rts-sim-module/sys/common_sys/counter.go
walker 9faf98f1eb 添加计数器系统
断相保护器逻辑修改
转辙机电路代码整理
2023-10-07 17:00:36 +08:00

28 lines
528 B
Go

package common_sys
import (
"github.com/yohamta/donburi/filter"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
)
type CounterSys struct {
query *ecs.Query
}
func NewCounterSys() *CounterDownSys {
return &CounterDownSys{
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
}
})
}