-
Notifications
You must be signed in to change notification settings - Fork 1
/
systems.go
executable file
·84 lines (73 loc) · 1.08 KB
/
systems.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package zinc
// S ...
type S interface{}
// U ...
type U interface {
Update(dt float64)
}
// CU ...
type CU interface {
Cleanup()
}
// I ...
type I interface {
Initialize()
}
// SS ...
type SS interface {
// Initialize ...
I
// Update ...
U
// Cleanup ...
CU
Add(sys ...S)
}
type sys struct {
initialize []I
update []U
cleanup []CU
}
// NewSystems ...
// TODO: Write TEST
func NewSystems() SS {
return &sys{}
}
// Add ...
// TODO: Write TEST
func (s *sys) Add(sys ...S) {
for _, sysv := range sys {
switch v := sysv.(type) {
case I:
s.initialize = append(s.initialize, v)
break
case U:
s.update = append(s.update, v)
break
case CU:
s.cleanup = append(s.cleanup, v)
break
}
}
}
// Initialize ...
// TODO: Write TEST
func (s *sys) Initialize() {
for _, sys := range s.initialize {
sys.Initialize()
}
}
// Update ...
// TODO: Write TEST
func (s *sys) Update(dt float64) {
for _, sys := range s.update {
sys.Update(dt)
}
}
// Cleanup ...
// TODO: Write TEST
func (s *sys) Cleanup() {
for _, sys := range s.cleanup {
sys.Cleanup()
}
}