| Package | com.pblabs.engine.entity |
| Interface | public interface IEntity extends IPropertyBag, IPBObject |
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 | ||
|---|---|---|---|
![]() | alias : 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 | ||
![]() | eventDispatcher : IEventDispatcher [read-only]
The event dispatcher that controls events for this entity. | IPropertyBag | |
![]() | name : String [read-only]
The name of the PBObject. | IPBObject | |
![]() | owningGroup : PBGroup
The PBGroup which owns this PBObject. | IPBObject | |
| Method | Defined 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 | ||
![]() | destroy():void
Destroys the PBObject by removing all components and unregistering it from
the name manager. | IPBObject | |
![]() | doesPropertyExist(property:PropertyReference):Boolean
Checks whether a property exists on this entity. | IPropertyBag | |
![]() | getProperty(property:PropertyReference, defaultValue:* = null):*
Gets the value of a property on this entity. | IPropertyBag | |
![]() | initialize(name:String = null, alias:String = null):void
initializes the PBObject, optionally assigning it a name. | IPBObject | |
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 | |
| deferring | property |
deferring:BooleanWhen true, onAdd/onRemove callbacks are deferred. When set to false, any pending callbacks are processed.
public function get deferring():Boolean public function set deferring(value:Boolean):void| addComponent | () | method |
public function addComponent(component:IEntityComponent, componentName:String):BooleanAdds 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.
|
Boolean |
| deserialize | () | method |
public function deserialize(xml:XML, registerComponents:Boolean = true):voidSets 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):IEntityComponentGets 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.
|
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.
|
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.
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.
|
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).
Parameters
component: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.
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.
|