Extending the system

From IrrWizard

Jump to: navigation, search

Contents

Introduction

Extending the system by overriding classes. These should be created in the 'game' folder.

Extending the GameManager

The CGameManager is the centre of the universe when it comes to using the framework, everything goes through it. Therefore the first area of customisation, or extending the system specifc to your game would be to create a game specific version inheriting from it.

This will allow new managers, (areas of functionality) to be added in the 'game' folder and any future releases to be added without overriting any game specific code that may have been added to the CGameManager. Create a class in the 'game' folder that extends CGameManager. This will be your base to work from.

header:

//////////////////////////////////////////////////////////////////////
///
/// ClientGameManager.h: interface for the CClientGameManager class.
///
//////////////////////////////////////////////////////////////////////
 
#if !defined(AFX_ClientGameManager_INCLUDED_)
#define AFX_ClientGameManager_INCLUDED_

#include "../core/GameManager.h"
class CClientGameManager : public CGameManager
{
public:
CClientGameManager();
virtual ~CClientGameManager();
protected:
private:
};
#endif

source:

///////////////////////////////////////////////////////////////////////////////////
///
/// Name: ClientGameManager.cpp
/// Author: Paul Rowland (area51)
/// Desc: Game specific implementation of the GameManager. New Managers should
/// be added here. 
///
///////////////////////////////////////////////////////////////////////////////////
 
#include "ClientGameManager.h"
     
//! Default constructor
CClientGameManager::CClientGameManager()
{
}
//! Default destructor
CClientGameManager::~CClientGameManager()
{
}

This new CClientGameManager can now be used in the CGame header file instead of the normal CGameManager.

CGame.h:

////////////////////////////////////////////////////////////////////// 
///
/// Game.h: interface for the CGame class.
///
//////////////////////////////////////////////////////////////////////
  
#ifndef __C_GAME_H_INCLUDED__
#define __C_GAME_H_INCLUDED__
 
#include <irrlicht.h>
#include "ClientGameManager.h"
using namespace irr;
//! Main entry point to game
class CGame 
{
public:
CGame();
bool run();
private:
CClientGameManager m_GameManager;
};
#endif

Comiple and run...

Modifying an existing Manager

The simplest way to modify an existing manager, ie CGameFXManager is to just edit or add new functions to it directly. As discussed previously, this will make taking later releases harder to integrate.

The safest, and recomended way is to extend the required manager by adding a game specific version in the 'game' folder, and then modify that.

Adding a new Manager

Extending an existing State

Adding a new State

Personal tools