Skip to content

Commit ef033e7

Browse files
authored
Merge pull request #3 from BlackMATov/dev
Dev
2 parents 3638ded + 3d13826 commit ef033e7

6 files changed

Lines changed: 223 additions & 714 deletions

File tree

README.md

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ ON_ASSIGN :: fragment
4040
ON_INSERT :: fragment
4141
ON_REMOVE :: fragment
4242
43-
PHASE :: fragment
4443
GROUP :: fragment
45-
AFTER :: fragment
4644
4745
QUERY :: fragment
4846
EXECUTE :: fragment
@@ -107,7 +105,7 @@ components :: chunk, fragment... -> component[]...
107105
each :: entity -> {each_state? -> fragment?, component?}, each_state?
108106
execute :: query -> {execute_state? -> chunk?, entity[]?, integer?}, execute_state?
109107
110-
process :: phase... -> ()
108+
process :: system... -> ()
111109
112110
spawn_at :: chunk?, fragment[]?, component[]? -> entity
113111
spawn_as :: entity?, fragment[]?, component[]? -> entity
@@ -149,38 +147,16 @@ query_builder:exclude :: fragment... -> query_builder
149147
query_builder:build :: query
150148
```
151149

152-
```
153-
group :: group_builder
154-
group_builder:name :: string -> group_builder
155-
group_builder:single :: component -> group_builder
156-
group_builder:disable :: group_builder
157-
group_builder:phase :: phase -> group_builder
158-
group_builder:after :: group... -> group_builder
159-
group_builder:prologue :: {} -> group_builder
160-
group_builder:epilogue :: {} -> group_builder
161-
group_builder:build :: group
162-
```
163-
164-
```
165-
phase :: phase_builder
166-
phase_builder:name :: string -> phase_builder
167-
phase_builder:single :: component -> phase_builder
168-
phase_builder:disable :: phase_builder
169-
phase_builder:prologue :: {} -> phase_builder
170-
phase_builder:epilogue :: {} -> phase_builder
171-
phase_builder:build :: phase
172-
```
173-
174150
```
175151
system :: system_builder
176152
system_builder:name :: string -> system_builder
177153
system_builder:single :: component -> system_builder
178-
system_builder:disable :: system_builder
179-
system_builder:group :: group -> system_builder
154+
system_builder:group :: system -> system_builder
180155
system_builder:query :: query -> system_builder
181156
system_builder:execute :: {chunk, entity[], integer} -> system_builder
182157
system_builder:prologue :: {} -> system_builder
183158
system_builder:epilogue :: {} -> system_builder
159+
system_builder:disabled :: system_builder
184160
system_builder:build :: system
185161
```
186162

ROADMAP.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
## Backlog
44

5-
- can we pass systems and groups to the process function?
65
- builders should be rewritten :/
76
- is/has_all/any for lists?
87

98
## After first release
109

1110
- cached queries
12-
- multi-phase groups
13-
- multi-group systems
1411
- observers and events
1512
- add INDEX fragment trait
1613
- add REQUIRES fragment trait

develop/example.lua

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,11 @@ local function vector2(x, y)
1515
return { x = x, y = y }
1616
end
1717

18-
local phases = {
19-
awake = evo.phase():build(),
20-
physics = evo.phase():build(),
21-
graphics = evo.phase():build(),
22-
shutdown = evo.phase():build(),
23-
}
24-
2518
local groups = {
26-
awake = evo.group():phase(phases.awake):build(),
27-
physics = evo.group():phase(phases.physics):build(),
28-
graphics = evo.group():phase(phases.graphics):build(),
29-
shutdown = evo.group():phase(phases.shutdown):build(),
19+
awake = evo.system():build(),
20+
physics = evo.system():build(),
21+
graphics = evo.system():build(),
22+
shutdown = evo.system():build(),
3023
}
3124

3225
local singles = {
@@ -126,12 +119,12 @@ local shutdown_system = evo.system()
126119
end):build()
127120

128121
do
129-
evo.process(phases.awake)
122+
evo.process(groups.awake)
130123

131124
for _ = 1, 10 do
132-
evo.process(phases.physics)
133-
evo.process(phases.graphics)
125+
evo.process(groups.physics)
126+
evo.process(groups.graphics)
134127
end
135128

136-
evo.process(phases.shutdown)
129+
evo.process(groups.shutdown)
137130
end

develop/unbench.lua

Lines changed: 85 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -610,28 +610,6 @@ basics.describe_bench(string.format('create and destroy %d entities with 5 compo
610610

611611
print '----------------------------------------'
612612

613-
basics.describe_bench(string.format('create and destroy %d entities / spawn_at', N),
614-
---@param entities evolved.id[]
615-
function(entities)
616-
local destroy = evo.destroy
617-
local spawn_at = evo.spawn_at
618-
619-
local fragments = {}
620-
local components = {}
621-
622-
local chunk = nil
623-
624-
for i = 1, N do
625-
entities[i] = spawn_at(chunk, fragments, components)
626-
end
627-
628-
for i = #entities, 1, -1 do
629-
destroy(entities[i])
630-
end
631-
end, function()
632-
return {}
633-
end)
634-
635613
basics.describe_bench(string.format('create and destroy %d entities with 1 components / spawn_at', N),
636614
---@param entities evolved.id[]
637615
function(entities)
@@ -729,26 +707,103 @@ basics.describe_bench(string.format('create and destroy %d entities with 5 compo
729707

730708
print '----------------------------------------'
731709

732-
basics.describe_bench(string.format('create and destroy %d entities / spawn_with', N),
710+
basics.describe_bench(string.format('create and destroy %d entities with 1 components / spawn_as', N),
733711
---@param entities evolved.id[]
734712
function(entities)
735-
local destroy = evo.destroy
736-
local spawn_with = evo.spawn_with
713+
local spawn_as = evo.spawn_as
714+
715+
local fragments = { F1 }
716+
local components = { true }
737717

738-
local fragments = {}
739-
local components = {}
718+
local prefab = evo.spawn_with(fragments, components)
740719

741720
for i = 1, N do
742-
entities[i] = spawn_with(fragments, components)
721+
entities[i] = spawn_as(prefab, fragments, components)
743722
end
744723

745-
for i = #entities, 1, -1 do
746-
destroy(entities[i])
724+
evo.batch_destroy(Q1)
725+
end, function()
726+
return {}
727+
end)
728+
729+
basics.describe_bench(string.format('create and destroy %d entities with 2 components / spawn_as', N),
730+
---@param entities evolved.id[]
731+
function(entities)
732+
local spawn_as = evo.spawn_as
733+
734+
local fragments = { F1, F2 }
735+
local components = { true, true }
736+
737+
local prefab = evo.spawn_with(fragments, components)
738+
739+
for i = 1, N do
740+
entities[i] = spawn_as(prefab, fragments, components)
741+
end
742+
743+
evo.batch_destroy(Q1)
744+
end, function()
745+
return {}
746+
end)
747+
748+
basics.describe_bench(string.format('create and destroy %d entities with 3 components / spawn_as', N),
749+
---@param entities evolved.id[]
750+
function(entities)
751+
local spawn_as = evo.spawn_as
752+
753+
local fragments = { F1, F2, F3 }
754+
local components = { true, true, true }
755+
756+
local prefab = evo.spawn_with(fragments, components)
757+
758+
for i = 1, N do
759+
entities[i] = spawn_as(prefab, fragments, components)
760+
end
761+
762+
evo.batch_destroy(Q1)
763+
end, function()
764+
return {}
765+
end)
766+
767+
basics.describe_bench(string.format('create and destroy %d entities with 4 components / spawn_as', N),
768+
---@param entities evolved.id[]
769+
function(entities)
770+
local spawn_as = evo.spawn_as
771+
772+
local fragments = { F1, F2, F3, F4 }
773+
local components = { true, true, true, true }
774+
775+
local prefab = evo.spawn_with(fragments, components)
776+
777+
for i = 1, N do
778+
entities[i] = spawn_as(prefab, fragments, components)
779+
end
780+
781+
evo.batch_destroy(Q1)
782+
end, function()
783+
return {}
784+
end)
785+
786+
basics.describe_bench(string.format('create and destroy %d entities with 5 components / spawn_as', N),
787+
---@param entities evolved.id[]
788+
function(entities)
789+
local spawn_as = evo.spawn_as
790+
791+
local fragments = { F1, F2, F3, F4, F5 }
792+
local components = { true, true, true, true, true }
793+
794+
local prefab = evo.spawn_with(fragments, components)
795+
796+
for i = 1, N do
797+
entities[i] = spawn_as(prefab, fragments, components)
747798
end
799+
800+
evo.batch_destroy(Q1)
748801
end, function()
749802
return {}
750803
end)
751804

805+
print '----------------------------------------'
806+
752807
basics.describe_bench(string.format('create and destroy %d entities with 1 components / spawn_with', N),
753808
---@param entities evolved.id[]
754809
function(entities)

develop/untests.lua

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5929,17 +5929,13 @@ do
59295929
local q = evo.query():build()
59305930
assert(evo.get(q, evo.NAME) == nil)
59315931

5932-
local p = evo.phase():build()
5933-
assert(evo.get(p, evo.NAME) == nil)
5934-
59355932
local s = evo.system():build()
59365933
assert(evo.get(s, evo.NAME) == nil)
59375934
end
59385935

59395936
do
59405937
local fb = evo.fragment()
59415938
local qb = evo.query()
5942-
local pb = evo.phase()
59435939
local sb = evo.system()
59445940

59455941
do
@@ -5949,9 +5945,6 @@ do
59495945
local q = qb:name('query'):build()
59505946
assert(evo.get(q, evo.NAME) == 'query')
59515947

5952-
local p = pb:name('phase'):build()
5953-
assert(evo.get(p, evo.NAME) == 'phase')
5954-
59555948
local s = sb:name('system'):build()
59565949
assert(evo.get(s, evo.NAME) == 'system')
59575950
end
@@ -5963,9 +5956,6 @@ do
59635956
local q = qb:build()
59645957
assert(evo.get(q, evo.NAME) == nil)
59655958

5966-
local p = pb:build()
5967-
assert(evo.get(p, evo.NAME) == nil)
5968-
59695959
local s = sb:build()
59705960
assert(evo.get(s, evo.NAME) == nil)
59715961
end
@@ -5974,7 +5964,6 @@ end
59745964
do
59755965
local fb = evo.fragment()
59765966
local qb = evo.query()
5977-
local pb = evo.phase()
59785967
local sb = evo.system()
59795968

59805969
do
@@ -5984,9 +5973,6 @@ do
59845973
local q = qb:single(false):build()
59855974
assert(evo.get(q, q) == false)
59865975

5987-
local p = pb:single(false):build()
5988-
assert(evo.get(p, p) == false)
5989-
59905976
local s = sb:single(false):build()
59915977
assert(evo.get(s, s) == false)
59925978
end
@@ -5998,9 +5984,6 @@ do
59985984
local q = qb:build()
59995985
assert(evo.get(q, q) == nil)
60005986

6001-
local p = pb:build()
6002-
assert(evo.get(p, p) == nil)
6003-
60045987
local s = sb:build()
60055988
assert(evo.get(s, s) == nil)
60065989
end
@@ -7315,7 +7298,7 @@ do
73157298
end
73167299

73177300
do
7318-
local gb = evo.group()
7301+
local gb = evo.system()
73197302

73207303
local g1 = gb:build()
73217304
local g2 = gb:name('g2'):build()
@@ -7329,31 +7312,11 @@ do
73297312
end
73307313

73317314
do
7332-
local g = evo.group():build()
7315+
local g = evo.system():build()
73337316
local s = evo.system():group(g):build()
73347317
assert(evo.get(s, evo.GROUP) == g)
73357318
end
73367319

7337-
do
7338-
local s1 = evo.group():build()
7339-
do
7340-
local after = evo.get(s1, evo.AFTER)
7341-
assert(after == nil)
7342-
end
7343-
7344-
local g2 = evo.group():after(s1):build()
7345-
do
7346-
local after = evo.get(g2, evo.AFTER)
7347-
assert(#after == 1 and after[1] == s1)
7348-
end
7349-
7350-
local g3 = evo.group():after(s1, g2):build()
7351-
do
7352-
local after = evo.get(g3, evo.AFTER)
7353-
assert(#after == 2 and after[1] == s1 and after[2] == g2)
7354-
end
7355-
end
7356-
73577320
do
73587321
local f1 = evo.id()
73597322
local c1 = evo.chunk(f1)

0 commit comments

Comments
 (0)