ASR::Game Class Reference

#include <Game.h>

Collaboration diagram for ASR::Game:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Game (SceneManager *sceneMgr, RenderWindow *win)
 ~Game ()
SceneManager * getSceneManager () const
 Grab the SceneManager.
LevelcreateLevel ()
 Start up a new level.
LevelgetLevel () const
 Retrieves the current level.
void destroyLevel ()
 Destroys the current level.
void addUpdater (Updater *updater)
 Registers a new Updater with the system.

Static Public Member Functions

static GamegetSingleton (void)
 Override standard Singleton retrieval.
static GamegetSingletonPtr (void)
 Override standard Singleton retrieval.

Private Attributes

LevelmLevel
GameListenermListener
SceneManager * mSceneMgr
RenderWindow * mWindow

Detailed Description

Definition at line 20 of file Game.h.


Constructor & Destructor Documentation

ASR::Game::Game ( SceneManager *  sceneMgr,
RenderWindow *  win 
)

Definition at line 20 of file Game.cpp.

References mLevel, and mListener.

00021                 : mSceneMgr ( sceneMgr ), mWindow ( win )
00022         {
00023                 mLevel = NULL;
00024                 mListener = NULL;
00025         }

ASR::Game::~Game (  ) 

Definition at line 29 of file Game.cpp.

References destroyLevel().

00030         {
00031                 destroyLevel ();
00032         }


Member Function Documentation

void ASR::Game::addUpdater ( Updater updater  ) 

Registers a new Updater with the system.

Updaters are called in the order they are added

Definition at line 96 of file Game.cpp.

References ASR::GameListener::addUpdater(), and mListener.

Referenced by ASR::Client::createCamera(), ASR::Client::createTeam(), and ASR::Team::Team().

00097         {
00098                 OgreAssert ( mListener != NULL, "Listener has not been created - Game::addUpdater" );
00099                 mListener->addUpdater ( updater );
00100         }

Level * ASR::Game::createLevel (  ) 

Start up a new level.

Definition at line 47 of file Game.cpp.

References mLevel, mListener, and mWindow.

Referenced by TutorialApplication::chooseSceneManager().

00048         {
00049                 if ( mLevel != NULL )
00050                         throw Exception ( Exception::ERR_DUPLICATE_ITEM, "Level already created", "Game::createLevel" );
00051 
00052                 if ( mListener != NULL )
00053                         throw Exception ( Exception::ERR_DUPLICATE_ITEM, "There is already an existing Listener", "Game::createLevel" );
00054 
00055                 mListener = new GameListener ( mWindow );
00056                 Ogre::Root::getSingleton().addFrameListener( mListener );
00057 
00058                 mLevel = new Level ();
00059                 return mLevel;
00060         }

void ASR::Game::destroyLevel (  ) 

Destroys the current level.

Definition at line 81 of file Game.cpp.

References mLevel, and mListener.

Referenced by ~Game().

00082         {
00083                 if ( mLevel == NULL )
00084                         throw Exception ( Exception::ERR_ITEM_NOT_FOUND, "Level does not exist", "Game::getLevel" );
00085 
00086                 Ogre::Root::getSingleton().removeFrameListener ( mListener );
00087                 delete mListener;
00088                 mListener = NULL;
00089 
00090                 delete mLevel;
00091                 mLevel = NULL;
00092         }

Level * ASR::Game::getLevel (  )  const

Retrieves the current level.

Definition at line 71 of file Game.cpp.

References mLevel.

00072         {
00073                 if ( mLevel == NULL )
00074                         throw Exception ( Exception::ERR_ITEM_NOT_FOUND, "Level does not exist", "Game::getLevel" );
00075 
00076                 return mLevel;
00077         }

SceneManager * ASR::Game::getSceneManager (  )  const

Grab the SceneManager.

Definition at line 64 of file Game.cpp.

References mSceneMgr.

Referenced by ASR::Projectile::_destroyEntity(), ASR::Projectile::_generateEntity(), ASR::UnitSelecter::_selectUnits(), ASR::Building::Building(), ASR::TeamBuildings::TeamBuildings(), ASR::TeamUnits::TeamUnits(), ASR::UnitSelecter::UnitSelecter(), ASR::TeamUnits::~TeamUnits(), and ASR::UnitSelecter::~UnitSelecter().

00065         {
00066                 return mSceneMgr;
00067         }

Game & ASR::Game::getSingleton ( void   )  [static]

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Definition at line 40 of file Game.cpp.

Referenced by ASR::Client::_createGUI(), ASR::Projectile::_destroyEntity(), ASR::Projectile::_generateEntity(), ASR::Client::createCamera(), ASR::Client::createTeam(), ASR::Team::Team(), and ASR::UnitSelecter::UnitSelecter().

00041         {
00042                 assert( ms_Singleton );  return ( *ms_Singleton );
00043         }

Game * ASR::Game::getSingletonPtr ( void   )  [static]

Override standard Singleton retrieval.

Remarks:
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Definition at line 36 of file Game.cpp.

Referenced by ASR::UnitSelecter::_selectUnits(), ASR::Building::Building(), ASR::TeamBuildings::TeamBuildings(), ASR::TeamUnits::TeamUnits(), ASR::TeamUnits::~TeamUnits(), and ASR::UnitSelecter::~UnitSelecter().

00037         {
00038                 return ms_Singleton;
00039         }


Member Data Documentation

Level* ASR::Game::mLevel [private]

Definition at line 25 of file Game.h.

Referenced by createLevel(), destroyLevel(), Game(), and getLevel().

GameListener* ASR::Game::mListener [private]

Definition at line 26 of file Game.h.

Referenced by addUpdater(), createLevel(), destroyLevel(), and Game().

SceneManager* ASR::Game::mSceneMgr [private]

Definition at line 28 of file Game.h.

Referenced by getSceneManager().

RenderWindow* ASR::Game::mWindow [private]

Definition at line 29 of file Game.h.

Referenced by createLevel().


The documentation for this class was generated from the following files:
Generated on Sun Jun 25 19:23:43 2006 for Valors End by  doxygen 1.4.7