class ECS::System

Overview

Сontainer for logic for processing filtered entities. User systems should inherit from ECS::System and implement #init, #execute, #teardown, #filter, #preprocess and #process (in any combination. Just skip methods you don't need).

Direct Known Subclasses

Defined in:

myecs.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(world : ECS::World) #

Constructor. Called before #init


[View source]

Instance Method Detail

def active : Bool #

Set #active property to false to temporarily disable system


[View source]
def active=(active : Bool) #

Set #active property to false to temporarily disable system


[View source]
def execute #

Will be called on each ECS::Systems.execute call


[View source]
def filter(world : World) : Filter | Nil #

Called once during ECS::Systems.init, after #init call. If this method is present, it should return a filter that will be applied to a world It can also return nil that means that no filter is present and #process won't be called Example:

def filter(world : World)
  world.of(Component1)
end

[View source]
def init #

Will be called once during ECS::Systems.init call


[View source]
def preprocess #

Will be called on each ECS::Systems.execute call, before #process and #execute


[View source]
def process(entity : Entity) #

Called during each ECS::Systems.execute call, before #execute, for each entity that match the #filter


[View source]
def teardown #

Will be called once during ECS::Systems.teardown call


[View source]