Nebula
Loading...
Searching...
No Matches
Game::GameServer Class Reference

#include <gameserver.h>

Detailed Description

The game server setups and runs the game world.

Functionality and queries on the game world are divided amongst several FeaturesUnits. This keeps the game server's interface small and clean, and lets applications easily extend functionality by implementing new, or deriving from existing game features.

To add or replace FeatureUnit objects, derive from Game::FeatureUnit and add your features on application start or gamestatehandler enter.

The GameServer triggers all attached features. Start and Stop is called within the gamestatehandler to allow all features do stuff after everything is loaded and initialized. Load and Save is invoked from the BaseGameFeature which allows beginning a new game, load or save a game.

Inherits Core::RefCounted.

Classes

struct  State
 contains internal state and world management More...
 

Protected Attributes

bool isOpen
 
bool isStarted
 
Util::CommandLineArgs args
 
Util::Array< Ptr< FeatureUnit > > gameFeatures
 

Private Member Functions

virtual __DeclareClass(GameServer) __DeclareSingleton(GameServer) public ~GameServer ()
 destructor
 
virtual bool Open ()
 Initialize the game server object.
 
virtual bool Start ()
 Start the game world, called after loading has completed.
 
virtual void Stop ()
 Stop the game world.
 
virtual void Close ()
 Close the game server object.
 
bool HasStarted () const
 has the game world already started
 
virtual void OnBeginFrame ()
 trigger actions before rendering the game world
 
virtual void OnFrame ()
 trigger the game world
 
virtual void OnEndFrame ()
 trigger actions after rendering the game world
 
virtual void NotifyBeforeLoad ()
 call OnBeforeLoad on all game features
 
virtual void NotifyBeforeCleanup ()
 call OnBeforeCleanup on all game features
 
virtual void NotifyGameLoad ()
 call OnLoad on all game features
 
virtual void NotifyGameSave ()
 call OnSave on all game features
 
void RenderDebug ()
 call when debug gui and primitives are up for rendering
 
void AttachGameFeature (const Ptr< FeatureUnit > &feature)
 add game feature
 
void RemoveGameFeature (const Ptr< FeatureUnit > &feature)
 remove game feature
 
bool IsFeatureAttached (const Util::String &stringName) const
 is feature attached
 
Util::Array< Ptr< FeatureUnit > > const & GetGameFeatures () const
 access to all attached features units
 
void SetCmdLineArgs (const Util::CommandLineArgs &a)
 set command line args
 
const Util::CommandLineArgsGetCmdLineArgs () const
 get command line args
 
virtual void SetupEmptyWorld (World *)
 setup an empty game world
 
virtual void CleanupWorld (World *)
 cleanup the game world
 
WorldCreateWorld (WorldHash hash)
 create a world. The game server handles all worlds
 
WorldGetWorld (WorldHash worldHash)
 get a world by hash
 
WorldGetWorld (WorldId id)
 get a world by WorldId
 
void DestroyWorld (WorldHash worldHash)
 destroy a world
 

Private Attributes

struct Game::GameServer::State state
 

Additional Inherited Members

- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 
- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Constructor & Destructor Documentation

◆ ~GameServer()

Game::GameServer::~GameServer ( )
privatevirtual

destructor

Member Function Documentation

◆ AttachGameFeature()

void Game::GameServer::AttachGameFeature ( const Ptr< FeatureUnit > & feature)
private

add game feature

◆ CleanupWorld()

void Game::GameServer::CleanupWorld ( World * world)
privatevirtual

cleanup the game world

Cleanup the game world.

This should undo the stuff in SetupWorld(). Override this method in a subclass if your app needs different behaviour.

◆ Close()

void Game::GameServer::Close ( )
privatevirtual

Close the game server object.

◆ CreateWorld()

World * Game::GameServer::CreateWorld ( WorldHash hash)
private

create a world. The game server handles all worlds

◆ DestroyWorld()

void Game::GameServer::DestroyWorld ( WorldHash worldHash)
private

destroy a world

Note
The world index does not get recycled.
Todo
The world index should probably be recycled.

◆ GetCmdLineArgs()

const Util::CommandLineArgs & Game::GameServer::GetCmdLineArgs ( ) const
inlineprivate

get command line args

◆ GetGameFeatures()

Util::Array< Ptr< FeatureUnit > > const & Game::GameServer::GetGameFeatures ( ) const
private

access to all attached features units

◆ GetWorld() [1/2]

World * Game::GameServer::GetWorld ( WorldHash worldHash)
private

get a world by hash

◆ GetWorld() [2/2]

World * Game::GameServer::GetWorld ( WorldId id)
private

get a world by WorldId

◆ HasStarted()

bool Game::GameServer::HasStarted ( ) const
private

has the game world already started

◆ IsFeatureAttached()

bool Game::GameServer::IsFeatureAttached ( const Util::String & stringName) const
private

is feature attached

◆ NotifyBeforeCleanup()

void Game::GameServer::NotifyBeforeCleanup ( )
privatevirtual

call OnBeforeCleanup on all game features

◆ NotifyBeforeLoad()

void Game::GameServer::NotifyBeforeLoad ( )
privatevirtual

call OnBeforeLoad on all game features

◆ NotifyGameLoad()

void Game::GameServer::NotifyGameLoad ( )
privatevirtual

call OnLoad on all game features

◆ NotifyGameSave()

void Game::GameServer::NotifyGameSave ( )
privatevirtual

call OnSave on all game features

◆ OnBeginFrame()

void Game::GameServer::OnBeginFrame ( )
privatevirtual

trigger actions before rendering the game world

◆ OnEndFrame()

void Game::GameServer::OnEndFrame ( )
privatevirtual

trigger actions after rendering the game world

◆ OnFrame()

void Game::GameServer::OnFrame ( )
privatevirtual

trigger the game world

Trigger the game server.

If your application introduces new or different manager objects, you may also want to override the Game::GameServer::Trigger() method if those gameFeatures need per-frame callbacks.

◆ Open()

bool Game::GameServer::Open ( )
privatevirtual

Initialize the game server object.

◆ RemoveGameFeature()

void Game::GameServer::RemoveGameFeature ( const Ptr< FeatureUnit > & feature)
private

remove game feature

◆ RenderDebug()

void Game::GameServer::RenderDebug ( )
private

call when debug gui and primitives are up for rendering

◆ SetCmdLineArgs()

void Game::GameServer::SetCmdLineArgs ( const Util::CommandLineArgs & a)
inlineprivate

set command line args

◆ SetupEmptyWorld()

void Game::GameServer::SetupEmptyWorld ( World * world)
privatevirtual

setup an empty game world

Setup a new, empty world.

◆ Start()

bool Game::GameServer::Start ( )
privatevirtual

Start the game world, called after loading has completed.

◆ Stop()

void Game::GameServer::Stop ( )
privatevirtual

Stop the game world.

Member Data Documentation

◆ args

Util::CommandLineArgs Game::GameServer::args
protected

◆ gameFeatures

Util::Array<Ptr<FeatureUnit> > Game::GameServer::gameFeatures
protected

◆ isOpen

bool Game::GameServer::isOpen
protected

◆ isStarted

bool Game::GameServer::isStarted
protected

◆ state

struct Game::GameServer::State Game::GameServer::state
private

The documentation for this class was generated from the following files: