mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2026-07-21 23:56:50 -06:00
Remove pesky trailing whitespace >:(
This commit is contained in:
@@ -65,12 +65,12 @@ end
|
|||||||
Copy paste tiny.lua into your source folder.
|
Copy paste tiny.lua into your source folder.
|
||||||
|
|
||||||
## Luarocks ##
|
## Luarocks ##
|
||||||
Tiny-ecs is also on [Luarocks](https://luarocks.org/) and can be installed with
|
Tiny-ecs is also on [Luarocks](https://luarocks.org/) and can be installed with
|
||||||
`luarocks install tiny-ecs`.
|
`luarocks install tiny-ecs`.
|
||||||
|
|
||||||
## Demo ##
|
## Demo ##
|
||||||
Check out the [demo](https://github.com/bakpakin/tiny-ecs/tree/demo-commandokibbles), a game
|
Check out the [demo](https://github.com/bakpakin/tiny-ecs/tree/demo-commandokibbles), a game
|
||||||
originally written for Ludum Dare 32 with the theme 'An Unconventional Weapon'. The demo uses
|
originally written for Ludum Dare 32 with the theme 'An Unconventional Weapon'. The demo uses
|
||||||
[LOVE](https://love2d.org/), an amazing game framework for lua.
|
[LOVE](https://love2d.org/), an amazing game framework for lua.
|
||||||
|
|
||||||
## Testing ##
|
## Testing ##
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ build = {
|
|||||||
modules = {
|
modules = {
|
||||||
tiny = "tiny.lua"
|
tiny = "tiny.lua"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -99,7 +99,7 @@ describe('tiny-ecs:', function()
|
|||||||
local oneTimeSystem = tiny.system()
|
local oneTimeSystem = tiny.system()
|
||||||
function oneTimeSystem:update(entities, dt)
|
function oneTimeSystem:update(entities, dt)
|
||||||
timePassed = timePassed + dt
|
timePassed = timePassed + dt
|
||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
entity1 = deep_copy(entityTemplate1)
|
entity1 = deep_copy(entityTemplate1)
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ local function isSystem(table)
|
|||||||
return table[systemTableKey]
|
return table[systemTableKey]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a System. Systems are tables that contain at least one field;
|
--- Creates a System. Systems are tables that contain at least one field;
|
||||||
-- an update function that takes parameters like so:
|
-- an update function that takes parameters like so:
|
||||||
-- `function system:update(entities, dt)`. `entities` is an unordered table of
|
-- `function system:update(entities, dt)`. `entities` is an unordered table of
|
||||||
-- Entities with Entities as KEYS, and `dt` is the delta time. There are also a
|
-- Entities with Entities as KEYS, and `dt` is the delta time. There are also a
|
||||||
-- few other optional callbacks:
|
-- few other optional callbacks:
|
||||||
-- `function system:filter(entity)` - returns a boolean,
|
-- `function system:filter(entity)` - returns a boolean,
|
||||||
-- `function system:onAdd(entity)` - returns nil,
|
-- `function system:onAdd(entity)` - returns nil,
|
||||||
@@ -124,11 +124,11 @@ local function processingSystemUpdate(system, entities, dt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Creates a Processing System. A Processing System iterates through its
|
--- Creates a Processing System. A Processing System iterates through its
|
||||||
-- Entities in no particluar order, and updates them individually. It has two
|
-- Entities in no particluar order, and updates them individually. It has two
|
||||||
-- important fields, `function system:process(entity, dt)`, and `function
|
-- important fields, `function system:process(entity, dt)`, and `function
|
||||||
-- system:filter(entity)`. `entities` is Entities,
|
-- system:filter(entity)`. `entities` is Entities,
|
||||||
-- and `dt` is the delta time. There are also a few other
|
-- and `dt` is the delta time. There are also a few other
|
||||||
-- optional callbacks:
|
-- optional callbacks:
|
||||||
-- `function system:preProcess(entities, dt)` - returns nil,
|
-- `function system:preProcess(entities, dt)` - returns nil,
|
||||||
-- `function system:postProcess(entities, dt)` - returns nil,
|
-- `function system:postProcess(entities, dt)` - returns nil,
|
||||||
@@ -136,7 +136,7 @@ end
|
|||||||
-- `function system:onRemove(entity)` - returns nil.
|
-- `function system:onRemove(entity)` - returns nil.
|
||||||
-- For Filters, it is conveient to use `tiny.requireAll` or `tiny.requireOne`,
|
-- For Filters, it is conveient to use `tiny.requireAll` or `tiny.requireOne`,
|
||||||
-- but one can write their own filters as well.
|
-- but one can write their own filters as well.
|
||||||
-- @param table A table to be used as a System, or `nil` to create a new
|
-- @param table A table to be used as a System, or `nil` to create a new
|
||||||
-- Processing System.
|
-- Processing System.
|
||||||
function tiny.processingSystem(table)
|
function tiny.processingSystem(table)
|
||||||
if table == nil then
|
if table == nil then
|
||||||
@@ -176,7 +176,7 @@ function tiny.world(...)
|
|||||||
-- List of Entities to remove
|
-- List of Entities to remove
|
||||||
systemsToRemove = {},
|
systemsToRemove = {},
|
||||||
|
|
||||||
-- Set of Entities
|
-- Set of Entities
|
||||||
entities = {},
|
entities = {},
|
||||||
|
|
||||||
-- Number of Entities in World.
|
-- Number of Entities in World.
|
||||||
@@ -200,7 +200,7 @@ end
|
|||||||
|
|
||||||
--- Adds an Entity to the world.
|
--- Adds an Entity to the world.
|
||||||
-- The new Entity will enter the world next time World:update is called.
|
-- The new Entity will enter the world next time World:update is called.
|
||||||
-- Also call this on Entities that have changed Components such that it
|
-- Also call this on Entities that have changed Components such that it
|
||||||
-- matches different systems.
|
-- matches different systems.
|
||||||
-- @param world
|
-- @param world
|
||||||
-- @param entity
|
-- @param entity
|
||||||
@@ -243,7 +243,7 @@ tiny_add = tiny.add
|
|||||||
|
|
||||||
--- Removes an Entity to the World.
|
--- Removes an Entity to the World.
|
||||||
-- The Entity will exit the World next time World:update is called.
|
-- The Entity will exit the World next time World:update is called.
|
||||||
-- Also call this on Entities that have changed Components such that it
|
-- Also call this on Entities that have changed Components such that it
|
||||||
-- matches different systems.
|
-- matches different systems.
|
||||||
-- @param world
|
-- @param world
|
||||||
-- @param entity
|
-- @param entity
|
||||||
@@ -263,7 +263,7 @@ function tiny.removeSystem(world, system)
|
|||||||
end
|
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.
|
||||||
-- Objects will exit the World the next time World:update(dt) is called.
|
-- Objects will exit the World the next time World:update(dt) is called.
|
||||||
-- @param world
|
-- @param world
|
||||||
-- @param ... Systems and Entities
|
-- @param ... Systems and Entities
|
||||||
@@ -514,7 +514,7 @@ function tiny.getSystemIndex(world, system)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Sets the index of a System in the world. Changes the order in
|
--- Sets the index of a System in the world. Changes the order in
|
||||||
-- which they Systems processed, because lower indexed Systems are processed
|
-- which they Systems processed, because lower indexed Systems are processed
|
||||||
-- first.
|
-- first.
|
||||||
-- @param world
|
-- @param world
|
||||||
-- @param system
|
-- @param system
|
||||||
|
|||||||
Reference in New Issue
Block a user