Leviathan  0.8.0.0
Leviathan game engine
GameWorldFactory.cpp
Go to the documentation of this file.
1 // ------------------------------------ //
2 #include "GameWorldFactory.h"
3 
4 #include "Generated/StandardWorld.h"
5 using namespace Leviathan;
6 // ------------------------------------ //
8 {
9  LEVIATHAN_ASSERT(StaticInstance == nullptr, "Multiple GameWorldFactories created");
10  StaticInstance = this;
11 }
12 
14 {
15  StaticInstance = nullptr;
16 }
17 
19 
21 {
22  return StaticInstance;
23 }
24 // ------------------------------------ //
25 DLLEXPORT std::shared_ptr<GameWorld> GameWorldFactory::CreateNewWorld(int worldtype,
26  const std::shared_ptr<PhysicsMaterialManager>& physicsMaterials, int overrideid /*= -1*/)
27 {
28  if(worldtype != 0)
29  LOG_WARNING("Standard GameWorldFactory: worldtype is not 0");
30 
31  return std::make_shared<StandardWorld>(physicsMaterials);
32 }
33 // ------------------------------------ //
34 // InbuiltWorldFactory
35 std::shared_ptr<GameWorld> InbuiltWorldFactory::CreateNewWorld(INBUILT_WORLD_TYPE worldtype,
36  const std::shared_ptr<PhysicsMaterialManager>& physicsMaterials, int overrideid /*= -1*/)
37 {
38  switch(worldtype) {
40  return std::make_shared<StandardWorld>(physicsMaterials, overrideid);
41  }
42 
43  return nullptr;
44 }
#define LOG_WARNING(x)
Definition: Define.h:89
static DLLEXPORT GameWorldFactory * Get()
INBUILT_WORLD_TYPE
Types of inbuilt world types.
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:98
Allows overwriting the used GameWorld class in the engine. By default creates a StandardWorld.
static DLLEXPORT GameWorldFactory * StaticInstance
Global instance. Overwrite this in child class constructors.
#define DLLEXPORT
Definition: Include.h:84
virtual DLLEXPORT std::shared_ptr< GameWorld > CreateNewWorld(int worldtype, const std::shared_ptr< PhysicsMaterialManager > &physicsMaterials, int overrideid=-1)
Creates a new world that can be used.
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
static std::shared_ptr< GameWorld > CreateNewWorld(INBUILT_WORLD_TYPE worldtype, const std::shared_ptr< PhysicsMaterialManager > &physicsMaterials, int overrideid=-1)