class ECS::World

Overview

Root level container for all entities / components, is iterated with ECS::Systems

Defined in:

myecs.cr
yaml.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

[View source]
def self.new #

Creates empty world


[View source]

Class Method Detail

def self.from_yaml(&) #

[View source]

Instance Method Detail

def add_yaml(io_or_string) #

[View source]
def add_yaml(&) #

[View source]
def all_of(*args, **options) #

Creates new Filter and adds a condition to it


[View source]
def all_of(*args, **options, &) #

Creates new Filter and adds a condition to it


[View source]
def any_of(*args, **options) #

Creates new Filter and adds a condition to it


[View source]
def any_of(*args, **options, &) #

Creates new Filter and adds a condition to it


[View source]
def component_exists?(typ) #

Returns true if at least one component of type typ exists in a world


[View source]
def decode(io) #

[View source]
def delete_all(with_callbacks = false) #

Deletes all components and entities from the world


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

Iterates over all entities


[View source]
def encode(io) #

[View source]
def entities_capacity #

number of entities that could exist in a world before reallocation of pools


[View source]
def entities_count #

total number of alive entities in a world


[View source]
def exclude(*args, **options) #

Creates new Filter and adds a condition to it


[View source]
def exclude(*args, **options, &) #

Creates new Filter and adds a condition to it


[View source]
def inspect(io) #

[View source]
def new_entity #

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.


[View source]
def new_filter #

Creates new Filter. This call can be skipped: Instead of world.new_filter.of(Comp1) you can do world.of(Comp1)


[View source]
def of(*args, **options) #

Creates new Filter and adds a condition to it


[View source]
def of(*args, **options, &) #

Creates new Filter and adds a condition to it


[View source]
def query(typ) #

Returns SimpleFilter (stack-allocated) that can iterate over single component


[View source]
def stats(& : String, Int32 -> ) #

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

[View source]
def 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}

[View source]
def to_yaml(yaml : YAML::Nodes::Builder) : Nil #

[View source]