33 lines
569 B
Go
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
|
|
}
|
|
}
|
|
})
|
|
}
|