rts-sim-module/entity/iscs_bas.go

155 lines
4.5 KiB
Go
Raw Normal View History

package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
)
// NewIscsFanEntity 创建风机实体
func NewIscsFanEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.FanType, component.FanStateType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewIscsTwoSpeedFanEntity 创建双速风机实体
func NewIscsTwoSpeedFanEntity(w ecs.World, id string) *ecs.Entry {
entry := NewIscsFanEntity(w, id)
entry.AddComponent(component.TwoSpeedFanTag)
return entry
}
// NewAirConditionerEntity 创建空调实体/空调器实体
//
// fc-true变频空调
func NewAirConditionerEntity(w ecs.World, id string, fc bool) *ecs.Entry {
entry := NewIscsFanEntity(w, id)
entry.HasComponent(component.AirConditionerTag)
component.FanType.Get(entry).Fc = fc
return entry
}
// NewCombinedAirConditionerEntity 组合式空调(变频空调)
func NewCombinedAirConditionerEntity(w ecs.World, id string) *ecs.Entry {
entry := NewAirConditionerEntity(w, id, true)
entry.AddComponent(component.CombinedAirConditionerTag)
return entry
}
// NewElectricControlValveEntity 创建电动调节阀实体
func NewElectricControlValveEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.ElectricControlValveType, component.TwoPositionTransformType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewElectricAirValveEntity 创建电动风阀实体
func NewElectricAirValveEntity(w ecs.World, id string) *ecs.Entry {
entry := NewElectricControlValveEntity(w, id)
entry.AddComponent(component.ElectricAirValveTag)
return entry
}
// NewCombinationAirValveEntity 创建组合式风阀
func NewCombinationAirValveEntity(w ecs.World, id string) *ecs.Entry {
entry := NewElectricControlValveEntity(w, id)
entry.AddComponent(component.CombinationAirValveTag)
return entry
}
// NewElectricTwoWayValveEntity 创建电动两通调节阀实体
func NewElectricTwoWayValveEntity(w ecs.World, id string) *ecs.Entry {
entry := NewElectricControlValveEntity(w, id)
entry.AddComponent(component.ElectricTwoWayValveTag)
return entry
}
// NewPurificationDeviceEntity 创建净化装置实体
func NewPurificationDeviceEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.PurificationDeviceType, component.CounterType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewElevatorDeviceEntity 创建垂直电梯实体
func NewElevatorDeviceEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.ElevatorType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewEscalatorDeviceEntity 创建自动扶梯实体
func NewEscalatorDeviceEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.EscalatorType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewChillerUnitEntity 创建冷水机组实体
func NewChillerUnitEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.ChillerUnitType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewWaterPumpEntity 创建水泵实体
func NewWaterPumpEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.WaterPumpType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewFloatBallWaterPumpEntity 创建浮球型水泵
func NewFloatBallWaterPumpEntity(w ecs.World, id string) *ecs.Entry {
entry := NewWaterPumpEntity(w, id)
entry.AddComponent(component.FloatBallSwitchType)
return entry
}
// NewWaterTankEntity 创建水池或水箱实体
func NewWaterTankEntity(w ecs.World, id string) *ecs.Entry {
wd := GetWorldData(w)
e, ok := wd.EntityMap[id]
if !ok {
e := w.Entry(w.Create(component.UidType, component.WaterTankType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}