33 lines
579 B
Go
33 lines
579 B
Go
package common_sys
|
|
|
|
import (
|
|
"github.com/yohamta/donburi/filter"
|
|
"joylink.club/ecs"
|
|
"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
|
|
}
|
|
}
|
|
})
|
|
}
|