class ECS::Filter
- ECS::Filter
- Reference
- Object
Overview
Allows to iterate over entities with specified conditions.
Created by call world.new_filter
or just by adding any conditions to world
.
Following conditions are possible:
- entity must have ALL listed components:
filter.all_of([Comp1, Comp2])
,filter.of(Comp1)
- entity must have AT LEAST ONE of listed components:
filter.any_of([Comp1, Comp2])
- entity must have NONE of listed components:
filter.exclude([Comp1, Comp2])
,filter.exclude(Comp1)
- specified Proc must return true when called on entity:
filter.select { |ent| ent.getComp1.size > 1 }
conditions can be specified in any order, multiple conditions of same type are allowed
Included Modules
Defined in:
myecs.crInstance Method Summary
-
#all_of(list)
Adds a condition that entity must have ALL listed components.
-
#any_of(list)
Adds a condition that entity must have AT LEAST ONE of specified components.
-
#each(& : Entity -> )
Calls a block once for each entity that match the filter.
-
#exclude(item : ComponentType)
Adds a condition that entity must not have specified component.
-
#exclude(list)
Adds a condition that entity must have NONE of listed components.
-
#filter(&block : Entity -> Bool)
Adds a condition that specified Proc must return true when called on entity.
-
#of(item : ComponentType)
Adds a condition that entity must have specified component.
-
#satisfy(entity : Entity) : Bool
Returns true if entity satisfy the filter
Instance methods inherited from module ECS::AbstractFilter
satisfy(entity : Entity) : Bool
satisfy
Instance Method Detail
Adds a condition that entity must have ALL listed components.
Example: filter.all_of([Comp1, Comp2])
Adds a condition that entity must have AT LEAST ONE of specified components.
Example: filter.any_of([Comp1, Comp2])
Calls a block once for each entity that match the filter.
Note that for Multiple
same entity can be called multiple times, once for each component present on entity
Adds a condition that entity must not have specified component.
Example: filter.exclude(Comp1)
Adds a condition that entity must have NONE of listed components.
Example: filter.exclude([Comp1, Comp2])
Adds a condition that specified Proc must return true when called on entity.
Example: filter.select { |ent| ent.getComp1.size > 1 }
Adds a condition that entity must have specified component.
Example: filter.of(Comp1)