groups have a phase and after dependencies, but systems don't

This commit is contained in:
BlackMATov
2025-03-19 06:51:07 +07:00
parent fcfc74790d
commit b2145093a2
5 changed files with 219 additions and 210 deletions
+12 -6
View File
@@ -22,6 +22,13 @@ local phases = {
shutdown = evo.phase():build(),
}
local groups = {
awake = evo.group():phase(phases.awake):build(),
physics = evo.group():phase(phases.physics):build(),
graphics = evo.group():phase(phases.graphics):build(),
shutdown = evo.group():phase(phases.shutdown):build(),
}
local singles = {
delta_time = evo.fragment():single(0.016):build(),
physics_gravity = evo.fragment():single(vector2(0, 9.81)):build(),
@@ -40,7 +47,7 @@ local queries = {
}
local awake_system = evo.system()
:phase(phases.awake)
:group(groups.awake)
:prologue(function()
print '-= | Awake | =-'
evo.entity()
@@ -51,7 +58,7 @@ local awake_system = evo.system()
end):build()
local integrate_forces_system = evo.system()
:phase(phases.physics)
:group(groups.physics)
:query(queries.physics_bodies)
:execute(function(chunk, entities, entity_count)
---@type number, evolved.vector2
@@ -72,8 +79,7 @@ local integrate_forces_system = evo.system()
end):build()
local integrate_velocities_system = evo.system()
:phase(phases.physics)
:after(integrate_forces_system)
:group(groups.physics)
:query(queries.physics_bodies)
:execute(function(chunk, entities, entity_count)
---@type number
@@ -96,7 +102,7 @@ local integrate_velocities_system = evo.system()
end):build()
local graphics_system = evo.system()
:phase(phases.graphics)
:group(groups.graphics)
:query(queries.physics_bodies)
:execute(function(chunk, entities, entity_count)
---@type evolved.vector2[]
@@ -113,7 +119,7 @@ local graphics_system = evo.system()
end):build()
local shutdown_system = evo.system()
:phase(phases.shutdown)
:group(groups.shutdown)
:epilogue(function()
print '-= | Shutdown | =-'
evo.batch_destroy(queries.physics_bodies)
+20 -20
View File
@@ -6569,26 +6569,6 @@ do
end
end
do
local s1 = evo.system():build()
do
local after = evo.get(s1, evo.AFTER)
assert(after == nil)
end
local s2 = evo.system():after(s1):build()
do
local after = evo.get(s2, evo.AFTER)
assert(#after == 1 and after[1] == s1)
end
local s3 = evo.system():after(s1, s2):build()
do
local after = evo.get(s3, evo.AFTER)
assert(#after == 2 and after[1] == s1 and after[2] == s2)
end
end
do
local f1, f2 = evo.id(2)
@@ -8222,3 +8202,23 @@ do
local s = evo.system():group(g):build()
assert(evo.get(s, evo.GROUP) == g)
end
do
local s1 = evo.group():build()
do
local after = evo.get(s1, evo.AFTER)
assert(after == nil)
end
local g2 = evo.group():after(s1):build()
do
local after = evo.get(g2, evo.AFTER)
assert(#after == 1 and after[1] == s1)
end
local g3 = evo.group():after(s1, g2):build()
do
local after = evo.get(g3, evo.AFTER)
assert(#after == 2 and after[1] == s1 and after[2] == g2)
end
end