rts-sim-module/sys/common_sys/counter.go
walker 97b2880c7b 修改断相保护器系统逻辑bug
修改道岔挤岔故障bug
修改计数器系统逻辑bug
2023-10-16 15:40:03 +08:00

28 lines
510 B
Go

package common_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
type CounterSys struct {
query *ecs.Query
}
func NewCounterSys() *CounterSys {
return &CounterSys{
query: ecs.NewQuery(filter.Contains(component.CounterType)),
}
}
// 更新
func (c *CounterSys) Update(w ecs.World) {
c.query.Each(w, func(entry *ecs.Entry) {
counter := component.CounterType.Get(entry)
if counter.Step > 0 {
counter.Val = counter.Val + counter.Step
}
})
}