class ECS::Filter

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:

Included Modules

Defined in:

myecs.cr

Instance Method Summary

Instance methods inherited from module ECS::AbstractFilter

count_entities count_entities, each_entity(& : Entity -> ) each_entity, find_entity? find_entity?, satisfy(entity : Entity) : Bool satisfy

Instance Method Detail

def all_of(list) #

Adds a condition that entity must have ALL listed components. Example: filter.all_of([Comp1, Comp2])


[View source]
def any_of(list) #

Adds a condition that entity must have AT LEAST ONE of specified components. Example: filter.any_of([Comp1, Comp2])


[View source]
def each_entity(& : Entity -> ) #

Calls a block once for each entity that match the filter. Note that for MultipleComponents same entity can be called multiple times, once for each component present on entity


[View source]
def exclude(item : ComponentType) #

Adds a condition that entity must not have specified component. Example: filter.exclude(Comp1)


[View source]
def exclude(list) #

Adds a condition that entity must have NONE of listed components. Example: filter.exclude([Comp1, Comp2])


[View source]
def of(item : ComponentType) #

Adds a condition that entity must have specified component. Example: filter.of(Comp1)


[View source]
def satisfy(entity : Entity) : Bool #

Returns true if entity satisfy the filter


[View source]
def select(&block : Entity -> Bool) #

Adds a condition that specified Proc must return true when called on entity. Example: filter.select { |ent| ent.getComp1.size > 1 }


[View source]