rts-sim-module/entity/iscs_afc.go

71 lines
2.0 KiB
Go
Raw Normal View History

2023-12-15 16:42:45 +08:00
package entity
import (
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
)
func newAfcGateEntity(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.AfcGateType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewEntranceGateEntity 创建进闸机实体
func NewEntranceGateEntity(w ecs.World, id string) *ecs.Entry {
entry := newAfcGateEntity(w, id)
entry.AddComponent(component.EntranceGateTag)
return entry
}
// NewExitGateEntity 创建出闸机实体
func NewExitGateEntity(w ecs.World, id string) *ecs.Entry {
entry := newAfcGateEntity(w, id)
entry.AddComponent(component.ExitGateTag)
return entry
}
// NewTwoWayGateEntity 创建双向闸机实体
func NewTwoWayGateEntity(w ecs.World, id string) *ecs.Entry {
entry := newAfcGateEntity(w, id)
entry.AddComponent(component.TwoWayGateTag)
return entry
}
func newTicketMachineEntity(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.TicketMachineType))
component.UidType.SetValue(e, component.Uid{Id: id})
wd.EntityMap[id] = e
}
return e
}
// NewTicketVendingMachineEntity 创建自动售票机实体
func NewTicketVendingMachineEntity(w ecs.World, id string) *ecs.Entry {
entry := newTicketMachineEntity(w, id)
entry.AddComponent(component.TicketVendingMachineTag)
return entry
}
// NewSemiAutoTicketMachineEntity 创建半自动售票机实体
func NewSemiAutoTicketMachineEntity(w ecs.World, id string) *ecs.Entry {
entry := newTicketMachineEntity(w, id)
entry.AddComponent(component.SemiAutoTicketMachineTag)
return entry
}
// NewTicketCheckingMachineEntity 创建验票机实体
func NewTicketCheckingMachineEntity(w ecs.World, id string) *ecs.Entry {
entry := newTicketMachineEntity(w, id)
entry.AddComponent(component.TicketCheckingMachineTag)
return entry
}