Packagecom.pblabs.engine.entity
Classpublic class EntityComponent
InheritanceEntityComponent Inheritance Object
Implements IEntityComponent
Subclasses AnimatedComponent, BasicSpatialManager2D, Box2DManagerComponent, Box2DSpatialComponent, DataComponent, EventSoundTrigger, GoogleSpreadsheetTweaker, GroupManagerComponent, GroupMemberComponent, HealthComponent, MachineDescription, MultiSpriteSheetHelper, SpriteContainerComponent, ThinkingComponent, TickedComponent, TweenComponent, TweenController

An implementation of the IEntityComponent interface, providing all the basic functionality required of all components. Custom components should always derive from this class rather than implementing IEntityComponent directly.

See also

IEntity


Public Properties
 PropertyDefined By
  isRegistered : Boolean
[read-only] Whether or not the component is currently registered with an entity.
EntityComponent
  name : String
[read-only] The name given to the component when it is added to an entity.
EntityComponent
  owner : IEntity
A reference to the entity that this component currently belongs to.
EntityComponent
Public Methods
 MethodDefined By
  
register(owner:IEntity, name:String):void
Registers the component with an entity.
EntityComponent
  
reset():void
This is called by an entity on all of its components any time a component is added or removed.
EntityComponent
  
unregister():void
Unregisters the component from an entity.
EntityComponent
Protected Methods
 MethodDefined By
  
onAdd():void
This is called when the component is added to an entity.
EntityComponent
  
onRemove():void
This is called when the component is removed from an entity.
EntityComponent
  
onReset():void
This is called anytime a component is added or removed from the owner entity.
EntityComponent
Property Detail
isRegisteredproperty
isRegistered:Boolean  [read-only]

Whether or not the component is currently registered with an entity.


Implementation
    public function get isRegistered():Boolean
nameproperty 
name:String  [read-only]

The name given to the component when it is added to an entity. This value should be equivelent to the second parameter passed to the register method.


Implementation
    public function get name():String
ownerproperty 
owner:IEntity

A reference to the entity that this component currently belongs to. If the component has not been added to an entity, this will be null.

This value should be equivalent to the first parameter passed to the register method.


Implementation
    public function get owner():IEntity
    public function set owner(value:IEntity):void
Method Detail
onAdd()method
protected function onAdd():void

This is called when the component is added to an entity. Any initialization, event registration, or object lookups should happen here. Component lookups on the owner entity should NOT happen here. Use onReset instead.

See also

onRemove()method 
protected function onRemove():void

This is called when the component is removed from an entity. It should reverse anything that happened in onAdd or onReset (like removing event listeners or nulling object references).

onReset()method 
protected function onReset():void

This is called anytime a component is added or removed from the owner entity. Lookups of other components on the owner entity should happen here.

This can potentially be called multiple times, so make sure previous lookups are properly cleaned up each time.

register()method 
public function register(owner:IEntity, name:String):void

Registers the component with an entity. This should only ever be called by an IEntity from the addComponent method.

Parameters

owner:IEntity — The entity to register the component with.
 
name:String — The name to assign to the component.

reset()method 
public function reset():void

This is called by an entity on all of its components any time a component is added or removed. In this method, any references to properties on the owner entity should be purged and re-looked up.

unregister()method 
public function unregister():void

Unregisters the component from an entity. This should only ever be called by an entity class from the removeComponent method.