2023-12-11 17:16:51 +08:00
|
|
|
|
package entity
|
2023-12-11 18:09:28 +08:00
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"joylink.club/ecs"
|
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// NewIscsFanEntity 创建风机实体
|
|
|
|
|
func NewIscsFanEntity(w ecs.World, id string) *ecs.Entry {
|
2023-12-12 13:23:51 +08:00
|
|
|
|
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
|
|
|
|
|
}
|
2023-12-11 18:09:28 +08:00
|
|
|
|
return e
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewIscsTwoSpeedFanEntity 创建双速风机实体
|
|
|
|
|
func NewIscsTwoSpeedFanEntity(w ecs.World, id string) *ecs.Entry {
|
|
|
|
|
entry := NewIscsFanEntity(w, id)
|
|
|
|
|
entry.AddComponent(component.TwoSpeedFanTag)
|
|
|
|
|
return entry
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 14:41:39 +08:00
|
|
|
|
// NewAirConditionerEntity 创建空调实体/空调器实体
|
2023-12-11 18:09:28 +08:00
|
|
|
|
//
|
|
|
|
|
// fc-true变频空调;
|
2023-12-12 14:41:39 +08:00
|
|
|
|
func NewAirConditionerEntity(w ecs.World, id string, fc bool) *ecs.Entry {
|
2023-12-11 18:09:28 +08:00
|
|
|
|
entry := NewIscsFanEntity(w, id)
|
|
|
|
|
entry.HasComponent(component.AirConditionerTag)
|
|
|
|
|
component.FanType.Get(entry).Fc = fc
|
|
|
|
|
return entry
|
|
|
|
|
}
|
2023-12-12 13:08:37 +08:00
|
|
|
|
|
2023-12-12 14:41:39 +08:00
|
|
|
|
// NewCombinedAirConditionerEntity 组合式空调(变频空调)
|
|
|
|
|
func NewCombinedAirConditionerEntity(w ecs.World, id string) *ecs.Entry {
|
|
|
|
|
entry := NewAirConditionerEntity(w, id, true)
|
2023-12-12 13:08:37 +08:00
|
|
|
|
entry.AddComponent(component.CombinedAirConditionerTag)
|
|
|
|
|
return entry
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 14:41:39 +08:00
|
|
|
|
// NewElectricControlValveEntity 创建电动调节阀实体
|
|
|
|
|
func NewElectricControlValveEntity(w ecs.World, id string) *ecs.Entry {
|
2023-12-12 13:23:51 +08:00
|
|
|
|
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
|
|
|
|
|
}
|
2023-12-12 13:08:37 +08:00
|
|
|
|
return e
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 14:41:39 +08:00
|
|
|
|
// NewElectricAirValveEntity 创建电动风阀实体
|
|
|
|
|
func NewElectricAirValveEntity(w ecs.World, id string) *ecs.Entry {
|
|
|
|
|
entry := NewElectricControlValveEntity(w, id)
|
2023-12-12 13:08:37 +08:00
|
|
|
|
entry.AddComponent(component.ElectricAirValveTag)
|
|
|
|
|
return entry
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 14:41:39 +08:00
|
|
|
|
// NewCombinationAirValveEntity 创建组合式风阀
|
|
|
|
|
func NewCombinationAirValveEntity(w ecs.World, id string) *ecs.Entry {
|
|
|
|
|
entry := NewElectricControlValveEntity(w, id)
|
2023-12-12 13:08:37 +08:00
|
|
|
|
entry.AddComponent(component.CombinationAirValveTag)
|
|
|
|
|
return entry
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 14:41:39 +08:00
|
|
|
|
// NewElectricTwoWayValveEntity 创建电动两通调节阀实体
|
|
|
|
|
func NewElectricTwoWayValveEntity(w ecs.World, id string) *ecs.Entry {
|
|
|
|
|
entry := NewElectricControlValveEntity(w, id)
|
2023-12-12 13:08:37 +08:00
|
|
|
|
entry.AddComponent(component.ElectricTwoWayValveTag)
|
|
|
|
|
return entry
|
|
|
|
|
}
|
2023-12-12 14:41:39 +08:00
|
|
|
|
|
2023-12-13 14:54:23 +08:00
|
|
|
|
// NewElectricButterflyValveEntity 创建电动蝶阀实体
|
|
|
|
|
func NewElectricButterflyValveEntity(w ecs.World, id string) *ecs.Entry {
|
|
|
|
|
entry := NewElectricControlValveEntity(w, id)
|
|
|
|
|
entry.AddComponent(component.ElectricButterflyValveTag)
|
|
|
|
|
return entry
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-12 14:41:39 +08:00
|
|
|
|
// 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
|
|
|
|
|
}
|
2023-12-12 16:00:53 +08:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
2023-12-12 18:07:38 +08:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
2023-12-13 10:21:02 +08:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
2023-12-13 14:54:23 +08:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
2023-12-13 15:21:16 +08:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
2023-12-13 16:01:20 +08:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
2023-12-13 16:10:18 +08:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|
2023-12-13 17:01:19 +08:00
|
|
|
|
|
|
|
|
|
// NewEmergencyLightingEntity 创建应急照明实体
|
|
|
|
|
func NewEmergencyLightingEntity(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.EmergencyLightingType))
|
|
|
|
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
|
|
|
|
wd.EntityMap[id] = e
|
|
|
|
|
}
|
|
|
|
|
return e
|
|
|
|
|
}
|
2023-12-13 17:27:26 +08:00
|
|
|
|
|
|
|
|
|
// NewAirCurtainEntity 创建空气幕实体
|
|
|
|
|
func NewAirCurtainEntity(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.AirCurtainType))
|
|
|
|
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
|
|
|
|
wd.EntityMap[id] = e
|
|
|
|
|
}
|
|
|
|
|
return e
|
|
|
|
|
}
|