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