Cafu Engine
GameWorld.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_GAMESYS_GAMEWORLD_INTERFACE_HPP_INCLUDED
23 #define CAFU_GAMESYS_GAMEWORLD_INTERFACE_HPP_INCLUDED
24 
25 #include "Math3D/BoundingBox.hpp"
26 #include "Templates/Pointer.hpp"
27 
28 #include <map>
29 
30 
31 class CafuModelT;
32 class GameEntityI;
33 class PhysicsWorldT;
34 namespace cf { namespace ClipSys { class ClipWorldT; } }
35 namespace cf { namespace GameSys { class GameI; } }
36 namespace cf { namespace GuiSys { class GuiResourcesT; } }
37 namespace cf { class UniScriptStateT; }
38 
39 
40 namespace cf
41 {
42  namespace GameSys
43  {
44  /// The game world interface, specified as an ABC so that is can be used without linked (module-local) implementation.
45  /// The engine provides each entity that it creates with a pointer to an implementation of this interface
46  /// (as entities can be created on the client and the server side, there can be more than one implementation).
47  /// See the GameI::CreateGameEntityFrom*() methods for the "source" of these pointers:
48  /// When one of these methods is called, a pointer to a GameWorldI is one of the parameters.
49  class GameWorldI
50  {
51  public:
52 
53  /// The virtual destructor, so that derived classes can safely be deleted via a GameWorldI (base class) pointer.
54  /// However, with GameWorldIs that's never supposed to happen, so this destructor only exists to silence the g++ compiler warning.
55  virtual ~GameWorldI() { }
56 
57  /// Returns the game that this is a world of.
58  virtual cf::GameSys::GameI* GetGame()=0;
59 
60  /// Returns the clip world for the game world.
62 
63  /// Returns the physics world for the game world.
64  virtual PhysicsWorldT& GetPhysicsWorld()=0;
65 
66  /// Returns a "good" ambient light color for an arbitrary object (i.e. a model) of size Dimensions at Origin.
67  /// The return value is derived from the worlds lightmap information "close" to the Dimensions at Origin.
68  virtual Vector3fT GetAmbientLightColorFromBB(const BoundingBox3T<double>& Dimensions, const VectorT& Origin) const=0;
69 
70  /// Returns (a reference to) an array that contains the IDs of all entities that currently exist in the world.
71  virtual const ArrayT<unsigned long>& GetAllEntityIDs() const=0;
72 
73  /// Returns a pointer to the entity with ID 'EntityID'.
74  /// NULL is returned if that entity does not exist.
75  virtual IntrusivePtrT<GameEntityI> GetGameEntityByID(unsigned long EntityID) const=0;
76 
77  /// Removes the entity identified by 'EntityID' from the (server) world.
78  virtual void RemoveEntity(unsigned long EntityID)=0;
79 
80  /// Returns a model for the given filename.
81  /// The returned model instance is managed by the GameWorldI implementation in a ModelManagerT,
82  /// thus the caller does not have to (and if fact, must not) delete the CafuModelT instance.
83  virtual const CafuModelT* GetModel(const std::string& FileName) const=0;
84 
85  /// Returns the GUI resources that are commonly used in this game world.
86  virtual cf::GuiSys::GuiResourcesT& GetGuiResources() const=0;
87  };
88  }
89 }
90 
91 #endif
virtual const ArrayT< unsigned long > & GetAllEntityIDs() const =0
Returns (a reference to) an array that contains the IDs of all entities that currently exist in the w...
This class represents a native Cafu model.
Definition: Model_cmdl.hpp:60
Definition: PhysicsWorld.hpp:173
This is the interface that the client and server use to access and work with game entities...
Definition: GameEntity.hpp:40
virtual const CafuModelT * GetModel(const std::string &FileName) const =0
Returns a model for the given filename.
The game world interface, specified as an ABC so that is can be used without linked (module-local) im...
Definition: GameWorld.hpp:49
virtual ~GameWorldI()
The virtual destructor, so that derived classes can safely be deleted via a GameWorldI (base class) p...
Definition: GameWorld.hpp:55
The game interface, specified as an ABC so that is can be used without linked (module-local) implemen...
Definition: Game.hpp:49
virtual void RemoveEntity(unsigned long EntityID)=0
Removes the entity identified by 'EntityID' from the (server) world.
virtual cf::GameSys::GameI * GetGame()=0
Returns the game that this is a world of.
virtual cf::GuiSys::GuiResourcesT & GetGuiResources() const =0
Returns the GUI resources that are commonly used in this game world.
virtual cf::ClipSys::ClipWorldT & GetClipWorld()=0
Returns the clip world for the game world.
The clip world manages all the clip models that exist in a world (their "union"). ...
Definition: ClipWorld.hpp:42
virtual Vector3fT GetAmbientLightColorFromBB(const BoundingBox3T< double > &Dimensions, const VectorT &Origin) const =0
Returns a "good" ambient light color for an arbitrary object (i.e.
virtual IntrusivePtrT< GameEntityI > GetGameEntityByID(unsigned long EntityID) const =0
Returns a pointer to the entity with ID 'EntityID'.
virtual PhysicsWorldT & GetPhysicsWorld()=0
Returns the physics world for the game world.
This class manages and provides resources (fonts and models) for GuiImplT instances.
Definition: GuiResources.hpp:41