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
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|