2023-09-27 18:39:18 +08:00
|
|
|
|
package rtss_simulation
|
|
|
|
|
|
2023-09-28 14:34:00 +08:00
|
|
|
|
import (
|
|
|
|
|
"joylink.club/ecs"
|
|
|
|
|
"joylink.club/rtsssimulation/entity"
|
2023-12-28 16:49:28 +08:00
|
|
|
|
"joylink.club/rtsssimulation/modelrepo"
|
2023-09-28 14:34:00 +08:00
|
|
|
|
"joylink.club/rtsssimulation/repository"
|
2023-09-28 18:20:53 +08:00
|
|
|
|
"joylink.club/rtsssimulation/sys"
|
2023-09-28 14:34:00 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
// 仿真循环间隔,单位ms
|
|
|
|
|
RtssSimulationTick = 20
|
|
|
|
|
)
|
|
|
|
|
|
2023-09-27 18:39:18 +08:00
|
|
|
|
// 初始化仿真
|
2023-10-20 15:05:56 +08:00
|
|
|
|
func NewSimulation(repo *repository.Repository) (ecs.World, error) {
|
2023-09-28 14:34:00 +08:00
|
|
|
|
w := ecs.NewWorld(RtssSimulationTick)
|
2023-09-28 18:20:53 +08:00
|
|
|
|
sys.BindSystem(w)
|
2023-10-20 15:05:56 +08:00
|
|
|
|
err := entity.Load(w, repo)
|
|
|
|
|
return w, err
|
2023-09-28 14:34:00 +08:00
|
|
|
|
}
|
2023-12-28 16:49:28 +08:00
|
|
|
|
|
|
|
|
|
// 加载城轨仿真
|
|
|
|
|
func LoadCgSimulation(repo modelrepo.Repo) (ecs.World, error) {
|
|
|
|
|
w := ecs.NewWorld(RtssSimulationTick)
|
|
|
|
|
// 加载组件实体
|
2023-12-29 17:48:57 +08:00
|
|
|
|
err := entity.Loading(w, repo)
|
2023-12-28 16:49:28 +08:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
// 加载系统
|
|
|
|
|
sys.BindSystem(w)
|
|
|
|
|
return w, err
|
|
|
|
|
}
|