blob: 48eeb02469aeb27a427fda1ea1800f49c2d21949 (
plain)
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
|
package input
import "ponger/ecs"
type DeviceID int
type Event struct {
ecs.Event
Which DeviceID
Dx, Dy float32
JustPressed, JustReleased, IsPressed bool
}
type Handler interface {
Process(ev Event)
}
func ProcessTree(root any, ev Event) {
if inp, ok := root.(Handler); ok {
inp.Process(ev)
}
if g, ok := root.(ecs.IsGameObject); ok {
for _, c := range g.GO().Children {
if c == nil {
continue
}
ProcessTree(c, ev)
}
}
}
|