355 lines
10 KiB
Go
355 lines
10 KiB
Go
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
|
||
}
|
||
|
||
// NewElectricButterflyValveEntity 创建电动蝶阀实体
|
||
func NewElectricButterflyValveEntity(w ecs.World, id string) *ecs.Entry {
|
||
entry := NewElectricControlValveEntity(w, id)
|
||
entry.AddComponent(component.ElectricButterflyValveTag)
|
||
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
|
||
}
|
||
|
||
// NewWaterClosedContainerEntity 创建封闭式水容器,如冷却塔、水处理器
|
||
func NewWaterClosedContainerEntity(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.WaterClosedContainerType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewCoolingTowerEntity 创建冷却塔实体
|
||
func NewCoolingTowerEntity(w ecs.World, id string) *ecs.Entry {
|
||
entry := NewWaterClosedContainerEntity(w, id)
|
||
entry.AddComponent(component.CoolingTowerTag)
|
||
return entry
|
||
}
|
||
|
||
// NewWaterProcessorEntity 创建水处理器实体
|
||
func NewWaterProcessorEntity(w ecs.World, id string) *ecs.Entry {
|
||
entry := NewWaterClosedContainerEntity(w, id)
|
||
entry.AddComponent(component.WaterProcessorTag)
|
||
return entry
|
||
}
|
||
|
||
// NewBypassValveSwitchEntity 创建旁通阀开关实体
|
||
func NewBypassValveSwitchEntity(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.ControlValveType, component.BypassValveSwitchTag))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewSensorEntity 创建传感器实体
|
||
func NewSensorEntity(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.SensorType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewThSensorEntity 创建温湿度传感器实体
|
||
func NewThSensorEntity(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.ThSensorType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewCO2SensorEntity CO2 传感器
|
||
func NewCO2SensorEntity(w ecs.World, id string) *ecs.Entry {
|
||
entry := NewSensorEntity(w, id)
|
||
entry.AddComponent(component.CO2SensorTag)
|
||
return entry
|
||
}
|
||
|
||
// NewWaterTSensorEntity 水温传感器
|
||
func NewWaterTSensorEntity(w ecs.World, id string) *ecs.Entry {
|
||
entry := NewSensorEntity(w, id)
|
||
entry.AddComponent(component.WaterTSensorTag)
|
||
return entry
|
||
}
|
||
|
||
// NewPressureSensorEntity 压力传感器
|
||
func NewPressureSensorEntity(w ecs.World, id string) *ecs.Entry {
|
||
entry := NewSensorEntity(w, id)
|
||
entry.AddComponent(component.PressureSensorTag)
|
||
return entry
|
||
}
|
||
|
||
// NewFlowSensorEntity 流量传感器
|
||
func NewFlowSensorEntity(w ecs.World, id string) *ecs.Entry {
|
||
entry := NewSensorEntity(w, id)
|
||
entry.AddComponent(component.FlowSensorTag)
|
||
return entry
|
||
}
|
||
|
||
// NewTemperatureSensorEntity 温度传感器
|
||
func NewTemperatureSensorEntity(w ecs.World, id string) *ecs.Entry {
|
||
entry := NewSensorEntity(w, id)
|
||
entry.AddComponent(component.TemperatureSensorTag)
|
||
return entry
|
||
}
|
||
|
||
// NewLightingGuidanceEntity 创建照明导向实体
|
||
func NewLightingGuidanceEntity(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.LightingGuidanceType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewPowerSwitchGuidanceEntity 创建电源开关导向实体
|
||
func NewPowerSwitchGuidanceEntity(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.PowerSwitchGuidanceType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewEscalatorGuidanceEntity 创建扶梯导向实体
|
||
func NewEscalatorGuidanceEntity(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.EscalatorGuidanceType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewTicketGateGuidanceEntity 创建闸机导向实体
|
||
func NewTicketGateGuidanceEntity(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.TicketGateGuidanceType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewSectionEvacuationGuidanceEntity 创建区间疏散导向实体
|
||
func NewSectionEvacuationGuidanceEntity(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.SectionEvacuationGuidanceType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewCivilDefenseDoorEntity 创建人防门实体
|
||
func NewCivilDefenseDoorEntity(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.CivilDefenseDoorType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewPlcControllerEntity 创建PLC控制器实体
|
||
func NewPlcControllerEntity(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.PlcControllerType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|
||
|
||
// NewNetworkSwitchEntity 创建网络交换机实体
|
||
func NewNetworkSwitchEntity(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.NetworkSwitchType))
|
||
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
wd.EntityMap[id] = e
|
||
}
|
||
return e
|
||
}
|