【增加获取继电器状态方法】
This commit is contained in:
parent
be88137f2a
commit
cafec76de9
@ -3,9 +3,15 @@ package entities
|
||||
import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/repository"
|
||||
"joylink.club/rtsssimulation/simulation"
|
||||
"joylink.club/rtsssimulation/system"
|
||||
)
|
||||
|
||||
type RelayState struct {
|
||||
Id string
|
||||
Xh bool
|
||||
}
|
||||
|
||||
// CreateRelayEntity 创建继电器实体
|
||||
func CreateRelayEntity(w ecs.World, relayId string) *ecs.Entry {
|
||||
e := w.Create(system.EntityIdentityComponent, system.RelayStateComponent)
|
||||
@ -19,3 +25,13 @@ func CreateRelayEntries(world ecs.World, relays []*repository.Relay) {
|
||||
CreateRelayEntity(world, relay.Id())
|
||||
}
|
||||
}
|
||||
|
||||
func GetRelayState(worldId ecs.WorldId, relayId string) *RelayState {
|
||||
sim := simulation.FindSimulation(worldId)
|
||||
entry := sim.GetEntry(relayId)
|
||||
if entry == nil {
|
||||
return nil
|
||||
}
|
||||
state := system.RelayStateComponent.Get(entry)
|
||||
return &RelayState{Id: relayId, Xh: state.Xh}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func TurnToReverse(worldId ecs.WorldId, turnoutId string) {
|
||||
}()
|
||||
}
|
||||
|
||||
func GetState(worldId ecs.WorldId, turnoutId string) *TurnoutState {
|
||||
func GetTurnoutState(worldId ecs.WorldId, turnoutId string) *TurnoutState {
|
||||
sim := simulation.FindSimulation(worldId)
|
||||
entry := sim.GetEntry(turnoutId)
|
||||
if entry == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user