rts-sim-module/examples/signal_2xh1/sigSys/debug_sys.go
2023-10-10 18:06:30 +08:00

31 lines
881 B
Go

package sigSys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"log"
)
type SignalDebugSystem struct {
query *ecs.Query
}
func NewSignalDebugSystem() *SignalDebugSystem {
return &SignalDebugSystem{query: ecs.NewQuery(filter.Contains(component.Signal2XH1ElectronicType, component.Signal2XH1FilamentType))}
}
// Update world 执行
func (s *SignalDebugSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) {
uid := component.UidType.Get(entry)
state := component.Signal2XH1ElectronicType.Get(entry)
filament := component.Signal2XH1FilamentType.Get(entry)
//
ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
//
log.Printf("===>> uid = %s ddj = %t lxj = %t , 绿灯 = %t 红灯 = %t,\n", uid.Id, ddj.Val, lxj.Val, filament.L, filament.H)
})
}