PackagePBLabs.Engine.Entity
Classpublic class EntityComponent
ImplementsIEntityComponent
SubclassesAnimatedComponent, BaseRenderComponent, BaseSceneComponent, BasicSpatialManager2D, Box2DManagerComponent, Box2DSpatialComponent, DataComponent, GroupManagerComponent, GroupMemberComponent, MultiSpriteSheetHelper, SpriteSheetComponent, TickedComponent

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
Creating Custom Components
Component System Overview


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
[read-only] 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  [read-only]

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 equivelent to the first parameter passed to the Register method.

Implementation
    public function get Owner():IEntity
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 entity class 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.