Packagecom.pblabs.engine.entity
Interfacepublic interface IEntity extends IPropertyBag, IPBObject

Game objects in PBE are referred to as entities. This interface defines the behavior for an entity. A full featured implementation of this interface is included, but is hidden so as to force using IEntity when storing references to entities. To create a new entity, use allocateEntity.

An entity by itself is a very light weight object. All it needs to store is its name and a list of components. Custom functionality is added by creating components and attaching them to entities.

An event with type "EntityDestroyed" will be fired when the entity is destroyed via the Destroy() method. This event is fired before any cleanup is done.

See also

IEntityComponent
com.pblabs.engine.entity.allocateEntity()


Public Properties
 PropertyDefined By
 Inheritedalias : String
[read-only] Since the PBE level format references template definitions by name, and that same name is used to name the entities created by the format, it is useful to be able to look things up by a common name.
IPBObject
  deferring : Boolean
When true, onAdd/onRemove callbacks are deferred.
IEntity
 InheritedeventDispatcher : IEventDispatcher
[read-only] The event dispatcher that controls events for this entity.
IPropertyBag
 Inheritedname : String
[read-only] The name of the PBObject.
IPBObject
 InheritedowningGroup : PBGroup
The PBGroup which owns this PBObject.
IPBObject
Public Methods
 MethodDefined By
  
addComponent(component:IEntityComponent, componentName:String):Boolean
Adds a component to the entity.
IEntity
  
deserialize(xml:XML, registerComponents:Boolean = true):void
Sets up this entity from an xml description.
IEntity
 Inherited
destroy():void
Destroys the PBObject by removing all components and unregistering it from the name manager.
IPBObject
 Inherited
Checks whether a property exists on this entity.
IPropertyBag
 Inherited
getProperty(property:PropertyReference, defaultValue:* = null):*
Gets the value of a property on this entity.
IPropertyBag
 Inherited
initialize(name:String = null, alias:String = null):void
initializes the PBObject, optionally assigning it a name.
IPBObject
  
Gets a component that was registered with a specific name on this entity.
IEntity
  
Gets a component of a specific type from this entity.
IEntity
  
lookupComponentsByType(componentType:Class):Array
Gets a list of all the components of a specific type that are on this entity.
IEntity
  
Removes a component from the entity.
IEntity
  
serialize(xml:XML):void
Creates an XML description of this entity, including all currently attached components.
IEntity
 Inherited
setProperty(property:PropertyReference, value:*):void
Sets the value of a property on this entity.
IPropertyBag
Property Detail
deferringproperty
deferring:Boolean

When true, onAdd/onRemove callbacks are deferred. When set to false, any pending callbacks are processed.


Implementation
    public function get deferring():Boolean
    public function set deferring(value:Boolean):void
Method Detail
addComponent()method
public function addComponent(component:IEntityComponent, componentName:String):Boolean

Adds a component to the entity.

When a component is added, it will have its register() method called (or onAdd if it is derived from EntityComponent). Also, reset() will be called on all components currently attached to the entity (or onReset if it is derived from EntityComponent).

Parameters

component:IEntityComponent — The component to add.
 
componentName:String — The name to set for the component. This is the value to use in lookupComponentByName to get a reference to the component. The name must be unique across all components on this entity.

Returns
Boolean
deserialize()method 
public function deserialize(xml:XML, registerComponents:Boolean = true):void

Sets up this entity from an xml description.

Parameters

xml:XML — The xml object describing the entity.
 
registerComponents:Boolean (default = true) — Set this to false to add components to the entity without registering them. This is used by the level manager to facilitate creating entities from templates.

lookupComponentByName()method 
public function lookupComponentByName(componentName:String):IEntityComponent

Gets a component that was registered with a specific name on this entity.

Parameters

componentName:String — The name of the component to retrieve. This corresponds to the second parameter passed to AddComponent.

Returns
IEntityComponent — The component with the specified name.

See also

lookupComponentByType()method 
public function lookupComponentByType(componentType:Class):IEntityComponent

Gets a component of a specific type from this entity. If more than one component of a specific type exists, there is no guarantee which one will be returned. To retrieve all components of a specified type, use lookupComponentsByType.

This check uses the is operator, so if you pass a parent type, subclasses will be considered to match, as will things implementing an interface you have passed.

Parameters

componentType:Class — The type of the component to retrieve.

Returns
IEntityComponent — The component, or null if none of the specified type were found.

See also

lookupComponentsByType()method 
public function lookupComponentsByType(componentType:Class):Array

Gets a list of all the components of a specific type that are on this entity.

This check uses the is operator, so if you pass a parent type, subclasses will be considered to match, as will things implementing an interface you have passed.

Parameters

componentType:Class — The type of components to retrieve.

Returns
Array — An array containing all the components of the specified type on this entity.
removeComponent()method 
public function removeComponent(component:IEntityComponent):void

Removes a component from the entity.

When a component is removed, it will have its Unregister method called (or onRemove if it is derived from EntityComponent). Also, Reset will be called on all components currently attached to the entity (or onReset if it is derived from EntityComponent).

Parameters

component:IEntityComponent — The component to remove.

serialize()method 
public function serialize(xml:XML):void

Creates an XML description of this entity, including all currently attached components.

This is not implemented yet.

Parameters

xml:XML — The xml object describing the entity. The parent tag should be included in this variable when the function is called, so only child tags need to be created.