Planeshift
psEntity Class Reference

This object represents a planeshift entity sound. More...

#include <psentity.h>

Public Member Functions

bool CanPlay (int time, float range) const
 Checks if all condition for the sound to play are satisfied in the current state. More...
 
bool DefineState (csRef< iDocumentNode > stateNode)
 Create a new state from an XML <state> node. More...
 
const csString & GetEntityName () const
 Gets the entity name associated to this object. More...
 
float GetMaxRange () const
 Gets the maximum distance at which this entity can be heard. More...
 
uint GetMeshID () const
 Get the ID of the mesh associated to this entity. More...
 
csVector3 GetPosition ()
 Returns the 3d position of this entity. More...
 
int GetState ()
 Gets the state of the entity. More...
 
bool IsActive () const
 Check if this entity is active. More...
 
bool IsFactoryEntity () const
 Return true if this is a factory entity. More...
 
bool IsPlaying () const
 Check if the sound associated to this entity is still working. More...
 
bool IsTemporary () const
 Used to determine if this is a temporary entity associated to a specific mesh object or if it is a factory/mesh entity that is not associated to any mesh. More...
 
bool Play (SoundControl *&ctrl, csVector3 entityPosition)
 Force this entity to play the sound associated to its current state. More...
 
 psEntity (bool isFactoryEntity, const char *entityName)
 Create a new psEntity. More...
 
 psEntity (psEntity *const &entity)
 Copy Constructor. More...
 
void SetActive (bool toggle)
 Activate or deactivate this entity. More...
 
void SetAsFactoryEntity (const char *factoryName)
 Sets this object as a factory entity. More...
 
void SetAsMeshEntity (const char *meshName)
 Sets this object as a mesh entity. More...
 
void SetMeshID (uint id)
 Set the ID of the mesh associated to this entity. More...
 
void SetRange (float minRange, float maxRange)
 Sets the range for this entity. More...
 
void SetState (int state, bool forceChange, bool setReady)
 Set the new state for the entity. More...
 
void Stop ()
 If this entity is playing, this method forces this to stop the sound. More...
 
void Update (int time, float distance, int interval, SoundControl *&ctrl, csVector3 entityPosition)
 Update the entity's activation status, play the sound associated with the current state if all condition are satisfied, update the delay and fallback in the new state if necessary. More...
 
 ~psEntity ()
 Destructor. More...
 

Detailed Description

This object represents a planeshift entity sound.

It can be a mesh entity, if it is associated to a mesh object, or a factory entity if it is associated to a mesh factory.

See also
psSoundSector psEntity main user.

Definition at line 39 of file psentity.h.

Constructor & Destructor Documentation

psEntity::psEntity ( bool  isFactoryEntity,
const char *  entityName 
)

Create a new psEntity.

The initial state is set to DEFAULT_ENTITY_STATE.

Parameters
isFactoryEntitytrue if this is associated to a factory, false if this is associated to a mesh.
entityNamethe name of the factory or the mesh.
psEntity::~psEntity ( )

Destructor.

When destroyed the sounds is not stopped and it is removed by the SoundSystemManager when it is done.

psEntity::psEntity ( psEntity *const &  entity)

Copy Constructor.

It copies everthing but not the handle that is set to 0.

Note
the data of each possible state is copied by reference to save time so any change on that data will affect also its clone.

Member Function Documentation

bool psEntity::CanPlay ( int  time,
float  range 
) const

Checks if all condition for the sound to play are satisfied in the current state.

Parameters
time<24 && >0 is resonable but can be any valid int.
rangethe distance to test.
Returns
true if the dalayed is done, the entity is not in an undefined state, the given time is within this entity's time window and if the distance is between the minimum and maximum range. False otherwise.
bool psEntity::DefineState ( csRef< iDocumentNode >  stateNode)

Create a new state from an XML <state> node.

Parameters
stateNodethe state node.
Returns
true if the state could be created, false otherwise.
const csString& psEntity::GetEntityName ( ) const
inline

Gets the entity name associated to this object.

Use IsFactoryEntity() to check if this name is a mesh name or a factory name.

Returns
the entity name.

Definition at line 78 of file psentity.h.

float psEntity::GetMaxRange ( ) const
inline

Gets the maximum distance at which this entity can be heard.

Returns
the maximum distance at which this entity can be heard.

Definition at line 99 of file psentity.h.

uint psEntity::GetMeshID ( ) const

Get the ID of the mesh associated to this entity.

Returns
the ID of the mesh.
csVector3 psEntity::GetPosition ( )
inline

Returns the 3d position of this entity.

Definition at line 126 of file psentity.h.

int psEntity::GetState ( )
inline

Gets the state of the entity.

Definition at line 185 of file psentity.h.

bool psEntity::IsActive ( ) const
inline

Check if this entity is active.

Returns
true if this is active, false otherwise.

Definition at line 142 of file psentity.h.

bool psEntity::IsFactoryEntity ( ) const
inline

Return true if this is a factory entity.

Returns
true if this is a factory entity, false otherwise.

Definition at line 68 of file psentity.h.

bool psEntity::IsPlaying ( ) const

Check if the sound associated to this entity is still working.

Returns
true if it is still playing, false otherwise.
bool psEntity::IsTemporary ( ) const

Used to determine if this is a temporary entity associated to a specific mesh object or if it is a factory/mesh entity that is not associated to any mesh.

Returns
true if this entity is temporary, false otherwise.
bool psEntity::Play ( SoundControl *&  ctrl,
csVector3  entityPosition 
)

Force this entity to play the sound associated to its current state.

You need to supply a SoundControl and the position for this sound.

Parameters
ctrlthe SoundControl to control this sound.
entitypositionposition of this entity.
Returns
true if the sound is played, false if it is not or if this entity is already playing a sound.
void psEntity::SetActive ( bool  toggle)
inline

Activate or deactivate this entity.

Parameters
toggletrue to activate this entity, false to deactivate it.

Definition at line 151 of file psentity.h.

void psEntity::SetAsFactoryEntity ( const char *  factoryName)

Sets this object as a factory entity.

Parameters
factoryNamethe name of the factory associated to this object.
void psEntity::SetAsMeshEntity ( const char *  meshName)

Sets this object as a mesh entity.

Parameters
meshNamethe name of the mesh associated to this object.
void psEntity::SetMeshID ( uint  id)

Set the ID of the mesh associated to this entity.

Parameters
idthe new id of this entity.
void psEntity::SetRange ( float  minRange,
float  maxRange 
)

Sets the range for this entity.

Parameters
minRangemaximum distance at which this entity is heard at maximum volume.
maxRangemaximum distance at which this entity can be heard.
void psEntity::SetState ( int  state,
bool  forceChange,
bool  setReady 
)

Set the new state for the entity.

If the given state is undefined for this entity the change of state is not forced, the state does not change. On the other hand if the change is forced the entity's state becomes UNDEFINED_ENTITY_STATE. In this state psEntity cannot play anything.

Parameters
statethe new state for this entity.
forceChangetrue to force the state change, false otherwise.
setReadywhen set to true this set the entity in the condition to play the new state sounds by stopping any eventual playing sound and resetting the delay.
void psEntity::Stop ( )

If this entity is playing, this method forces this to stop the sound.

void psEntity::Update ( int  time,
float  distance,
int  interval,
SoundControl *&  ctrl,
csVector3  entityPosition 
)

Update the entity's activation status, play the sound associated with the current state if all condition are satisfied, update the delay and fallback in the new state if necessary.

Parameters
timethe time of the day, <24 && >0 is resonable but can be any valid int.
distancethe distance from the listener.
ctrlthe SoundControl to play the sound with.
entityPositionthe position of the player.

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