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

33 lines
569 B
Go

package common_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
)
type CounterDownSys struct {
query *ecs.Query
}
func NewCounterDownSys() *CounterDownSys {
return &CounterDownSys{
query: ecs.NewQuery(filter.Contains(component.CounterDownType)),
}
}
// 更新
func (c *CounterDownSys) Update(w ecs.World) {
c.query.Each(w, func(entry *ecs.Entry) {
cd := component.CounterDownType.Get(entry)
if cd.Val > 0 {
v := cd.Val - cd.Step
if v < 0 {
cd.Val = 0
} else {
cd.Val = v
}
}
})
}