class Crash::Entity

Included Modules

Defined in:

crash/entity.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String) #

[View source]
def self.new #

[View source]

Instance Method Detail

def add(component : Crash::Component, component_class : Crash::Component.class) #

Add a component to the entity.

@param component The component object to add. @param componentClass The class of the component. This is only necessary if the component extends another component class and you want the framework to treat the component as of the base class type. If not set, the class type is determined directly from the component.

@return A reference to the entity. This enables the chaining of calls to add, to make creating and configuring entities cleaner. e.g.

var entity : Entity = new Entity() .add( new Position( 100, 200 ) .add( new Display( new PlayerClip() );


[View source]
def add(component : Crash::Component) #

[View source]
def get(component_class : Crash::Component.class) : Crash::Component | Nil #

Get a component from the entity.


[View source]
def get_all #

Get all components from the entity.


[View source]
def has(component_class : Crash::Component.class) : Bool #

Does the entity have a component of a particular type.

@param componentClass The class of the component sought. @return true if the entity has a component of the type, false if not.


[View source]
def name : String #

[View source]
def name=(name : String) #

[View source]
def remove(component_class : Crash::Component.class) #

[View source]