class Entitas::Collector(TEntity)
- Entitas::Collector(TEntity)
- Reference
- Object
Overview
A Collector can observe one or more groups from the same context and collects changed entities based on the specified groupEvent.
Included Modules
- Entitas::ICollector
- Enumerable(TEntity)
Defined in:
entitas.crentitas/collector.cr
Constant Summary
-
Log =
::Log.for(self)
Constructors
-
.new(group : Group(TEntity), group_event : Entitas::Events::GroupEvent)
Creates a Collector and will collect changed entities based on the specified group_event.
-
.new(groups : Array(Group(TEntity)), group_events : Array(Entitas::Events::GroupEvent))
Creates a Collector and will collect changed entities based on the specified group_events.
Instance Method Summary
-
#activate
Activates the Collector and will start collecting changed entities.
- #add_entity(event : Entitas::Events::OnEntityAdded) : Nil
- #add_entity(event : Entitas::Events::OnEntityRemoved) : Nil
- #add_entity(event : Entitas::Events::OnEntityUpdated) : Nil
-
#clear
Clears all collected entities
- #deactivate
-
#each(&)
Must yield this collection's elements to the block.
-
#empty?
Returns
true
ifself
is empty,false
otherwise. - #entities : Set(TEntity)
-
#size
Returns the total number of
TEntity
in thisCollector
- #to_json(json : JSON::Builder)
- #to_s(io)
Constructor Detail
Creates a Collector and will collect changed entities based on the specified group_event.
Creates a Collector and will collect changed entities based on the specified group_events.
Instance Method Detail
Activates the Collector and will start collecting changed entities. Collectors are activated by default.
Must yield this collection's elements to the block.
Returns true
if self
is empty, false
otherwise.
([] of Int32).empty? # => true
([1]).empty? # => false