mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2026-07-22 07:56:52 -06:00
Make enabling/disabling Systems not use varargs.
This commit is contained in:
+6
-2
@@ -139,14 +139,18 @@ describe('tiny-ecs:', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("Disable and Enable Systems", function()
|
it("Disable and Enable Systems", function()
|
||||||
world:deactivate(moveSystem, oneTimeSystem)
|
world:deactivate(moveSystem)
|
||||||
|
world:deactivate(oneTimeSystem)
|
||||||
world:update(1)
|
world:update(1)
|
||||||
|
assert.equals(world:getSystemCount(), 2)
|
||||||
assert.equals(timePassed, 0)
|
assert.equals(timePassed, 0)
|
||||||
assert.equals(entity1.xform.x, entityTemplate1.xform.x)
|
assert.equals(entity1.xform.x, entityTemplate1.xform.x)
|
||||||
world:activate(moveSystem, oneTimeSystem)
|
world:activate(moveSystem)
|
||||||
|
world:activate(oneTimeSystem)
|
||||||
world:update(1)
|
world:update(1)
|
||||||
assert.equals(timePassed, 1)
|
assert.equals(timePassed, 1)
|
||||||
assert.are_not.equal(entity1.xform.x, entityTemplate1.xform.x)
|
assert.are_not.equal(entity1.xform.x, entityTemplate1.xform.x)
|
||||||
|
assert.equals(world:getSystemCount(), 2)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("Clear Entities", function()
|
it("Clear Entities", function()
|
||||||
|
|||||||
@@ -596,30 +596,24 @@ function tiny.setSystemIndex(world, system, index)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Activates Systems in the World.
|
--- Activate a System in the World.
|
||||||
-- Activated Systems will be update whenever tiny.update(world, dt) is called.
|
-- Activated Systems will be update whenever tiny.update(world, dt) is called.
|
||||||
-- @param world
|
-- @param world
|
||||||
-- @param ... Systems to activate. The Systems must already be added to the
|
-- @param system System to activate. The System must already be added to the
|
||||||
-- World.
|
-- World.
|
||||||
function tiny.activate(world, ...)
|
function tiny.activate(world, system)
|
||||||
local args = {...}
|
world.systems[world.systemIndices[system]].active = true
|
||||||
for _, system in ipairs(args) do
|
|
||||||
world.systems[world.systemIndices[system]].active = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Deactivates Systems in the World.
|
--- Deactivates a System in the World.
|
||||||
-- Deactivated Systems must be update manually, and will not update when the
|
-- Deactivated Systems must be update manually, and will not update when the
|
||||||
-- rest of World updates. They will, however, process new Entities added while
|
-- rest of World updates. They will, however, process new Entities added while
|
||||||
-- the System is deactivated.
|
-- the System is deactivated.
|
||||||
-- @param world
|
-- @param world
|
||||||
-- @param ... Systems to deactivate. The Systems must already be added to the
|
-- @param system System to deactivate. The System must already be added to the
|
||||||
-- World.
|
-- World.
|
||||||
function tiny.deactivate(world, ...)
|
function tiny.deactivate(world, system)
|
||||||
local args = {...}
|
world.systems[world.systemIndices[system]].active = false
|
||||||
for _, system in ipairs(args) do
|
|
||||||
world.systems[world.systemIndices[system]].active = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return tiny
|
return tiny
|
||||||
|
|||||||
Reference in New Issue
Block a user