CGame Class Reference

Manages all the elements of the game (level, input, network, etc.). More...

#include <game.h>

List of all members.

Creation methods

Since this is a singlton, we use an instance for all our calls.

 ~CGame ()
eError init ()
 Setup with starting values.
static CGameinstance ()
 
Returns:
A pointer to the singlton instance.


Public Types

Enum values
enum  eError {
  kNoError = 0, kNoEnt = -1, kBadValue = -2, kCantFindInLevel = -3,
  kEnumOutOfRange = -4, kBadType = -5, kBadLevel = -6, kCantStart = -7,
  kNullPtr = -8, kNullEntPtr = -9
}
 Error code enums. More...

Public Member Functions

void fx_update ()
 Update managed FX.
Level methods
bool level_valid (int i=-1) const
 Is the current level valid?
bool level_switch (const int i=0)
 Switch the current level.
bool level_next ()
 Go to the next valid level.
int level_update ()
 Update the current level.
bool level_remove (int i=-1)
 Remove the current level from the game.
int level_count () const
 Return the number of user levels in this game instance.
int level_current ()
 Return the current level.
GameEntity methods
int ge_focus (CGameEntity *pGE)
 Set the current focus entity.
CGameEntityge_focus ()
 Get the current focus entity.
CGameEntityge_ptr (ENTITY *pEnt)
 Get a pointer to any GameEntity associated with the ENTITY* passed in.
CGameEntityge_ptr (const long id)
 Get a GE using its id number.
Level Objects methods
long object_add (ENTITY *pEnt)
 Add an entity object to the current level.
long object_add (CGameEntity *pGE)
 Add a GE to the current level.
bool object_valid (ENTITY *pEnt) const
 Is this a valid GE?
void object_remove (ENTITY *pEnt)
 Remove an entity from the current level.
void object_remove (long id)
 Remove an entity from the current level.
int object_add_cmp (ENTITY *pEnt, int type)
 Add a component to the entity.
int object_cmp_set (ENTITY *pEnt, eCmp cmp, const EDIT_DATA &data)
 Set an entity's property.
int object_set (ENTITY *pEnt, const EDIT_DATA &editData)
 Set an entity's property.
int object_get (ENTITY *pEnt, EDIT_DATA &editData)
 Get a value from an entity.
int object_get (ENTITY *pEnt, eCmp cmpType, EDIT_DATA &editData)
 Get a value from an entity.
int object_get (const long id, EDIT_DATA &editData)
 Get a value from an entity.
int object_act (ENTITY *pEnt, const ACTION_DATA &actData)
 Act on an entity (do damage, activate, etc.).
int object_act (ENTITY *pEnt, eCmp cmpType, const ACTION_DATA &data)
 Act on an entity (do damage, activate, etc.).
bool event_set_data (const T7EVENT_DATA &data)
 \ name Event methods
bool event_get_data (T7EVENT_DATA &data)
 Get event data.
bool event_get_data (T7EVENT_DATA &data, const int event_type)
 Get event data.
Camera methods
bool camera_add (CCameraBase *cam)
 Add a global camera.
bool camera_add (int type)
 Add a global camera.
bool camera_set_target (ENTITY *ent, float x, float y, float z)
 Change the target entity for the cameras.
EntityData methods
int entityData_count ()
 Return the number of base behavior in this game instance.
bool entityData_load (const char *filename, const char *path=NULL)
 Load in the behavior description from a file.
bool entityData_valid (const char *str)
 Is the data named valid?
CGameEntityDataentityData_get (const char *str)
 
Returns:
Pointer to the CGameEntityData keyed to the str, or NULL if none

User Interface methods
bool ui_add (CUi *pUi)
 Add a UI object to this level.
bool ui_add (eUI type)
 Create and add a UI object to this level.
void ui_update ()
 Update the UI.

Static Public Member Functions

Static methods
Can be called directly using CGame::func(..)

static void remove ()
 Remove the current instance.
static bool update ()
 Update the game for one frame.
static bool load (const std::string &filename)
 Load in the game description from a file.

Protected Member Functions

 CGame ()
 Protected constructor (use "instance()" to create).


Detailed Description

Manages all the elements of the game (level, input, network, etc.).

(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 CGame::eError

Error code enums.

Enumerator:
kNoError  No error.
kNoEnt  No entity.
kBadValue  A bad input value.
kCantFindInLevel  Can't find object in level.
kEnumOutOfRange  Value fall outside of enum range.
kBadType  Bad Type.
kBadLevel  Bad level.
kCantStart  Can't start.
kNullPtr  Tried to use a null pointer.
kNullEntPtr  Tried to use a null ENTITY pointer.


Constructor & Destructor Documentation

CGame::CGame (  )  [protected]

Protected constructor (use "instance()" to create).

See also:
instance()


Member Function Documentation

bool CGame::update (  )  [static]

Update the game for one frame.

Returns:
false if there is nothing to update
Note:
Call once a frame.

bool CGame::load ( const std::string &  filename  )  [static]

Load in the game description from a file.

Parameters:
filename Name of the file containing game description
Returns:
true if the load succeeds

bool CGame::level_valid ( int  i = -1  )  const [inline]

Is the current level valid?

Parameters:
i Level to check (default to current level: -1)
Returns:
true if the current level is valid

bool CGame::level_switch ( const int  i = 0  ) 

Switch the current level.

Returns:
false if we couldn't switch

bool CGame::level_next (  ) 

Go to the next valid level.

Returns:
false if there isn't any valid next level.

int CGame::level_update (  ) 

Update the current level.

Returns:
neg on error (see error enum), 1 if okay

bool CGame::level_remove ( int  i = -1  ) 

Remove the current level from the game.

Parameters:
i Level to be removed (default to current level: -1)
Returns:
true if the remove succeeds

int CGame::level_count (  )  const [inline]

Return the number of user levels in this game instance.

Returns:
number of levels

int CGame::level_current (  )  [inline]

Return the current level.

Returns:
current level

int CGame::ge_focus ( CGameEntity pGE  )  [inline]

Set the current focus entity.

Note:
Focus entity is normally under player control and the object cameras are focused on.
Parameters:
pGE Pointer to a Game Entity
Returns:
Error code (eError)
See also:
ge_focus()

CGameEntity* CGame::ge_focus (  )  [inline]

Get the current focus entity.

Returns:
The current game entity under the local player's control.
See also:
ge_focus(CGameEntity* pGE)

CGameEntity* CGame::ge_ptr ( ENTITY *  pEnt  )  [inline]

Get a pointer to any GameEntity associated with the ENTITY* passed in.

Parameters:
pEnt Pointer to ENTITY we are searching for
Returns:
Pointer to associated GameEntity, NULL if none.

CGameEntity* CGame::ge_ptr ( const long  id  )  [inline]

Get a GE using its id number.

Returns:
Pointer to a game entity with the matching id (NULL if none)

long CGame::object_add ( ENTITY *  pEnt  ) 

Add an entity object to the current level.

Parameters:
pEnt Pointer to ENTITY to be added.
Returns:
GameEntity ID if added to level, or negitive number on error.

long CGame::object_add ( CGameEntity pGE  ) 

Add a GE to the current level.

Parameters:
pGE Point to the CGameEntity to be added.
Returns:
GameEntity ID if added to level, or negitive number on error.

bool CGame::object_valid ( ENTITY *  pEnt  )  const

Is this a valid GE?

Parameters:
pEnt Pointer to an ENTITY we are checking for.
Returns:
true if the ENTITY* has an associated GE in this level.

void CGame::object_remove ( ENTITY *  pEnt  ) 

Remove an entity from the current level.

Parameters:
pEnt Pointer to ENTITY to be removed.

void CGame::object_remove ( long  id  ) 

Remove an entity from the current level.

Parameters:
id Game Entity ID of object we want removed.

int CGame::object_add_cmp ( ENTITY *  pEnt,
int  type 
)

Add a component to the entity.

Note:
The entity must already be added to the level (e.g. using entity_add()).
Parameters:
pEnt Pointer to the entity we are adding a new component to.
type The component we are adding (see t7EnityCMP_ list).
Returns:
Less than zero on error, otherwise positive.

int CGame::object_cmp_set ( ENTITY *  pEnt,
eCmp  cmp,
const EDIT_DATA data 
)

Set an entity's property.

Parameters:
pEnt Pointer to ENTITY to be edited.
cmp CMP enum of CMP to be set.
data The data used to preform the action (see EDIT_DATA struct).
Returns:
Less than zero on error, 0 if nothing found, positive otherwise.

int CGame::object_set ( ENTITY *  pEnt,
const EDIT_DATA editData 
)

Set an entity's property.

Parameters:
pEnt Pointer to ENTITY to be edited.
editData The data used to set (see EDIT_DATA struct).
Returns:
Less than zero on error, 0 if nothing found, positive otherwise.

int CGame::object_get ( ENTITY *  pEnt,
EDIT_DATA editData 
)

Get a value from an entity.

Parameters:
pEnt Pointer to ENTITY who's data we are looking at.
editData This will be filled with the requested data (see EDIT_DATA struct).
Returns:
Less than zero on error, 0 if nothing found, positive otherwise.

int CGame::object_get ( ENTITY *  pEnt,
eCmp  cmpType,
EDIT_DATA editData 
)

Get a value from an entity.

Parameters:
pEnt Pointer to ENTITY who's data we are looking at.
cmpType The component we are checking.
editData This will be filled with the requested data (see EDIT_DATA struct).
Returns:
Less than zero on error, 0 if nothing found, positive otherwise.

int CGame::object_get ( const long  id,
EDIT_DATA editData 
)

Get a value from an entity.

Parameters:
id ID number of entity who's data we are looking at.
editData This will be filled with the requested data (see EDIT_DATA struct).
Returns:
Less than zero on error, 0 if nothing found, positive otherwise.

int CGame::object_act ( ENTITY *  pEnt,
const ACTION_DATA actData 
)

Act on an entity (do damage, activate, etc.).

Parameters:
pEnt Pointer to ENTITY to be edited.
actData The data used to preform the action (see ACTION_DATA).
Returns:
Less than zero on error, 0 if no cmp found or cmp does not accept that action, otherwise positive.

int CGame::object_act ( ENTITY *  pEnt,
eCmp  cmpType,
const ACTION_DATA data 
)

Act on an entity (do damage, activate, etc.).

Parameters:
pEnt Pointer to ENTITY to be acted on.
cmpType The component we are looking for.
data The data used to preform the action (see ACTION_DATA).
Returns:
Less than zero on error, 0 if no cmp found or cmp does not accept that action, otherwise positive.

bool CGame::event_set_data ( const T7EVENT_DATA data  ) 

\ name Event methods

Store data for event driven message passing

Parameters:
data Data values for an event (see T7EVENT_DATA)
Returns:
true if data event has been added.

bool CGame::event_get_data ( T7EVENT_DATA data  ) 

Get event data.

Parameters:
data Data values for an event (see T7EVENT_DATA)
Returns:
true if data event has been retrieved.

we've expired

bool CGame::event_get_data ( T7EVENT_DATA data,
const int  event_type 
)

Get event data.

Parameters:
data Data values for an event (see T7EVENT_DATA)
event_type The type of event we are looking for (EVENT_SCAN, EVENT_SHOOT, etc)
Returns:
true if data event has been retrieved.

bool CGame::camera_add ( CCameraBase cam  )  [inline]

Add a global camera.

Parameters:
cam A pointer to a camera object.
Returns:
true if the camera was added

bool CGame::camera_add ( int  type  )  [inline]

Add a global camera.

Parameters:
type Type of camera to be added.
Returns:
true if the camera was added

bool CGame::camera_set_target ( ENTITY *  ent,
float  x,
float  y,
float  z 
) [inline]

Change the target entity for the cameras.

Parameters:
ent A pointer to an ENTITY
x The X offset
y The Y offset
z The Z offset
Returns:
true if the camera target was changed

int CGame::entityData_count (  )  [inline]

Return the number of base behavior in this game instance.

Returns:
number of base behaviors

bool CGame::entityData_load ( const char *  filename,
const char *  path = NULL 
)

Load in the behavior description from a file.

Parameters:
filename Name of the file containing behavior description
path Path to the given file (NULL if path is included in filename)
Returns:
true if the load succeeds

bool CGame::entityData_valid ( const char *  str  ) 

Is the data named valid?

Returns:
true if the name is a a key to valid behavior data
Parameters:
str Name of the entityData we are checking for
Returns:
true if the str is a a key to valid behavior data

bool CGame::ui_add ( CUi pUi  )  [inline]

Add a UI object to this level.

Parameters:
pUi Pointer to a UI object
Returns:
true if the UI is added

bool CGame::ui_add ( eUI  type  )  [inline]

Create and add a UI object to this level.

Parameters:
type Type of UI to create
Returns:
true if the UI is added


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