rts-sim-module/simulation/init.go
2023-09-21 15:22:22 +08:00

24 lines
601 B
Go

package simulation
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)
entities.CreateModelStorageEntity(world, config.ModelManager)
//
return world
}