-
Notifications
You must be signed in to change notification settings - Fork 9
/
shape_getter_test.go
60 lines (47 loc) · 1.32 KB
/
shape_getter_test.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
package ecs
import (
"testing"
"time"
)
type __ShapeGetter_Test_C_1 struct {
Component[__ShapeGetter_Test_C_1]
Field1 int
}
type __ShapeGetter_Test_C_2 struct {
Component[__ShapeGetter_Test_C_2]
Field1 int
}
type __ShapeGetter_Test_Shape_1 struct {
c1 *__ShapeGetter_Test_C_1
c2 *__ShapeGetter_Test_C_2
}
type __ShapeGetter_Test_S_1 struct {
System[__ShapeGetter_Test_S_1]
getter1 *Shape[__ShapeGetter_Test_Shape_1]
}
func (t *__ShapeGetter_Test_S_1) Init(initializer SystemInitConstraint) {
t.SetRequirements(initializer, &__ShapeGetter_Test_C_1{}, &__ShapeGetter_Test_C_2{})
t.getter1 = NewShape[__ShapeGetter_Test_Shape_1](initializer)
if t.getter1 == nil {
initializer.SetBroken("invalid getter")
}
}
func (t *__ShapeGetter_Test_S_1) Update(event Event) {
Log.Infof("__ShapeGetter_Test_S_1.Update, frame:%d", event.Frame)
iter := t.getter1.Get()
for s := iter.Begin(); !iter.End(); s = iter.Next() {
Log.Infof("s.c1:%+v, s.c2:%+v", s.c1, s.c2)
}
}
func TestNewShapeGetter(t *testing.T) {
world := NewSyncWorld(NewDefaultWorldConfig())
RegisterSystem[__ShapeGetter_Test_S_1](world)
world.Startup()
for i := 0; i < 3; i++ {
e := world.newEntity().Entity()
world.Add(e, &__ShapeGetter_Test_C_1{Field1: i}, &__ShapeGetter_Test_C_2{Field1: i * 10})
}
world.Update()
time.Sleep(time.Second)
world.Update()
}