mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2024-11-17 04:44:23 +00:00
Readd tiny.processingSystem(table).
This commit is contained in:
parent
c66ed98a5a
commit
61ffd2551b
21
tiny.lua
21
tiny.lua
@ -334,6 +334,16 @@ function tiny.system(table, attributes)
|
|||||||
return table
|
return table
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Creates a new Processing System or Processing System class. Shortcut for
|
||||||
|
-- `tiny.system(table, { "process" })`.
|
||||||
|
-- @see system
|
||||||
|
function tiny.processingSystem(table)
|
||||||
|
table = table or {}
|
||||||
|
table[systemTableKey] = true
|
||||||
|
table.update = processingSystemUpdate
|
||||||
|
return table
|
||||||
|
end
|
||||||
|
|
||||||
--- Get number of Entities in the System.
|
--- Get number of Entities in the System.
|
||||||
function tiny.getSystemEntityCount(system)
|
function tiny.getSystemEntityCount(system)
|
||||||
return #(system.entities)
|
return #(system.entities)
|
||||||
@ -354,7 +364,6 @@ local worldMetaTable
|
|||||||
--- Creates a new World.
|
--- Creates a new World.
|
||||||
-- Can optionally add default Systems and Entities.
|
-- Can optionally add default Systems and Entities.
|
||||||
function tiny.world(...)
|
function tiny.world(...)
|
||||||
|
|
||||||
local ret = {
|
local ret = {
|
||||||
|
|
||||||
-- List of Entities to add
|
-- List of Entities to add
|
||||||
@ -388,7 +397,6 @@ function tiny.world(...)
|
|||||||
tiny_manageEntities(ret)
|
tiny_manageEntities(ret)
|
||||||
|
|
||||||
return setmetatable(ret, worldMetaTable)
|
return setmetatable(ret, worldMetaTable)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds an Entity to the world.
|
--- Adds an Entity to the world.
|
||||||
@ -411,8 +419,6 @@ end
|
|||||||
tiny_addSystem = tiny.addSystem
|
tiny_addSystem = tiny.addSystem
|
||||||
|
|
||||||
--- Shortcut for adding multiple Entities and Systems to the World.
|
--- Shortcut for adding multiple Entities and Systems to the World.
|
||||||
-- @see addEntity
|
|
||||||
-- @see addSystem
|
|
||||||
function tiny.add(world, ...)
|
function tiny.add(world, ...)
|
||||||
local obj
|
local obj
|
||||||
for i = 1, select("#", ...) do
|
for i = 1, select("#", ...) do
|
||||||
@ -443,8 +449,6 @@ end
|
|||||||
tiny_removeSystem = tiny.removeSystem
|
tiny_removeSystem = tiny.removeSystem
|
||||||
|
|
||||||
--- Shortcut for removing multiple Entities and Systems from the World.
|
--- Shortcut for removing multiple Entities and Systems from the World.
|
||||||
-- @see removeEntity
|
|
||||||
-- @see removeSystem
|
|
||||||
function tiny.remove(world, ...)
|
function tiny.remove(world, ...)
|
||||||
local obj
|
local obj
|
||||||
for i = 1, select("#", ...) do
|
for i = 1, select("#", ...) do
|
||||||
@ -462,7 +466,6 @@ tiny_remove = tiny.remove
|
|||||||
|
|
||||||
-- Adds and removes Systems that have been marked from the World.
|
-- Adds and removes Systems that have been marked from the World.
|
||||||
function tiny_manageSystems(world)
|
function tiny_manageSystems(world)
|
||||||
|
|
||||||
local s2a, s2r = world.systemsToAdd, world.systemsToRemove
|
local s2a, s2r = world.systemsToAdd, world.systemsToRemove
|
||||||
|
|
||||||
-- Early exit
|
-- Early exit
|
||||||
@ -531,12 +534,10 @@ function tiny_manageSystems(world)
|
|||||||
end
|
end
|
||||||
s2a[i] = nil
|
s2a[i] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Adds and removes Entities that have been marked.
|
-- Adds and removes Entities that have been marked.
|
||||||
function tiny_manageEntities(world)
|
function tiny_manageEntities(world)
|
||||||
|
|
||||||
local e2a, e2r = world.entitiesToAdd, world.entitiesToRemove
|
local e2a, e2r = world.entitiesToAdd, world.entitiesToRemove
|
||||||
|
|
||||||
-- Early exit
|
-- Early exit
|
||||||
@ -582,7 +583,6 @@ function tiny_manageEntities(world)
|
|||||||
e2r[i] = nil
|
e2r[i] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Add Entities
|
-- Add Entities
|
||||||
for i = 1, #e2a do
|
for i = 1, #e2a do
|
||||||
entity = e2a[i]
|
entity = e2a[i]
|
||||||
@ -614,7 +614,6 @@ function tiny_manageEntities(world)
|
|||||||
|
|
||||||
-- Update Entity count
|
-- Update Entity count
|
||||||
world.entityCount = entityCount
|
world.entityCount = entityCount
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Updates the World by dt (delta time). Takes an optional parameter, `filter`,
|
--- Updates the World by dt (delta time). Takes an optional parameter, `filter`,
|
||||||
|
Loading…
Reference in New Issue
Block a user