rts-sim-module/entities/common_entity.go
2023-09-15 10:13:25 +08:00

32 lines
942 B
Go

package entities
import (
"time"
"joylink.club/ecs"
"joylink.club/rtsssimulation/system"
"joylink.club/rtsssimulation/umi"
)
// 创建模型仓库实体
func CreateModelStorageEntity(w ecs.World, modelManager umi.IModelManager) *ecs.Entry {
e := w.Create(system.ModelStorageComponent)
system.ModelStorageComponent.Set(e, &system.ModelStorageRef{ModelManager: modelManager})
return e
}
// 创建继电器实体
func CreateRelayEntity(w ecs.World, relayId string) *ecs.Entry {
e := w.Create(system.EntityIdentityComponent, system.RelayStateComponent)
system.EntityIdentityComponent.Set(e, &system.EntityIdentity{Id: relayId})
system.RelayStateComponent.Set(e, system.NewRelayState())
return e
}
// 创建系统时钟实体
func CreateSystemTimerEntity(w ecs.World, systemTime time.Time) *ecs.Entry {
e := w.Create(system.SystemTimerComponent)
system.SystemTimerComponent.Set(e, system.NewSystemTimer(&systemTime))
return e
}