mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2026-07-22 07:56:52 -06:00
Change names of tiny.requireOne and tiny.rejectOne to tiny.requireAny and tiny.rejectAny.
This commit is contained in:
+2
-2
@@ -56,10 +56,10 @@ describe('tiny-ecs:', function()
|
|||||||
local ftap = tiny.requireAll("spinalTap")
|
local ftap = tiny.requireAll("spinalTap")
|
||||||
local fvel = tiny.requireAll("vel")
|
local fvel = tiny.requireAll("vel")
|
||||||
local fxform = tiny.requireAll("xform")
|
local fxform = tiny.requireAll("xform")
|
||||||
local fall = tiny.requireOne("spinalTap", "onlyTen", "littleMan")
|
local fall = tiny.requireAny("spinalTap", "onlyTen", "littleMan")
|
||||||
|
|
||||||
-- Only select Entities without "spinalTap"
|
-- Only select Entities without "spinalTap"
|
||||||
local frtap = tiny.rejectOne("spinalTap")
|
local frtap = tiny.rejectAny("spinalTap")
|
||||||
|
|
||||||
-- Select Entities without all three: "spinalTap", "onlyTen", and
|
-- Select Entities without all three: "spinalTap", "onlyTen", and
|
||||||
-- "littleMan"
|
-- "littleMan"
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ local tiny_remove
|
|||||||
-- value indicating if the Entity should be processed by the System.
|
-- value indicating if the Entity should be processed by the System.
|
||||||
--
|
--
|
||||||
-- Filters must be added to Systems by setting the `filter` field of the System.
|
-- Filters must be added to Systems by setting the `filter` field of the System.
|
||||||
-- Filter's returned by `tiny.requireAll` and `tiny.requireOne` are immutable
|
-- Filter's returned by `tiny.requireAll` and `tiny.requireAny` are immutable
|
||||||
-- and can be used by multiple Systems.
|
-- and can be used by multiple Systems.
|
||||||
--
|
--
|
||||||
-- local f1 = tiny.requireAll("position", "velocity", "size")
|
-- local f1 = tiny.requireAll("position", "velocity", "size")
|
||||||
-- local f2 = tiny.requireOne("position", "velocity", "size")
|
-- local f2 = tiny.requireAny("position", "velocity", "size")
|
||||||
--
|
--
|
||||||
-- local e1 = {
|
-- local e1 = {
|
||||||
-- position = {2, 3},
|
-- position = {2, 3},
|
||||||
@@ -82,7 +82,7 @@ local tiny_remove
|
|||||||
--
|
--
|
||||||
-- -- Selects Entities with an "image" Component, but not Entities with a
|
-- -- Selects Entities with an "image" Component, but not Entities with a
|
||||||
-- -- "Player" or "Enemy" Component.
|
-- -- "Player" or "Enemy" Component.
|
||||||
-- filter = tiny.requireAll("image", tiny.rejectOne("Player", "Enemy"))
|
-- filter = tiny.requireAll("image", tiny.rejectAny("Player", "Enemy"))
|
||||||
--
|
--
|
||||||
-- @section Filter
|
-- @section Filter
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ end
|
|||||||
--- Makes a Filter that selects Entities with at least one of the specified
|
--- Makes a Filter that selects Entities with at least one of the specified
|
||||||
-- Components and Filters.
|
-- Components and Filters.
|
||||||
-- @param ... List of required Components and other Filters.
|
-- @param ... List of required Components and other Filters.
|
||||||
function tiny.requireOne(...)
|
function tiny.requireAny(...)
|
||||||
local components = {...}
|
local components = {...}
|
||||||
local len = #components
|
local len = #components
|
||||||
return function(system, e)
|
return function(system, e)
|
||||||
@@ -155,7 +155,7 @@ end
|
|||||||
--- Makes a Filter that rejects Entities with at least one of the specified
|
--- Makes a Filter that rejects Entities with at least one of the specified
|
||||||
-- Components and Filters, and selects all other Entities.
|
-- Components and Filters, and selects all other Entities.
|
||||||
-- @param ... List of required Components and other Filters.
|
-- @param ... List of required Components and other Filters.
|
||||||
function tiny.rejectOne(...)
|
function tiny.rejectAny(...)
|
||||||
local components = {...}
|
local components = {...}
|
||||||
local len = #components
|
local len = #components
|
||||||
return function(system, e)
|
return function(system, e)
|
||||||
@@ -199,7 +199,7 @@ end
|
|||||||
-- * `function system:onRemove(entity)`
|
-- * `function system:onRemove(entity)`
|
||||||
-- * `function system:onModify(dt)`
|
-- * `function system:onModify(dt)`
|
||||||
--
|
--
|
||||||
-- For Filters, it is conveient to use `tiny.requireAll` or `tiny.requireOne`,
|
-- For Filters, it is conveient to use `tiny.requireAll` or `tiny.requireAny`,
|
||||||
-- but one can write their own filters as well. Set the Filter of your System
|
-- but one can write their own filters as well. Set the Filter of your System
|
||||||
-- like so:
|
-- like so:
|
||||||
-- system.filter = tiny.requireAll("a", "b", "c")
|
-- system.filter = tiny.requireAll("a", "b", "c")
|
||||||
|
|||||||
Reference in New Issue
Block a user