rts-sim-module/examples/test1/tinit/init.go
2023-09-26 10:49:22 +08:00

26 lines
633 B
Go

package tinit
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/entities"
"joylink.club/rtsssimulation/system"
)
// InitializeWorld 初始化仿真world
func InitializeWorld(config *WorldConfig) ecs.World {
world := ecs.NewWorld(config.Tick)
// 添加系统
world.AddSystem(system.NewTimerSystem())
world.AddSystem(system.NewPercentageMovableSystem())
for _, sys := range config.Systems {
world.AddSystem(sys)
}
// 添加内置实体
entities.CreateSystemTimerEntity(world, config.InitTime)
if config.ModelManager != nil {
entities.CreateModelStorageEntity(world, config.ModelManager)
}
//
return world
}