Cafu Engine
Game.hpp
1 /*
2 =================================================================================
3 This file is part of Cafu, the open-source game engine and graphics engine
4 for multiplayer, cross-platform, real-time 3D action.
5 Copyright (C) 2002-2013 Carsten Fuchs Software.
6 
7 Cafu is free software: you can redistribute it and/or modify it under the terms
8 of the GNU General Public License as published by the Free Software Foundation,
9 either version 3 of the License, or (at your option) any later version.
10 
11 Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with Cafu. If not, see <http://www.gnu.org/licenses/>.
17 
18 For support and more information about Cafu, visit us at <http://www.cafu.de>.
19 =================================================================================
20 */
21 
22 #ifndef CAFU_GAME_GAMEINTERFACE_HPP_INCLUDED
23 #define CAFU_GAME_GAMEINTERFACE_HPP_INCLUDED
24 
25 #include "Templates/Pointer.hpp"
26 
27 #include <map>
28 #include <string>
29 
30 
31 // Forward declarations.
32 class GameEntityI;
33 template<class T> class Vector3T;
34 class ModelManagerT;
35 namespace cf { namespace GameSys { class EntityT; } }
36 namespace cf { namespace GameSys { class GameWorldI; } }
37 namespace cf { namespace SceneGraph { class GenericNodeT; } }
38 namespace cf { namespace TypeSys { class TypeInfoT; } }
39 namespace cf { namespace TypeSys { class TypeInfoManT; } }
40 
41 
42 namespace cf
43 {
44  namespace GameSys
45  {
46  /// The game interface, specified as an ABC so that is can be used without linked (module-local) implementation.
47  /// This interface is implemented by the game DLL, and thus defines the essence of a game/MOD.
48  /// It is used (only) by the engine to run the game.
49  class GameI
50  {
51  public:
52 
53  /// Called to initialize the game.
54  /// This function is called exactly once as the very first function after the game has been loaded,
55  /// not each time a new world is about to be loaded.
56  /// @param AsClient Tells whether we're running as client.
57  /// @param AsServer Tells whether we're running as server.
58  /// @param ModelMan The manager for all models that are used in this game.
59  virtual void Initialize(bool AsClient, bool AsServer, ModelManagerT& ModelMan)=0;
60 
61  /// Called to shutdown the game.
62  /// This function is called exactly once as the very last function before the game is released,
63  /// not each time a world is being freed.
64  virtual void Release()=0;
65 
66 
67  /// Returns the type information manager with the entity hierarchy.
68  virtual const cf::TypeSys::TypeInfoManT& GetEntityTIM() const=0;
69 
70  /// Creates a new entity of the given type.
71  /// @param TI The type of entity to create.
72  /// @param Entity The associated entity in the cf::GameSys::WorldT.
73  /// @param Properties The properties dictionary in the map file of this entity (empty if the entity is created "dynamically"). Contains especially the "classname" key that was used by the caller to determine TI.
74  /// @param RootNode The root node of the scene graph of this entity as defined in the map file. NULL if the entity is created "dynamically".
75  /// @param ID The global unique ID of this entity (in the current map).
76  /// @param GameWorld Pointer to the game world implementation.
77  /// @returns a pointer to the newly created game entity.
78  virtual IntrusivePtrT<GameEntityI> CreateGameEntity(const cf::TypeSys::TypeInfoT* TI, IntrusivePtrT<cf::GameSys::EntityT> Entity, const std::map<std::string, std::string>& Properties,
79  const cf::SceneGraph::GenericNodeT* RootNode, unsigned long ID, cf::GameSys::GameWorldI* GameWorld)=0;
80 
81  /// The virtual destructor, so that derived classes can safely be deleted via a GameI (base class) pointer.
82  virtual ~GameI() { }
83  };
84  }
85 }
86 
87 #endif
virtual const cf::TypeSys::TypeInfoManT & GetEntityTIM() const =0
Returns the type information manager with the entity hierarchy.
This is the interface that the client and server use to access and work with game entities...
Definition: GameEntity.hpp:40
This class represents a polymorphic 3-dimensional vector.
Definition: Game.hpp:33
The game world interface, specified as an ABC so that is can be used without linked (module-local) im...
Definition: GameWorld.hpp:49
virtual void Initialize(bool AsClient, bool AsServer, ModelManagerT &ModelMan)=0
Called to initialize the game.
This class manages the type infos.
Definition: TypeSys.hpp:159
virtual ~GameI()
The virtual destructor, so that derived classes can safely be deleted via a GameI (base class) pointe...
Definition: Game.hpp:82
The game interface, specified as an ABC so that is can be used without linked (module-local) implemen...
Definition: Game.hpp:49
virtual void Release()=0
Called to shutdown the game.
This class is used for managing model instances.
Definition: ModelManager.hpp:46
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:94
Definition: Node.hpp:50
virtual IntrusivePtrT< GameEntityI > CreateGameEntity(const cf::TypeSys::TypeInfoT *TI, IntrusivePtrT< cf::GameSys::EntityT > Entity, const std::map< std::string, std::string > &Properties, const cf::SceneGraph::GenericNodeT *RootNode, unsigned long ID, cf::GameSys::GameWorldI *GameWorld)=0
Creates a new entity of the given type.