Planeshift
|
This object represents a planeshift entity sound. More...
#include <psentity.h>
Classes | |
struct | EntityState |
Keeps all the parameters of an entity state. | |
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. | |
bool | DefineState (csRef< iDocumentNode > stateNode) |
Create a new state from an XML <state> node. | |
const csString & | GetEntityName () const |
Gets the entity name associated to this object. | |
float | GetMaxRange () const |
Gets the maximum distance at which this entity can be heard. | |
uint | GetMeshID () const |
Get the ID of the mesh associated to this entity. | |
csVector3 | GetPosition () |
Returns the 3d position of this entity. | |
int | GetState () |
Gets the state of the entity. | |
bool | IsActive () const |
Check if this entity is active. | |
bool | IsFactoryEntity () const |
Return true if this is a factory entity. | |
bool | IsPlaying () const |
Check if the sound associated to this entity is still working. | |
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. | |
bool | Play (SoundControl *&ctrl, csVector3 entityPosition) |
Force this entity to play the sound associated to its current state. | |
psEntity (bool isFactoryEntity, const char *entityName) | |
Create a new psEntity. | |
psEntity (psEntity *const &entity) | |
Copy Constructor. | |
void | SetActive (bool toggle) |
Activate or deactivate this entity. | |
void | SetAsFactoryEntity (const char *factoryName) |
Sets this object as a factory entity. | |
void | SetAsMeshEntity (const char *meshName) |
Sets this object as a mesh entity. | |
void | SetMeshID (uint id) |
Set the ID of the mesh associated to this entity. | |
void | SetRange (float minRange, float maxRange) |
Sets the range for this entity. | |
void | SetState (int state, bool forceChange, bool setReady) |
Set the new state for the entity. | |
void | Stop () |
If this entity is playing, this method forces this to stop the sound. | |
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. | |
~psEntity () | |
Destructor. |
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.
Definition at line 39 of file psentity.h.
psEntity::psEntity | ( | bool | isFactoryEntity, |
const char * | entityName | ||
) |
Create a new psEntity.
The initial state is set to DEFAULT_ENTITY_STATE.
isFactoryEntity | true if this is associated to a factory, false if this is associated to a mesh. |
entityName | the 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.
Checks if all condition for the sound to play are satisfied in the current state.
time | <24 && >0 is resonable but can be any valid int. |
range | the distance to test. |
bool psEntity::DefineState | ( | csRef< iDocumentNode > | stateNode | ) |
Create a new state from an XML <state> node.
stateNode | the state node. |
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.
Definition at line 78 of file psentity.h.
float psEntity::GetMaxRange | ( | ) | const [inline] |
Gets 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.
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.
Definition at line 142 of file psentity.h.
bool psEntity::IsFactoryEntity | ( | ) | const [inline] |
Return true if this is a factory entity.
Definition at line 68 of file psentity.h.
bool psEntity::IsPlaying | ( | ) | const |
Check if the sound associated to this entity is still working.
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.
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.
ctrl | the SoundControl to control this sound. |
entityposition | position of this entity. |
void psEntity::SetActive | ( | bool | toggle | ) | [inline] |
Activate or deactivate this entity.
toggle | true 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.
factoryName | the name of the factory associated to this object. |
void psEntity::SetAsMeshEntity | ( | const char * | meshName | ) |
Sets this object as a mesh entity.
meshName | the name of the mesh associated to this object. |
void psEntity::SetMeshID | ( | uint | id | ) |
Set the ID of the mesh associated to this entity.
id | the new id of this entity. |
Sets the range for this entity.
minRange | maximum distance at which this entity is heard at maximum volume. |
maxRange | maximum 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.
state | the new state for this entity. |
forceChange | true to force the state change, false otherwise. |
setReady | when 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.
time | the time of the day, <24 && >0 is resonable but can be any valid int. |
distance | the distance from the listener. |
ctrl | the SoundControl to play the sound with. |
entityPosition | the position of the player. |