From 35d3e7a9c10bca8dfb0e8118d7328eab9728f3e1 Mon Sep 17 00:00:00 2001
From: bakpakin For Filters, it is convenient to use For Filters, it is convenient to use tiny.requireAll or tiny.requireAny,
but one can write their own filters as well. Set the Filter of a System like
so: orfunction system:preWrap(dt) - Called on each system before update is
called on any system.function system:postWrap(dt) - Called on each system in reverse order
- after update is called on each system. The idea behind preWrap and
- postWrap is to allow for systems that modify the behavior of other systems.
+ tiny.requireAllfunction system:postWrap(dt) - Called on each system in reverse order
+ after update is called on each system. The idea behind preWrap and
+ postWrap is to allow for systems that modify the behavior of other systems.
Say there is a DrawingSystem, which draws sprites to the screen, and a
PostProcessingSystem, that adds some blur and bloom effects. In the preWrap
method of the PostProcessingSystem, the System could set the drawing target
@@ -350,10 +350,10 @@ filter = tiny.requireAll("image", tiny.rejectAny("Player", "Enemy"))
be accomplished with a single custom update function in the DrawingSystem). or tiny.requireAny,
+system.filter = tiny.requireAll("a", "b", "c")
+system.filter = tiny.requireAll("a", "b", "c")
function system:filter(entity)
@@ -366,33 +366,33 @@ end
commonly used.
field points to the World that the System belongs to. Useful
+ - The world field points to the World that the System belongs to. Useful
for adding and removing Entities from the world dynamically via the System.
- - The
active flag is whether or not the System is updated automatically.
+ - The
active flag is whether or not the System is updated automatically.
Inactive Systems should be updated manually or not at all via
- system:update(dt). Defaults to true. field is an ordered list of Entities in the System. This
+ system:update(dt). Defaults to true.entities field is an ordered list of Entities in the System. This
list can be used to quickly iterate through all Entities in a System. field is an optional field that makes Systems update at
+ - The
interval field is an optional field that makes Systems update at
certain intervals using buffered time, regardless of World update frequency.
- For example, to make a System update once a second, set the System's interval
+ For example, to make a System update once a second, set the System's interval
to 1.
- - The
index field is the System's index in the World. Lower indexed
- Systems are processed before higher indices. The index is a read only
- field; to set the index, use tiny.setSystemIndex(world, system). field is a table of Entity keys to their indices in the
- entities list. Most Systems can ignore this. flag is an indicator if the System has been modified in
- the last update. If so, the onModify callback will be called on the System
+ - The
index field is the System's index in the World. Lower indexed
+ Systems are processed before higher indices. The index is a read only
+ field; to set the index, use tiny.setSystemIndex(world, system).
+ - The
indices field is a table of Entity keys to their indices in the
+ entities list. Most Systems can ignore this.
+ - The
modified flag is an indicator if the System has been modified in
+ the last update. If so, the onModify callback will be called on the System
in the next update, if it has one. This is usually managed by tiny-ecs, so
users should mostly ignore this, too.
There is another option to (hopefully) increase performance in systems that
have items added to or removed from them often, and have lots of entities in
- them. Setting the nocache' field of the system might improve performance.
+ them. Setting the nocache' field of the system might improve performance.
It is still experimental. There are some restriction to systems without
- caching, however. * There is no entities` table. * Callbacks such onAdd,
onRemove, and onModify will never be called * Noncached systems cannot be
sorted (There is no entities list to sort).
@@ -714,7 +714,7 @@ end
entities table. * Callbacks such onAdd,
+ caching, however. * There is no