rts-sim-module/init.go
walker c4bc8c640f 重构singleton组件及相关方法接口
调整repo目录结构和命名
初步开始重构仿真实体加载
2023-12-28 16:49:28 +08:00

36 lines
746 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package rtss_simulation
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/modelrepo"
"joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/sys"
)
const (
// 仿真循环间隔单位ms
RtssSimulationTick = 20
)
// 初始化仿真
func NewSimulation(repo *repository.Repository) (ecs.World, error) {
w := ecs.NewWorld(RtssSimulationTick)
sys.BindSystem(w)
err := entity.Load(w, repo)
return w, err
}
// 加载城轨仿真
func LoadCgSimulation(repo modelrepo.Repo) (ecs.World, error) {
w := ecs.NewWorld(RtssSimulationTick)
// 加载组件实体
err := entity.LoadCg(w, repo)
if err != nil {
return nil, err
}
// 加载系统
sys.BindSystem(w)
return w, err
}