Implementing the game rules interface
Now that we know the basic workings of the game rules system, we can give creating a custom IGameRules
implementation a shot.
Note
Before we start, consider whether you actually need a custom IGameRules
implementation for your game. The default GameDLL that ships with CGameRules
, is an IGameRules
implementation specialized for
First-Person Shooters (FPS). If your game premise is similar to a FPS, or if you can reuse existing functionality that might be preferrable to writing an implementation from scratch.
To start, we'll need to create two new files; GameRules.cpp
and GameRules.h
.When you're done, open GameRules.h
and create a new class. We'll be naming ours as CGameRules
.
After the class is in place, we have to derive from IGameRules
. As we mentioned before, game rules are handled as game object extensions. We'll therefore have to use the CGameObjectExtensionHelper
template class:
class CGameRules : public CGameObjectExtensionHelper<CGameRules, IGameRules...