126 lines
3.6 KiB
Go
126 lines
3.6 KiB
Go
|
package entity
|
||
|
|
||
|
import (
|
||
|
"joylink.club/ecs"
|
||
|
"joylink.club/rtsssimulation/component"
|
||
|
)
|
||
|
|
||
|
// NewNetworkHostEntity 创建网络设备、网络主机等实体
|
||
|
func NewNetworkHostEntity(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.NetworkHostType))
|
||
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
|
wd.EntityMap[id] = e
|
||
|
}
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// NewSmokeDetectorEntity 创建烟感实体
|
||
|
func NewSmokeDetectorEntity(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.SmokeDetectorType))
|
||
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
|
wd.EntityMap[id] = e
|
||
|
}
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// NewTemperatureDetectorEntity 创建温感实体
|
||
|
func NewTemperatureDetectorEntity(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.TemperatureDetectorType))
|
||
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
|
wd.EntityMap[id] = e
|
||
|
}
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// NewManualFireAlarmButtonEntity 创建手动火灾报警按钮实体
|
||
|
func NewManualFireAlarmButtonEntity(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.ManualFireAlarmButtonType))
|
||
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
|
wd.EntityMap[id] = e
|
||
|
}
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// NewGasFireExtinguisherEntity 创建气体灭火器实体
|
||
|
func NewGasFireExtinguisherEntity(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.GasFireExtinguisherType))
|
||
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
|
wd.EntityMap[id] = e
|
||
|
}
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// NewAlarmBellEntity 创建警铃实体
|
||
|
func NewAlarmBellEntity(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.AlarmBellType))
|
||
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
|
wd.EntityMap[id] = e
|
||
|
}
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// 创建防火卷帘
|
||
|
func newFireRollerShutterEntity(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.FireRollerShutterType))
|
||
|
component.UidType.SetValue(e, component.Uid{Id: id})
|
||
|
wd.EntityMap[id] = e
|
||
|
}
|
||
|
return e
|
||
|
}
|
||
|
|
||
|
// NewPartitionTypeFireRollerShutterEntity 创建隔断型防火卷帘
|
||
|
func NewPartitionTypeFireRollerShutterEntity(w ecs.World, id string) *ecs.Entry {
|
||
|
entry := newFireRollerShutterEntity(w, id)
|
||
|
entry.AddComponent(component.PartitionTypeFireRollerShutterTag)
|
||
|
return entry
|
||
|
}
|
||
|
|
||
|
// NewEvacuationTypeFireRollerShutterEntity 创建疏散型防火卷帘
|
||
|
func NewEvacuationTypeFireRollerShutterEntity(w ecs.World, id string) *ecs.Entry {
|
||
|
entry := newFireRollerShutterEntity(w, id)
|
||
|
entry.AddComponent(component.EvacuationTypeFireRollerShutterTag)
|
||
|
return entry
|
||
|
}
|
||
|
|
||
|
// NewFirePumpEntity 创建消防泵实体
|
||
|
func NewFirePumpEntity(w ecs.World, id string) *ecs.Entry {
|
||
|
entry := NewWaterPumpEntity(w, id)
|
||
|
entry.AddComponent(component.FirePumpTag)
|
||
|
return entry
|
||
|
}
|
||
|
|
||
|
// NewSprayPumpEntity 创建喷淋泵实体
|
||
|
func NewSprayPumpEntity(w ecs.World, id string) *ecs.Entry {
|
||
|
entry := NewWaterPumpEntity(w, id)
|
||
|
entry.AddComponent(component.SprayPumpTag)
|
||
|
return entry
|
||
|
}
|
||
|
|
||
|
// NewStabilizedPressurePumpEntity 创建稳压泵实体
|
||
|
func NewStabilizedPressurePumpEntity(w ecs.World, id string) *ecs.Entry {
|
||
|
entry := NewWaterPumpEntity(w, id)
|
||
|
entry.AddComponent(component.StabilizedPressurePumpTag)
|
||
|
return entry
|
||
|
}
|