class ECS::World
- ECS::World
- Reference
- Object
Overview
Root level container for all entities / components, is iterated with ECS::Systems
Defined in:
myecs.cryaml.cr
Constructors
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
-
.new
Creates empty world
Class Method Summary
Instance Method Summary
- #add_yaml(io_or_string)
- #add_yaml(&)
-
#all_of(*args, **options)
Creates new
Filter
and adds a condition to it -
#all_of(*args, **options, &)
Creates new
Filter
and adds a condition to it -
#any_of(*args, **options)
Creates new
Filter
and adds a condition to it -
#any_of(*args, **options, &)
Creates new
Filter
and adds a condition to it -
#component_exists?(typ)
Returns true if at least one component of type
typ
exists in a world - #decode(io)
-
#delete_all(with_callbacks = false)
Deletes all components and entities from the world
-
#each_entity(& : Entity -> )
Iterates over all entities
- #encode(io)
-
#entities_capacity
number of entities that could exist in a world before reallocation of pools
-
#entities_count
total number of alive entities in a world
-
#exclude(*args, **options)
Creates new
Filter
and adds a condition to it -
#exclude(*args, **options, &)
Creates new
Filter
and adds a condition to it - #inspect(io)
-
#new_entity
Creates new entity in a world context.
-
#new_filter
Creates new Filter.
-
#of(*args, **options)
Creates new
Filter
and adds a condition to it -
#of(*args, **options, &)
Creates new
Filter
and adds a condition to it -
#query(typ)
Returns SimpleFilter (stack-allocated) that can iterate over single component
-
#stats(& : String, Int32 -> )
Non-allocating version of
#stats
. -
#stats
Returns Hash containing count of components
world = init_benchmark_world(1000000) puts world.stats # prints {"Comp1" => 500000, "Comp2" => 333334, "Comp3" => 200000, "Comp4" => 142858, "Config" => 1}
- #to_yaml(yaml : YAML::Nodes::Builder) : Nil
Constructor Detail
Class Method Detail
Instance Method Detail
Creates new entity in a world context. Basically doesn't cost anything as it just increase entities counter. Entity don't take up space without components.
Creates new Filter.
This call can be skipped:
Instead of world.new_filter.of(Comp1)
you can do world.of(Comp1)
Non-allocating version of #stats
. Yields component names and count of corresponding components
world = init_benchmark_world(1000000)
world.stats do |comp_name, value|
puts "#{comp_name}: #{value}"
end
Returns Hash containing count of components
world = init_benchmark_world(1000000)
puts world.stats # prints {"Comp1" => 500000, "Comp2" => 333334, "Comp3" => 200000, "Comp4" => 142858, "Config" => 1}