Entity Class Reference

#include <Entity.h>

Inheritance diagram for Entity:
ListenerObject Container Particle Printer Actor Stage UIContainer ParticleSystem

# Public Member Functions

void constructor ()
 Class' constructor.
override bool handleMessage (Telegram telegram)
void clearComponentLists (uint32 componentType)
Component addComponent (const ComponentSpec *componentSpec)
void removeComponent (Component component)
void addComponents (ComponentSpec **componentSpecs, uint32 componentType)
void removeComponents (uint32 componentType)
Component getComponentAtIndex (uint32 componentType, int16 componentIndex)
VirtualList getComponents (uint32 componentType)
bool getComponentsOfClass (ClassPointer classPointer, VirtualList components, uint32 componentType)
uint16 getComponentsCount (uint32 componentType)
void resetComponents ()
 Reset components.
void setVisible ()
 Set this instance's visibility flag up.
const TransformationgetTransformation ()
const Vector3DgetPosition ()
const RotationgetRotation ()
const ScalegetScale ()
Body getBody ()
bool isMoving ()
void stopAllMovement ()
 Stop all entity's movement.
void stopMovement (uint16 axis)
bool setVelocity (const Vector3D *velocity, bool checkIfCanMove)
const Vector3DgetVelocity ()
fixed_t getSpeed ()
fixed_t getMaximumSpeed ()
fixed_t getBounciness ()
fixed_t getFrictionCoefficient ()
void enableCollisions ()
 Enable collision detection on the entity's colliders.
void disableCollisions ()
 Disable collision detection on the entity's colliders.
void checkCollisions (bool activate)
void registerCollisions (bool activate)
void setCollidersLayers (uint32 layers)
uint32 getCollidersLayers ()
void setCollidersLayersToIgnore (uint32 layersToIgnore)
uint32 getCollidersLayersToIgnore ()
bool hasColliders ()
void showColliders ()
 Make the entity's colliders visible.
void hideColliders ()
 Make the entity's colliders invisible.
virtual void createComponents (ComponentSpec **componentSpecs)
virtual void destroyComponents ()
 Destroy the components that attach to this container.
virtual void addedComponent (Component component)
virtual void removedComponent (Component component)
virtual void show ()
 Make this instance visible.
virtual void hide ()
 Make this instance invisible.
virtual void setTransparency (uint8 transparency)
virtual void calculateSize ()
 Configure the entity's size.
virtual fixed_t getRadius ()
virtual void setPosition (const Vector3D *position)
virtual void setRotation (const Rotation *rotation)
virtual void setScale (const Scale *scale)
virtual void setDirection (const Vector3D *direction)
virtual const Vector3DgetDirection ()
virtual bool applyForce (const Vector3D *force, bool checkIfCanMove)
virtual bool canMoveTowards (Vector3D direction)
virtual bool isSensibleToCollidingObjectBouncinessOnCollision (Entity collidingEntity)
virtual bool isSensibleToCollidingObjectFrictionOnCollision (Entity collidingEntity)
virtual bool isSubjectToGravity (Vector3D gravity)
virtual bool collisionStarts (const CollisionInformation *collisionInformation)
virtual void collisionPersists (const CollisionInformation *collisionInformation)
virtual void collisionEnds (const CollisionInformation *collisionInformation)
virtual uint32 getInGameType ()

# Protected Attributes

VirtualListcomponents
 Linked list of attached components.
Transformation transformation
 3D transformation
Body body
bool isVisible
 Flag used for streaming purposes.

# Additional Inherited Members

- Private Member Functions inherited from ListenerObject
void constructor ()
 Class' constructor.
void destructor ()
 Class' destructor.
void addEventListener (ListenerObject listener, uint16 eventCode)
void removeEventListener (ListenerObject listener, uint16 eventCode)
void removeEventListeners (uint16 eventCode)
void removeAllEventListeners ()
 Remove all listener objects.
bool hasActiveEventListeners ()
void fireEvent (uint16 eventCode)
void sendMessageTo (ListenerObject receiver, uint32 message, uint32 delay, uint32 randomDelay)
void sendMessageToSelf (uint32 message, uint32 delay, uint32 randomDelay)
void discardAllMessages ()
 Discard all messages, both to be sent and to be received.
void discardMessages (uint32 message)
virtual bool onEvent (ListenerObject eventFirer, uint16 eventCode)
- Private Attributes inherited from ListenerObject
VirtualList events
 List of registered events.
int8 eventFirings
 Counter that keeps track of the number of fired events to prevent race conditions in nested firings.

# Detailed Description

Class Entity

Inherits from ListenerObject

Defines objects that occupy a place in 3D space.

Definition at line 38 of file Entity.h.

# Member Function Documentation

# addComponent()

Component Entity::addComponent ( const ComponentSpec * componentSpec)

Attach a new component to the entity and configure it with the provided spec.

Parameters
componentSpecSpecification to be used to configure the new component
Returns
Added component

Definition at line 120 of file Entity.c.

# addComponents()

void Entity::addComponents ( ComponentSpec ** componentSpecs,
uint32 componentType )

Attach a new components to the entity and configure it with the provided specs.

Parameters
componentSpecsSpecifications to be used to configure the new components
componentTypeType of components to add

Definition at line 134 of file Entity.c.

# addedComponent()

void Entity::addedComponent ( Component component)
virtual

A new component has been added to this entity.

Parameters
componentAdded component

Definition at line 470 of file Entity.c.

# applyForce()

bool Entity::applyForce ( const Vector3D * force,
bool checkIfCanMove )
virtual

Apply a force to the entity's body.

Parameters
forceForce to be applied
checkIfCanMoveIf true, the entity checks that none of its colliders will
Returns
True if the force was succesfully applied to the entity's body

Definition at line 618 of file Entity.c.

# calculateSize()

void Entity::calculateSize ( )
virtual

Configure the entity's size.

Reimplemented in Actor.

Definition at line 561 of file Entity.c.

# canMoveTowards()

bool Entity::canMoveTowards ( Vector3D direction)
virtual

Check if the entity will enter a collision if it were to move in the provided direction

Parameters
directionDirection vector to check

Definition at line 642 of file Entity.c.

# checkCollisions()

void Entity::checkCollisions ( bool activate)

Enable or disable collision detection against other entitys' colliders.

Parameters
activateIf true, this entity's colliders check collision against other entitys'

Definition at line 370 of file Entity.c.

# clearComponentLists()

void Entity::clearComponentLists ( uint32 componentType)

Clear the linked lists of components.

Parameters
componentTypeType of components whose lists must be cleard

Definition at line 90 of file Entity.c.

# collisionEnds()

void Entity::collisionEnds ( const CollisionInformation * collisionInformation)
virtual

Process when a previously detected collision by one of the component colliders stops.

Parameters
collisionInformationInformation struct about the collision to resolve

Definition at line 754 of file Entity.c.

# collisionPersists()

void Entity::collisionPersists ( const CollisionInformation * collisionInformation)
virtual

Process a going on collision detected by one of the component colliders.

Parameters
collisionInformationInformation struct about the collision to resolve

Definition at line 749 of file Entity.c.

# collisionStarts()

bool Entity::collisionStarts ( const CollisionInformation * collisionInformation)
virtual

Process a newly detected collision by one of the component colliders.

Parameters
collisionInformationInformation struct about the collision to resolve
Returns
True if the collider must keep track of the collision to detect if it persists and when it ends; false otherwise

Reimplemented in Particle.

Definition at line 704 of file Entity.c.

# constructor()

void Entity::constructor ( )

Class' constructor.

Definition at line 39 of file Entity.c.

# createComponents()

void Entity::createComponents ( ComponentSpec ** componentSpecs)
virtual

Create the components that must attach to this container.

Parameters
componentSpecsSpecifications to be used to configure the new components

Reimplemented in Actor.

Definition at line 448 of file Entity.c.

# destroyComponents()

void Entity::destroyComponents ( )
virtual

Destroy the components that attach to this container.

Reimplemented in Actor.

Definition at line 462 of file Entity.c.

# disableCollisions()

void Entity::disableCollisions ( )

Disable collision detection on the entity's colliders.

Definition at line 363 of file Entity.c.

# enableCollisions()

void Entity::enableCollisions ( )

Enable collision detection on the entity's colliders.

Definition at line 356 of file Entity.c.

# getBody()

Body Entity::getBody ( )

Retrieve the entity's physical body.

Returns
Entity's physical body

Definition at line 244 of file Entity.c.

# getBounciness()

fixed_t Entity::getBounciness ( )

Retrieve the object's bounciness fentity.

Returns
Object's bounciness fentity

Definition at line 332 of file Entity.c.

# getCollidersLayers()

uint32 Entity::getCollidersLayers ( )

Retrieve the layers in which this entity's colliders live.

Returns
Flags that determine the layers where the entity's colliders live

Definition at line 391 of file Entity.c.

# getCollidersLayersToIgnore()

uint32 Entity::getCollidersLayersToIgnore ( )

Retrieve the layers that the entity's colliders ignore when detecting collision.

Returns
The layers that the entity's colliders ignore when detecting collision

Definition at line 416 of file Entity.c.

# getComponentAtIndex()

Component Entity::getComponentAtIndex ( uint32 componentType,
int16 componentIndex )

Retrieve a component of the given type at the desired position.

Parameters
componentTypeType of components to add
componentIndexComponent's index according to their order of creation
Returns
Component at the provided index position

Definition at line 148 of file Entity.c.

# getComponents()

VirtualList Entity::getComponents ( uint32 componentType)

Retrieve a list with the components of the provided type.

Parameters
componentTypeType of components to add
Returns
Linked list of components of the type provided

Definition at line 155 of file Entity.c.

# getComponentsCount()

uint16 Entity::getComponentsCount ( uint32 componentType)

Retrieve the number of components belonging to the entity.

Parameters
componentTypeType of components to count
Returns
Number of components belonging to the entity

Definition at line 194 of file Entity.c.

# getComponentsOfClass()

bool Entity::getComponentsOfClass ( ClassPointer classPointer,
VirtualList components,
uint32 componentType )

Retrieve the linked list of components that are instances of the provided class.

Parameters
classPointerPointer to the class to use as search criteria. Usage: typeofclass(ClassName)
componentsLinked list to be filled with the components that meed the search criteria (it is externally allocated and must be externally deleted)
componentTypeType of components to retrieve
Returns
True if one or more components met the search criteria; false otherwise

Definition at line 187 of file Entity.c.

# getDirection()

const Vector3D * Entity::getDirection ( )
virtual

Retrieve the direction towards which the object is moving.

Returns
Pointer to the direction towards which the object is moving

Definition at line 604 of file Entity.c.

# getFrictionCoefficient()

fixed_t Entity::getFrictionCoefficient ( )

Retrieve the object's friction coefficient.

Returns
Object's friction coefficient

Definition at line 344 of file Entity.c.

# getInGameType()

uint32 Entity::getInGameType ( )
virtual

Retrieve the enum that determines the type of game object.

Returns
The enum that determines the type of game object

Reimplemented in Actor, and Particle.

Definition at line 772 of file Entity.c.

# getMaximumSpeed()

fixed_t Entity::getMaximumSpeed ( )

Retrieve the entity's maximum speed.

Returns
Maximum speed at which the entity's body is allowed to move

Definition at line 325 of file Entity.c.

# getPosition()

const Vector3D * Entity::getPosition ( )

Retrieve the object's position.

Returns
Pointer to the object's 3D vector defining its position

Definition at line 223 of file Entity.c.

# getRadius()

fixed_t Entity::getRadius ( )
virtual

Retrieve the object's radius.

Returns
Radius

Reimplemented in Actor.

Definition at line 566 of file Entity.c.

# getRotation()

const Rotation * Entity::getRotation ( )

Retrieve the object's rotation.

Returns
Pointer to the object's 3D rotation

Definition at line 230 of file Entity.c.

# getScale()

const Scale * Entity::getScale ( )

Retrieve the object's scale.

Returns
Pointer to the object's 3D

Definition at line 237 of file Entity.c.

# getSpeed()

fixed_t Entity::getSpeed ( )

Retrieve the object's current speed (velocity vector's magnitude).

Returns
Object's current speed (velocity vector's magnitude)

Definition at line 313 of file Entity.c.

# getTransformation()

const Transformation * Entity::getTransformation ( )

Retrieve the object's transformation.

Returns
Pointer to the object's 3D transformation

Definition at line 216 of file Entity.c.

# getVelocity()

const Vector3D * Entity::getVelocity ( )

Retrieve the object's velocity vector.

Returns
Pointer to the direction towards which the object is moving

Definition at line 299 of file Entity.c.

# handleMessage()

bool Entity::handleMessage ( Telegram telegram)
virtual

Receive and process a Telegram.

Parameters
telegramReceived telegram to process
Returns
True if the telegram was processed

Reimplemented from ListenerObject.

Definition at line 66 of file Entity.c.

# hasColliders()

bool Entity::hasColliders ( )

Check if the entity has attached colliders.

Returns
True if the entity hast at least on collider arrached; false otherwise

# hide()

void Entity::hide ( )
virtual

Make this instance invisible.

Reimplemented in Container, and ParticleSystem.

Definition at line 545 of file Entity.c.

# hideColliders()

void Entity::hideColliders ( )

Make the entity's colliders invisible.

Definition at line 441 of file Entity.c.

# isMoving()

bool Entity::isMoving ( )

Check if the entity is moving.

Returns
True if the entity's body is moving; false otherwise

Definition at line 251 of file Entity.c.

# isSensibleToCollidingObjectBouncinessOnCollision()

bool Entity::isSensibleToCollidingObjectBouncinessOnCollision ( Entity collidingEntity)
virtual

Check if when the entity bounces it has to take into account the colliding object's bounciness.

Returns
True if the entity has to take into account the colliding object's bounciness when bouncing

Definition at line 673 of file Entity.c.

# isSensibleToCollidingObjectFrictionOnCollision()

bool Entity::isSensibleToCollidingObjectFrictionOnCollision ( Entity collidingEntity)
virtual

Check if when the entity bounces it has to take into account the colliding object's friction coefficient.

Returns
True if the entity has to take into account the colliding object's friction coefficient when bouncing

Definition at line 680 of file Entity.c.

# isSubjectToGravity()

bool Entity::isSubjectToGravity ( Vector3D gravity)
virtual

Check if the object is subject to provided gravity vector.

Returns
True if the provided gravity vector can affect the object; false otherwise

Definition at line 687 of file Entity.c.

# registerCollisions()

void Entity::registerCollisions ( bool activate)

Enable or disable the register of detected collisions.

Parameters
activateIf false, this entity's colliders won't keep track of collisions, hence they won't notify of it of persisting (collisionPersists) collisions or when end (collisionEnds)

Definition at line 377 of file Entity.c.

# removeComponent()

void Entity::removeComponent ( Component component)

Remove a component from the entity.

Parameters
componentComponent to remove

Definition at line 127 of file Entity.c.

# removeComponents()

void Entity::removeComponents ( uint32 componentType)

Remove the components of a give type from the entity.

Parameters
componentTypeType of components to remove

Definition at line 141 of file Entity.c.

# removedComponent()

void Entity::removedComponent ( Component component)
virtual

A component has been removed from this entity.

Parameters
componentRemoved component

Reimplemented in Particle, and Printer.

Definition at line 508 of file Entity.c.

# resetComponents()

void Entity::resetComponents ( )

Reset components.

Definition at line 201 of file Entity.c.

# setCollidersLayers()

void Entity::setCollidersLayers ( uint32 layers)

Set the layers in which this entity's colliders must live.

Parameters
layersFlags that determine the layers for the entity's colliders

Definition at line 384 of file Entity.c.

# setCollidersLayersToIgnore()

void Entity::setCollidersLayersToIgnore ( uint32 layersToIgnore)

Set the layers that the entity's colliders must ignore when detecting collision.

Parameters
layersToIgnoreFlags that determine the layers with colliders to ignore when detecting collisions

Definition at line 409 of file Entity.c.

# setDirection()

void Entity::setDirection ( const Vector3D * direction)
virtual

Set the direction towards which the object must move.

Parameters
directionPointer to a direction vector

Reimplemented in Container.

Definition at line 599 of file Entity.c.

# setPosition()

void Entity::setPosition ( const Vector3D * position)
virtual

Set the object's position.

Parameters
position3D vector defining the object's new position

Reimplemented in Container.

Definition at line 573 of file Entity.c.

# setRotation()

void Entity::setRotation ( const Rotation * rotation)
virtual

Set the object's rotation.

Parameters
rotationRotation

Reimplemented in Container.

Definition at line 585 of file Entity.c.

# setScale()

void Entity::setScale ( const Scale * scale)
virtual

Set the object's scale.

Parameters
scaleScale

Reimplemented in Container.

Definition at line 592 of file Entity.c.

# setTransparency()

void Entity::setTransparency ( uint8 transparency)
virtual

Set this instance's transparency effects.

Parameters
transparencyTransparecy effect (__TRANSPARENCY_NONE, __EVEN or __ODD)

Reimplemented in Container, ParticleSystem, and Printer.

Definition at line 553 of file Entity.c.

# setVelocity()

bool Entity::setVelocity ( const Vector3D * velocity,
bool checkIfCanMove )

Set the entity's velocity vector.

Parameters
velocityVelocity vector to assign to the entity's body
checkIfCanMoveIf true, the entity checks that none of its colliders will enter a collision if it were to move in the direction of the provided velocity
Returns
True if the entity started to move in the direction specified by the provided velocity vector

Definition at line 275 of file Entity.c.

# setVisible()

void Entity::setVisible ( )

Set this instance's visibility flag up.

Definition at line 208 of file Entity.c.

# show()

void Entity::show ( )
virtual

Make this instance visible.

Reimplemented in Container, and ParticleSystem.

Definition at line 537 of file Entity.c.

# showColliders()

void Entity::showColliders ( )

Make the entity's colliders visible.

Definition at line 434 of file Entity.c.

# stopAllMovement()

void Entity::stopAllMovement ( )

Stop all entity's movement.

Definition at line 258 of file Entity.c.

# stopMovement()

void Entity::stopMovement ( uint16 axis)

Stop the entity's movement in the specified axis.

Parameters
axisAxis on which to stop the movement of the entity's body

Definition at line 265 of file Entity.c.

# Member Data Documentation

# body

Body Entity::body
protected

Cache the Body component for physics simulations to avoid having constantly grabing it from the ComponentManager

Definition at line 50 of file Entity.h.

# components

VirtualList* Entity::components
protected

Linked list of attached components.

Definition at line 43 of file Entity.h.

# isVisible

bool Entity::isVisible
protected

Flag used for streaming purposes.

Definition at line 53 of file Entity.h.

# transformation

Transformation Entity::transformation
protected

3D transformation

Definition at line 46 of file Entity.h.


The documentation for this class was generated from the following files: