SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
TerrainObjectManager.h
1#ifndef TerrainObjectManager_H
2#define TerrainObjectManager_H
3
4#include "AzulCore.h"
5#include <map>
6
7class Terrain;
8using MapKey = std::string const;
9
18class TerrainObjectManager
19{
20private:
21 friend class TerrainObjectManagerAttorney;
22
23 static TerrainObjectManager* ptrInstance;
24
25 TerrainObjectManager();
26 TerrainObjectManager(const TerrainObjectManager&) = delete;
27 TerrainObjectManager& operator=(const TerrainObjectManager&) = delete;
28 ~TerrainObjectManager() = default;
29
30 static TerrainObjectManager& Instance()
31 {
32 if (ptrInstance == nullptr)
33 ptrInstance = new TerrainObjectManager();
34 return *ptrInstance;
35 };
36
40 static void Delete() { Instance().privDelete(); };
41
42 void privDelete();
43 Terrain* privGet(MapKey key);
44 void privLoad(MapKey key, Terrain* t);
45 void privLoad(MapKey key, std::string heightmap, float sideLen, float maxH, float zeroAltitude, std::string tex, float uRep, float vRep);
46
50 std::map<MapKey, Terrain*> storageMap;
51
52public:
56 static const MapKey defaultTerrainKey;
57
64 static Terrain* Get(MapKey key) { return Instance().privGet(key); };
65
72 static void Load(MapKey key, Terrain* t) { Instance().privLoad(key, t); };
73
86 static void Load(MapKey key, std::string heightmap, float sideLen, float maxH, float zeroAltitude, std::string tex, float uRep, float vRep)
87 {
88 Instance().privLoad(key, heightmap, sideLen, maxH, zeroAltitude, tex, uRep, vRep);
89 };
90};
91
92#endif
Represents a 3D terrain generated from a heightmap.
Definition Terrain.h:18
static void Delete()
Deletes all managed Terrain objects and the singleton instance.
Definition TerrainObjectManager.h:40
static Terrain * Get(MapKey key)
Retrieves a Terrain object by its key.
Definition TerrainObjectManager.h:64
static void Load(MapKey key, std::string heightmap, float sideLen, float maxH, float zeroAltitude, std::string tex, float uRep, float vRep)
Loads a Terrain object from parameters.
Definition TerrainObjectManager.h:86
static const MapKey defaultTerrainKey
Default key for the default Terrain.
Definition TerrainObjectManager.h:56
static void Load(MapKey key, Terrain *t)
Loads a Terrain object directly.
Definition TerrainObjectManager.h:72
std::map< MapKey, Terrain * > storageMap
Map storing Terrain objects associated with their keys.
Definition TerrainObjectManager.h:50