2023-09-13 10:05:42 +08:00
|
|
|
package simulation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/entities"
|
2023-09-15 13:48:48 +08:00
|
|
|
"joylink.club/rtsssimulation/system"
|
2023-09-13 10:05:42 +08:00
|
|
|
)
|
|
|
|
|
2023-09-15 13:48:48 +08:00
|
|
|
// InitializeWorld 初始化仿真world
|
2023-09-13 10:05:42 +08:00
|
|
|
func InitializeWorld(config *WorldConfig) ecs.World {
|
|
|
|
world := ecs.NewWorld(config.Tick)
|
2023-09-15 13:48:48 +08:00
|
|
|
// 添加系统
|
|
|
|
world.AddSystem(system.NewTimerSystem())
|
|
|
|
world.AddSystem(system.NewMovableSystem())
|
2023-09-13 10:05:42 +08:00
|
|
|
for _, sys := range config.Systems {
|
|
|
|
world.AddSystem(sys)
|
|
|
|
}
|
2023-09-15 13:48:48 +08:00
|
|
|
// 添加内置实体
|
2023-09-13 10:05:42 +08:00
|
|
|
entities.CreateSystemTimerEntity(world, config.InitTime)
|
2023-09-15 10:13:25 +08:00
|
|
|
entities.CreateModelStorageEntity(world, config.ModelManager)
|
2023-09-13 10:05:42 +08:00
|
|
|
//
|
|
|
|
return world
|
|
|
|
}
|