rts-sim-module/entity/singleton.go
walker c56feb3bdf 道岔电路驱动系统实现
仿真单例组件定义(暂定)
仿真道岔相关实体构建(未完)
2023-09-27 18:39:18 +08:00

26 lines
603 B
Go

package entity
import (
"time"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository"
)
// 初始化世界数据
func InitWorldData(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)
}