| Package | PBLabs.Engine.Entity |
| Interface | public interface IEntity extends IPropertyBag |
| Implementors | EntityComponent |
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
| Property | Defined by | ||
|---|---|---|---|
![]() | EventDispatcher : IEventDispatcher
The event dispatcher that controls events for this entity.
| IPropertyBag | |
| Name : String [read-only]
The name of the entity.
| IEntity | ||
| Method | Defined by | ||
|---|---|---|---|
|
AddComponent(component:IEntityComponent, componentName:String):void
Adds a component to the entity.
| IEntity | ||
|
Deserialize(xml:XML, registerComponents:Boolean = true):void
Sets up this entity from an xml description.
| IEntity | ||
|
Destroy():void
Destroys the entity by removing all components and unregistering it from
the name manager.
| IEntity | ||
![]() |
DoesPropertyExist(property:PropertyReference):Boolean
Checks whether a property exists on this entity.
| IPropertyBag | |
![]() |
GetProperty(property:PropertyReference):*
Gets the value of a property on this entity.
| IPropertyBag | |
|
Initialize(name:String, alias:String = null):void
Initializes the entity, optionally assigning it a name.
| IEntity | ||
|
LookupComponentByName(componentName:String):IEntityComponent
Gets a component that was registered with a specific name on this entity.
| IEntity | ||
|
LookupComponentByType(componentType:Class):IEntityComponent
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 | ||
|
RemoveComponent(component:IEntityComponent):void
Removes a component from the entity.
| IEntity | ||
|
Serialize(xml:XML):void
Creates an XML description of this entity, including all currently attached
components.
| IEntity | ||
![]() |
SetProperty(property:PropertyReference, value:*):void
Sets the value of a property on this entity.
| IPropertyBag | |
| Name | property |
Name:String [read-only]The name of the entity. This is set by passing a name to the Initialize method after the entity is first created.
Implementation public function get Name():String
See also
| AddComponent | () | method |
public function AddComponent(component:IEntityComponent, componentName:String):voidAdds 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).
Parameterscomponent: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.
|
| Deserialize | () | method |
public function Deserialize(xml:XML, registerComponents:Boolean = true):voidSets up this entity from an xml description.
Parametersxml: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.
|
See also
| Destroy | () | method |
public function Destroy():voidDestroys the entity by removing all components and unregistering it from the name manager.
Currently this will not invalidate external references to the entity so the entity will only be cleaned up by the garbage collector if those are set to null manually.
| Initialize | () | method |
public function Initialize(name:String, alias:String = null):voidInitializes the entity, optionally assigning it a name. This should be called immediately after the entity is created.
Parametersname:String — The name to assign to the entity. If this is null or an empty
string, the entity will not register itself with the name manager.
|
|
alias:String (default = null) — An alternate name under which this entity can be looked up.
Useful when you need to distinguish between multiple things but refer
to the active one by a consistent name.
|
See also
| LookupComponentByName | () | method |
public function LookupComponentByName(componentName:String):IEntityComponentGets a component that was registered with a specific name on this entity.
ParameterscomponentName:String — The name of the component to retrieve. This corresponds
to the second parameter passed to AddComponent.
|
IEntityComponent —
The component with the specified name.
|
See also
| LookupComponentByType | () | method |
public function LookupComponentByType(componentType:Class):IEntityComponentGets 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.
ParameterscomponentType:Class — The type of the component to retrieve.
|
IEntityComponent —
The component, or null if none of the specified type were found.
|
See also
| LookupComponentsByType | () | method |
public function LookupComponentsByType(componentType:Class):ArrayGets a list of all the components of a specific type that are on this entity.
ParameterscomponentType:Class — The type of components to retrieve.
|
Array — An array containing all the components of the specified type on
this entity.
|
| RemoveComponent | () | method |
public function RemoveComponent(component:IEntityComponent):voidRemoves 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).
Parameterscomponent:IEntityComponent — The component to remove.
|
| Serialize | () | method |
public function Serialize(xml:XML):voidCreates an XML description of this entity, including all currently attached components.
This is not implemented yet.
Parametersxml: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.
|
See also