-
Notifications
You must be signed in to change notification settings - Fork 0
/
sys_pause.go
33 lines (27 loc) · 904 Bytes
/
sys_pause.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package bees
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
"github.com/mlange-42/arche-model/model"
"github.com/mlange-42/arche/ecs"
"github.com/mlange-42/arche/generic"
)
// UISysManagePause is a simple system that listens to clicks and pauses the simulation..
type UISysManagePause struct {
systems generic.Resource[model.Systems]
}
// InitializeUI the system
func (s *UISysManagePause) InitializeUI(world *ecs.World) {
s.systems = generic.NewResource[model.Systems](world)
}
// UpdateUI the system
func (s *UISysManagePause) UpdateUI(world *ecs.World) {
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButton0) {
sys := s.systems.Get()
sys.Paused = !sys.Paused
}
}
// PostUpdateUI the system
func (s *UISysManagePause) PostUpdateUI(world *ecs.World) {}
// FinalizeUI the system
func (s *UISysManagePause) FinalizeUI(world *ecs.World) {}