26 lines
603 B
Go
26 lines
603 B
Go
package entity
|
|
|
|
import (
|
|
"time"
|
|
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/component"
|
|
"joylink.club/rtsssimulation/repository"
|
|
)
|
|
|
|
// 初始化世界数据
|
|
func LoadWorldData(w ecs.World, repo *repository.Repository) {
|
|
entry := w.Create(component.WorldDataType)
|
|
component.WorldDataType.Set(entry, &component.WorldData{
|
|
Repo: repo,
|
|
Time: time.Now().UnixMilli(),
|
|
EntityMap: make(map[string]*ecs.Entry),
|
|
})
|
|
}
|
|
|
|
// 获取世界数据
|
|
func GetWorldData(w ecs.World) *component.WorldData {
|
|
entry := component.WorldDataType.MustFirst(w)
|
|
return component.WorldDataType.Get(entry)
|
|
}
|