rts-sim-module/sys/common_sys/counter.go
walker 0bba8f0934 删除donburi包引用
修改filter导入为从ecs项目导入
整理包结构,将弃用的包放入deprecated文件中
2023-10-09 11:17:25 +08:00

28 lines
518 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() *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
}
})
}