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 {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 信号机显示状态查询
|
2023-08-16 15:14:03 +08:00
|
|
|
|
var signalQuery *ecs.Query = ecs.NewQuery(filter.Contains(components.ComDeviceIdentity, components.ComSignalState))
|
2023-08-15 18:12:30 +08:00
|
|
|
|
|
|
|
|
|
// 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 {
|
2023-08-16 15:14:03 +08:00
|
|
|
|
var signalEntry *ecs.Entry
|
|
|
|
|
signalQuery.Each(w, func(e *ecs.Entry) {
|
|
|
|
|
if signalId == components.ComDeviceIdentity.Get(e).Id {
|
|
|
|
|
signalEntry = e
|
2023-08-15 18:12:30 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
2023-08-16 15:14:03 +08:00
|
|
|
|
//s
|
|
|
|
|
if signalEntry == nil {
|
2023-08-15 18:12:30 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
//
|
2023-08-16 15:14:03 +08:00
|
|
|
|
signalState := components.ComSignalState.Get(signalEntry)
|
2023-08-15 18:12:30 +08:00
|
|
|
|
signalState.Display = display
|
|
|
|
|
//
|
|
|
|
|
return true
|
|
|
|
|
}
|