CGameEntity Class Reference

Game Entity (GEs). More...

#include <gameEntity.h>

List of all members.

Enum data

enum  eError { kNone = 0, kNoEnt = -1, kBadValue = -2 }
 Error code enums. More...
enum  eState {
  kStateNone = 0, kStateIdle = 1, kStateForward, kStateBackward,
  kStateLeft, kStateRight, kStateRun, kStateJump,
  kStateWater, kStateAir, kStateAttack, kStateReload,
  kStateSwitch, kStateDamage, kStateDead, kStateDuck,
  kStateRemove, kStateEmpty
}
 State this entity is in. Can be used for animation, attack modifiers, movement, etc. More...
static eState string_to_eState (const char *str)
 Get eState from a string value.

Creation methods

Factory methods are the only way to create a CGameEntity (GE).

static CGameEntitycreate_gameEntity (ENTITY *pEnt)
 Factory creates a GE using the ENTITY.
static CGameEntitycreate_gameEntity (char *filename)
 Factory creates a GE from a filename.
static CGameEntitycreate_gameEntity (ENTITY *pEnt, CGameEntityData *pData)
 Factory creates a GE from an ENTITY and use a Data struct to init it.
bool data_load (CGameEntityData *pEntityData)
 Set GE values/CMPs using data.

Public Member Functions

Destructor methods
virtual ~CGameEntity ()
 Destructor.
void remove ()
 Remove GE from the game.
Data methods
Uses the CMPs and ENTITY data to handle updates, actions, and edits.

virtual bool update ()
 Update this entity for one frame.
virtual int set (const EDIT_DATA &editData)
 Set a value.
virtual int set (eCmp cmpType, const EDIT_DATA &editData)
 Set a value in a single CMP.
virtual int get (EDIT_DATA &editData)
 Get a value.
virtual int get (eCmp cmpType, EDIT_DATA &editData)
 Get a value from a single CMP.
virtual int act (const ACTION_DATA &actData)
 Preform an action.
virtual int act (eCmp cmpType, const ACTION_DATA &actData)
 Use a single CMP to preform an action.
Event methods
Events are sent from the game engine to the ENTITY.

eError event_enable (const unsigned int bfEvent)
 Enable an event.
eError event_disable (const unsigned int bfEvent)
 Disable an event.
bool event_valid (const unsigned int bfEvent)
 Is event valid?
State methods
The state of an GE (eState).

void state_clear ()
 Clear all states.
void state_set (eState state)
 Set a state.
void state_reset (eState state)
 Reset a state.
bool state_check (eState state) const
 Check a state.
bool state_check (const CFlagSet< eState > &flagSet) const
 Check a group of states.
CMP methods
CMP (components) add functionality to the GE. Each GE can have zero or more CMPs.

bool cmp_valid (eCmp type)
 Has this CMP been added to this GE?
bool cmp_add (eCmp type)
 Add a CMP to this GE.
void cmp_remove ()
 Remove all CMPs.
CCmpcmp_get (eCmp type)
 Get a CMP pointer.
Movement methods
Move the entity while handling collision.

bool move (const CVector3D &vec, int move_mode=-1)
 Move the entity by the vector given (with collision).
bool move (const unit x, const unit y, const unit z, int move_mode=-1)
 Move the entity by the vector given (with collision).
Rotation methods
Rotate the entity while handling collision.

bool rotate (const CAngle3D &ang, int move_mode=-1)
 Rotate the entity by the angle given (with collision).
bool rotate (const unit pan, const unit tilt, const unit roll, int move_mode=-1)
 Rotate the entity by the angle given (with collision).
Distance methods
Distance (in quants) moved in the last update.

const CVector3Ddist () const
 Get distance moved.
void dist (const CVector3D &dist)
 Set a new distance value.
void dist_add (const CVector3D &dist)
 Add to the distance moved.
Position methods
The position of the ENTITY.

CVector3D pos () const
 Get the current position.
void pos (const CVector3D &vec)
 Set the position of the entity (without collision).
void pos (const unit x, const unit y, const unit z)
 Set the position of the entity (without collision).
Angle methods
Rotation angle of the ENTITY.

CAngle3D ang () const
 Get the current angle.
void ang (const CAngle3D &ang)
 Set the angle of the entity (without collision).
void ang (const unit pan, const unit tilt, const unit roll)
 Set the angle of the entity (without collision).
Skill methods
Skills are stored inside the ENTITY itself.

var skill (const int index)
 Get an ENTITY skill as a VAR.
float skill_f (const int index)
 Get an ENTITY skill as a float value.
bool skill (const int index, const int value)
 Set a skill.
bool skill (const int index, const unit value)
 Set a skill.
bool skill (const EDIT_SKILL_DATA *pData)
 Set a skill.
Misc methods
virtual bool valid () const
 Is ENTITY* valid?
unsigned long id () const
 Get the GE's unique ID number.
ENTITY * pEnt () const
 Get a pointer to the GE's acknex ENTITY.

Static Public Attributes

static const int kSkillGEID = 99
 Const.
static const int kSkillIndexMax = 98
 Max index value into the skill array.

Protected Member Functions

Construction methods
Construction methods are not to be used directly. Instead, you should always use a Factory method to create a GE.

 CGameEntity (ENTITY *pEnt)
 Create a basic GE.
 CGameEntity (char *filename)
 Create a GE from a filename.
eError init ()
 Init all values to their default.


Detailed Description

Game Entity (GEs).

Game Entities (GEs) are a collection of components (CCmp) attached to a single acknex ENTITY.

(c) 2007-2008 oP group Germany GbR. All rights reserved.
This source code is provided "as is" with no warranty and must not be distributed without written permission.

Author:
Doug Poston
Version:
1.3
Date:
12/28/2007

Member Enumeration Documentation

enum CGameEntity::eError

Error code enums.

Enumerator:
kNone  No error.
kNoEnt  No entity.
kBadValue  A bad input value.

enum CGameEntity::eState

State this entity is in. Can be used for animation, attack modifiers, movement, etc.

Enumerator:
kStateNone  Not doing anything.
kStateIdle  Play idle animation (smoke, stand, etc.).
kStateForward  Moving forward (run, walk).
kStateBackward  Moving backwards (run, walk).
kStateLeft  Moving left.
kStateRight  Moving right.
kStateRun  Moving faster than normal.
kStateJump  Jumping.
kStateWater  In water.
kStateAir  In air.
kStateAttack  Attacking (shoot, throw, swing, stab, ...).
kStateReload  Reloading a device (i.e. weapon).
kStateSwitch  Switching items in hand (i.e. weapons).
kStateDamage  Taking damage.
kStateDead  Dead or dying.
kStateDuck  Ducking or crawling.
kStateRemove  Marked for removal.
kStateEmpty  Contains nothing (can be safely removed).


Constructor & Destructor Documentation

CGameEntity::CGameEntity ( ENTITY *  pEnt  )  [protected]

Create a basic GE.

Parameters:
pEnt Pointer to ENTITY used.

CGameEntity::CGameEntity ( char *  filename  )  [protected]

Create a GE from a filename.

Parameters:
filename Name of a valid ENTITY file (model, sprite, or map entity).


Member Function Documentation

CGameEntity::eState CGameEntity::string_to_eState ( const char *  str  )  [static]

Get eState from a string value.

Parameters:
str String containing eState name.
Returns:
eState enum.
Parameters:
str  take a string and return the eState

CGameEntity * CGameEntity::create_gameEntity ( ENTITY *  pEnt  )  [static]

Factory creates a GE using the ENTITY.

Parameters:
pEnt Pointer to ENTITY used by this GE.
Returns:
Pointer to the GE created (NULL on error).
Parameters:
pEnt  factory creates any type of CGameEntity, returns points

CGameEntity * CGameEntity::create_gameEntity ( char *  filename  )  [static]

Factory creates a GE from a filename.

Parameters:
filename Name of a valid ENTITY file (model, sprite, or map entity).
Returns:
Pointer to the GE created (NULL on error).
Parameters:
filename  factory creates any type of CGameEntity, returns points

CGameEntity * CGameEntity::create_gameEntity ( ENTITY *  pEnt,
CGameEntityData pData 
) [static]

Factory creates a GE from an ENTITY and use a Data struct to init it.

Parameters:
pEnt Pointer to ENTITY used by this GE.
pData Data used to init the GE.
Returns:
Pointer to the GE created (NULL on error).
Parameters:
pData  same as above, but using CGameEntityData for data

bool CGameEntity::data_load ( CGameEntityData pEntityData  ) 

Set GE values/CMPs using data.

Load values, skills, CMPs, and their edit values from the GameEntityData passed in.

Parameters:
pEntityData Pointer to the data used.
Returns:
true if data was added or edited, otherwise false

CGameEntity::eError CGameEntity::init (  )  [protected]

Init all values to their default.

Returns:
Error code (0 if no error).

void CGameEntity::remove (  ) 

Remove GE from the game.

Shuts down all the attached CMPs and flags this GE as "empty".

bool CGameEntity::update (  )  [virtual]

Update this entity for one frame.

Returns:
false If this GE is no longer updating (e.g. empty or invalid).

int CGameEntity::set ( const EDIT_DATA editData  )  [virtual]

Set a value.

If we have a matching data type in any of the CMPs or base GE, set its value.

Parameters:
editData Data type and value (see EDIT_DATA struct).
Returns:
Value less than zero on error, 0 if nothing found, positive otherwise.
See also:
EDIT_DATA
Edit an entity's value by preforming an action
Parameters:
editData The data used to preform the action (see EDIT_DATA struct)
Returns:
value less than zero on error, 0 if nothing found, positive otherwise

int CGameEntity::set ( eCmp  cmpType,
const EDIT_DATA editData 
) [virtual]

Set a value in a single CMP.

If we have a matching data type in the CMP given, set its value.

Parameters:
cmpType The component we are editing
editData Data type and value (see EDIT_DATA struct).
Returns:
Value less than zero on error, 0 if nothing found, positive otherwise.
See also:
EDIT_DATA

int CGameEntity::get ( EDIT_DATA editData  )  [virtual]

Get a value.

If we have a matching data type in any of the CMPs or base GE, get the value.

Parameters:
editData Data type we are looking for, and memory to store value (see EDIT_DATA struct).
Returns:
Value less than zero on error, 0 if nothing found, positive otherwise.
See also:
EDIT_DATA
Get an entity's value
Parameters:
editData The data used to preform the action (see EDIT_DATA struct)
Returns:
value less than zero on error, 0 if nothing found, positive otherwise

int CGameEntity::get ( eCmp  cmpType,
EDIT_DATA editData 
) [virtual]

Get a value from a single CMP.

If we have a matching data type in the CMP given, get the value.

Parameters:
cmpType The component we are checking
editData Data type we are looking for, and memory to store value (see EDIT_DATA struct).
Returns:
Value less than zero on error, 0 if nothing found, positive otherwise.
See also:
EDIT_DATA

int CGameEntity::act ( const ACTION_DATA actData  )  [virtual]

Preform an action.

Handle the action passed in (ignore if we do not handle the action type).

Parameters:
actData The data used to preform the action (see ACTION_DATA struct).
Returns:
Value less than zero on error, 0 if no action found, positive otherwise.
See also:
ACTION_DATA

int CGameEntity::act ( eCmp  cmpType,
const ACTION_DATA actData 
) [virtual]

Use a single CMP to preform an action.

Have a single CMP handle the action passed in (ignore if it does not handle the action type).

Parameters:
cmpType The component we are acting on
actData The data used to preform the action (see ACTION_DATA struct).
Returns:
Value less than zero on error, 0 if no action found, positive otherwise.
See also:
ACTION_DATA

CGameEntity::eError CGameEntity::event_enable ( const unsigned int  bfEvent  ) 

Enable an event.

Set an event for this GE to react to.

Parameters:
bfEvent The event bit-flag we are enabling (see atypes.h for avalible ENABLE_EVENTS)
Returns:
Error code (0: no error, neg otherwise)

CGameEntity::eError CGameEntity::event_disable ( const unsigned int  bfEvent  ) 

Disable an event.

Disable checking for this type of event

Parameters:
bfEvent The event bit-flag we are disabling (see atypes.h for avalible ENABLE_EVENTS)
Returns:
Error code (0: no error, neg otherwise)

bool CGameEntity::event_valid ( const unsigned int  bfEvent  ) 

Is event valid?

Are we checking for this kind of event?

Parameters:
bfEvent The event bit-flag to check.
Returns:
true if this event flag is enabled

void CGameEntity::state_set ( eState  state  )  [inline]

Set a state.

Parameters:
state State to be set.

void CGameEntity::state_reset ( eState  state  )  [inline]

Reset a state.

Parameters:
state State to be reset.

bool CGameEntity::state_check ( eState  state  )  const [inline]

Check a state.

Parameters:
state State to check.
Returns:
true if state is set, otherwise false.

bool CGameEntity::state_check ( const CFlagSet< eState > &  flagSet  )  const [inline]

Check a group of states.

Note:
This is useful for AI and animation conditions.
Returns:
true if the all the flags in the set passed in are set in this flagset, otherwise false

bool CGameEntity::cmp_valid ( eCmp  type  ) 

Has this CMP been added to this GE?

Parameters:
type The type of cmp to check.
Returns:
true if cmp is valid, otherwise false

bool CGameEntity::cmp_add ( eCmp  type  ) 

Add a CMP to this GE.

Parameters:
type The type of cmp to add.
Returns:
true if cmp was added, otherwise false

CCmp * CGameEntity::cmp_get ( eCmp  type  ) 

Get a CMP pointer.

Returns:
Pointer to a CCmp
Parameters:
type The CMP we want to get a pointer to
Returns:
The CMP that matches type, o if nothing found.

bool CGameEntity::move ( const CVector3D vec,
int  move_mode = -1 
)

Move the entity by the vector given (with collision).

Parameters:
vec Movement vector.
move_mode Optional move_mode value (neg values use the default move_mode).
Returns:
true if collision occured.

bool CGameEntity::move ( const unit  x,
const unit  y,
const unit  z,
int  move_mode = -1 
)

Move the entity by the vector given (with collision).

Parameters:
x Movement in X
y Movement in Y
z Movement in Z
move_mode Optional move_mode value (neg values use the default move_mode)
Returns:
true if collision occured

bool CGameEntity::rotate ( const CAngle3D ang,
int  move_mode = -1 
)

Rotate the entity by the angle given (with collision).

Parameters:
ang Movement vector
move_mode Optional move_mode value (neg values use the default move_mode)
Returns:
true if collision occured

bool CGameEntity::rotate ( const unit  pan,
const unit  tilt,
const unit  roll,
int  move_mode = -1 
)

Rotate the entity by the angle given (with collision).

Parameters:
pan rotation around Z
tilt rotation around Y
roll rotation around X
move_mode Optional move_mode value (neg values use the default move_mode)
Returns:
true if collision occured

const CVector3D & CGameEntity::dist (  )  const

Get distance moved.

Returns:
The distance this entity moved last update (as a vector).

void CGameEntity::dist ( const CVector3D dist  ) 

Set a new distance value.

Parameters:
dist Overwrites old value.

void CGameEntity::dist_add ( const CVector3D dist  ) 

Add to the distance moved.

Parameters:
dist Distance to add to the current value.

CVector3D CGameEntity::pos (  )  const [inline]

Get the current position.

Returns:
A CVector3D with the current position

void CGameEntity::pos ( const CVector3D vec  )  [inline]

Set the position of the entity (without collision).

Parameters:
vec New position of the entity
Note:
It is not normally a good idea to set the position of an entity directly (use move instead).

void CGameEntity::pos ( const unit  x,
const unit  y,
const unit  z 
) [inline]

Set the position of the entity (without collision).

Parameters:
x New x position of the entity
y New y position of the entity
z New z position of the entity
Note:
It is not normally a good idea to set the position of an entity directly (use move instead)

CAngle3D CGameEntity::ang (  )  const [inline]

Get the current angle.

Returns:
A CAngle3D with the current angles (pan, tilt, roll).

void CGameEntity::ang ( const CAngle3D ang  )  [inline]

Set the angle of the entity (without collision).

Parameters:
ang New angle of the entity
Note:
It is not normally a good idea to set the angle of an entity directly (use rotate instead)

void CGameEntity::ang ( const unit  pan,
const unit  tilt,
const unit  roll 
) [inline]

Set the angle of the entity (without collision).

Parameters:
pan Entity's new pan
tilt Entity's new tilt
roll Entity's new roll
Note:
It is not normally a good idea to set the angle of an entity directly (use rotate instead)

var CGameEntity::skill ( const int  index  )  [inline]

Get an ENTITY skill as a VAR.

Parameters:
index Index into the skill array (0-max)
Returns:
The skill value for the given index (as a VAR), 0 if none found

float CGameEntity::skill_f ( const int  index  )  [inline]

Get an ENTITY skill as a float value.

Parameters:
index Index into the skill array (0-max)
Returns:
The skill value for the given index (as a float), 0 if none found

bool CGameEntity::skill ( const int  index,
const int  value 
) [inline]

Set a skill.

Parameters:
index Index into the skill array (0-max)
value Value we want to store
Returns:
false on error (no value set)

bool CGameEntity::skill ( const int  index,
const unit  value 
) [inline]

Set a skill.

Parameters:
index Index into the skill array (0-max)
value Value we want to store
Returns:
false on error (no value set)

bool CGameEntity::skill ( const EDIT_SKILL_DATA pData  )  [inline]

Set a skill.

Parameters:
pData Data struct used to set a skill value
Returns:
false on error (no value set)

virtual bool CGameEntity::valid (  )  const [inline, virtual]

Is ENTITY* valid?

Returns:
true if ENTITY* is not NULL

unsigned long CGameEntity::id (  )  const [inline]

Get the GE's unique ID number.

Returns:
This GE's unique ID number.

ENTITY* CGameEntity::pEnt (  )  const [inline]

Get a pointer to the GE's acknex ENTITY.

Returns:
This GE's ENTITY*


Member Data Documentation

const int CGameEntity::kSkillGEID = 99 [static]

Const.

Skill used to store the Game Entity ID


The documentation for this class was generated from the following files:
Generated on Fri Dec 28 12:55:07 2007 for template7 by  doxygen 1.5.4