-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathtest37.lua
81 lines (66 loc) · 1.33 KB
/
test37.lua
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
local ecs = require "ecs"
local w = ecs.world()
w:register {
name = "scene",
"parent:int64",
}
w:register {
name = "dummy",
}
w:register {
name = "visible",
}
w:register {
name = "name",
type = "lua"
}
--[[
A
B
C
H
I
D
E
F
G
J
DUMMY
]]
local eid = {}
local function new(v, parent)
if parent then
if parent == "" then
v.scene = { parent = 0 }
else
local pid = assert(eid[parent])
v.scene = { parent = pid }
end
end
local id = w:new(v)
if v.name then
eid[v.name] = id
end
end
new ( { name = "FIRST" }, "" )
new ( { name = "A" }, "" )
new ( { name = "B" , visible = true }, "" )
new ( { name = "C" }, "B" )
new ( { name = "D" }, "" )
new ( { name = "E" , visible = true }, "D" )
new ( { name = "F" }, "E" )
new ( { name = "G" }, "D" )
new ( { dummy = true , name = "dummy", visible = true } ) -- no scene
new ( { name = "H" }, "C" )
new ( { name = "I" }, "C" )
new ( { name = "J" }, "D" )
new ( { dummy = true , name = "dummy2"} ) -- no scene
new ( { dummy = true , name = "dummy3", visible = true } ) -- no scene
for v in w:select "name:in scene?in eid:in visible?in" do
print(v.eid, v.name, v.scene and v.scene.parent, v.visible)
end
print "propagate"
w:propagate("scene", "visible")
for v in w:select "name:in scene?in eid:in visible" do
print(v.eid, v.name, v.scene and v.scene.parent)
end