Packagecitrus.system
Classpublic class Entity
InheritanceEntity Inheritance CitrusObject Inheritance Object
Subclasses CitrusGroup

A game entity is compound by components. The entity serves as a link to communicate between components. It extends the CitrusObject class to enjoy its params setter.



Public Properties
 PropertyDefined By
  components : Vector.<Component>
[read-only]
Entity
 InheritedhideParamWarnings : Boolean = false
[static]
CitrusObject
 InheritedID : uint
[read-only]
CitrusObject
 Inheritedkill : Boolean = false
Set it to true if you want to remove, clean and destroy the object.
CitrusObject
 Inheritedname : String
A name to identify easily an objet.
CitrusObject
 Inheritedtype : String = classicObject
Added to the CE's render list via the State and the add method.
CitrusObject
 InheritedupdateCallEnabled : Boolean = false
This property prevent the update method to be called by the enter frame, it will save performances.
CitrusObject
Protected Properties
 PropertyDefined By
 Inherited_ce : CitrusEngine
CitrusObject
  _components : Vector.<Component>
Entity
 Inherited_initialized : Boolean = false
CitrusObject
 Inherited_params : Object
CitrusObject
 Inherited_timeDelta : Number
The time elasped between two update call.
CitrusObject
Public Methods
 MethodDefined By
  
Entity(name:String, params:Object = null)
Entity
  
add(component:Component):Entity
Add a component to the entity.
Entity
  
destroy():void
[override] Destroy the entity and its components.
Entity
  
initialize(poolObjectParams:Object = null):void
[override] After all the components have been added call this function to perform an init on them.
Entity
  
Search and return a component using its name
Entity
  
lookupComponentByType(componentType:Class):Component
Search and return first componentType's instance found in components
Entity
  
lookupComponentsByType(componentType:Class):Vector.<Component>
Search and return all componentType's instance found in components
Entity
  
remove(component:Component):void
Remove a component from the entity.
Entity
 Inherited
setParams(object:Object, params:Object):void
The initialize method usually calls this.
CitrusObject
 Inherited
toString():String
CitrusObject
  
update(timeDelta:Number):void
[override] Perform an update on all entity's components.
Entity
Protected Methods
 MethodDefined By
  
doAddComponent(component:Component):Boolean
Entity
Property Detail
_componentsproperty
protected var _components:Vector.<Component>

componentsproperty 
components:Vector.<Component>  [read-only]


Implementation
    public function get components():Vector.<Component>
Constructor Detail
Entity()Constructor
public function Entity(name:String, params:Object = null)



Parameters
name:String
 
params:Object (default = null)
Method Detail
add()method
public function add(component:Component):Entity

Add a component to the entity.

Parameters

component:Component

Returns
Entity
destroy()method 
override public function destroy():void

Destroy the entity and its components. Components destruction will be perform according order in which components has been add to entity

doAddComponent()method 
protected function doAddComponent(component:Component):Boolean

Parameters

component:Component

Returns
Boolean
initialize()method 
override public function initialize(poolObjectParams:Object = null):void

After all the components have been added call this function to perform an init on them. Mostly used if you want to access to other components through the entity. Components initialization will be perform according order in which components has been add to entity

Parameters

poolObjectParams:Object (default = null)

lookupComponentByName()method 
public function lookupComponentByName(name:String):Component

Search and return a component using its name

Parameters

name:String — Component's name we're looking for

Returns
Component — Component
lookupComponentByType()method 
public function lookupComponentByType(componentType:Class):Component

Search and return first componentType's instance found in components

Parameters

componentType:Class — Component instance class we're looking for

Returns
Component — Component
lookupComponentsByType()method 
public function lookupComponentsByType(componentType:Class):Vector.<Component>

Search and return all componentType's instance found in components

Parameters

componentType:Class — Component instance class we're looking for

Returns
Vector.<Component>
remove()method 
public function remove(component:Component):void

Remove a component from the entity.

Parameters

component:Component

update()method 
override public function update(timeDelta:Number):void

Perform an update on all entity's components. Components update will be perform according order in which components has been add to entity

Parameters

timeDelta:Number