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

28 lines
718 B
Go

package entities
import (
"time"
"joylink.club/ecs"
"joylink.club/rtsssimulation/system"
)
// 创建模型仓库实体
func CreateModelStorageEntity(w ecs.World) *ecs.Entry {
return w.Create(system.ModelStorageComponent)
}
// 创建继电器实体
func CreateRelayEntity(w ecs.World, relayId string) *ecs.Entry {
e := w.Create(system.EntityIdentityComponent, system.RelayStateComponent)
system.EntityIdentityComponent.Set(e, &system.EntityIdentity{Id: relayId})
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
}