rts-sim-module/simulation/system/signal_system.go

43 lines
965 B
Go
Raw Normal View History

2023-08-15 18:12:30 +08:00
package system
import (
"github.com/yohamta/donburi/filter"
"joylink.club/ecs"
"joylink.club/rtsssimulation/components"
"joylink.club/rtsssimulation/state"
)
type SignalSystem struct {
}
// 信号机显示状态查询
var signalDisplayQuery *ecs.Query = ecs.NewQuery(filter.Contains(components.ComDeviceIdentity, components.ComSignalState))
// world 执行
func (me *SignalSystem) Update(world ecs.World) {
}
2023-08-16 15:00:24 +08:00
func NewSignalSystem() *SignalSystem {
return &SignalSystem{}
}
2023-08-15 18:12:30 +08:00
// 设置某个信号机的显示
// 返回值true-设置成功false-设置失败
func SetSignalDisplay(w ecs.World, signalId string, display state.SignalAspect) bool {
var signalState *state.SignalState
//
signalDisplayQuery.Each(w, func(e *ecs.Entry) {
if components.ComDeviceIdentity.Get(e).Id == signalId {
signalState = components.ComSignalState.Get(e)
}
})
//
if nil == signalState {
return false
}
//
signalState.Display = display
//
return true
}