This commit is contained in:
xzb 2023-09-27 17:08:11 +08:00
parent 899deff8b0
commit 7891fe2ded

View File

@ -24,11 +24,11 @@ var (
)
type ButtonSystem struct {
query *ecs.Query
selfRestQuery *ecs.Query
}
func NewButtonSystem() *ButtonSystem {
return &ButtonSystem{query: ecs.NewQuery(filter.Contains(ButtonStateComponent))}
return &ButtonSystem{selfRestQuery: ecs.NewQuery(filter.Contains(ButtonStateComponent, ButtonSelfRestTag))}
}
func NewButtonState() *ButtonState {
return &ButtonState{Ckd: false}
@ -36,11 +36,9 @@ func NewButtonState() *ButtonState {
// Update world 执行
func (me *ButtonSystem) Update(w ecs.World) {
me.query.Each(w, func(e *ecs.Entry) {
if e.HasComponent(ButtonSelfRestTag) {
state := ButtonStateComponent.Get(e)
me.calculateSelfRest(w, e, state)
}
me.selfRestQuery.Each(w, func(e *ecs.Entry) {
state := ButtonStateComponent.Get(e)
me.calculateSelfRest(w, e, state)
})
}