Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
AssetCache.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <map>
5 #include <string>
6 #include <vector>
7 
8 #include "../../Config.hpp"
9 #include "AssetTypes.hpp"
10 #include "TextureReader.hpp"
11 
17 {
18 public:
23  {
24  static AssetCache instance;
25  return instance;
26  }
27 
31  void loadAssets();
32 
37  std::map<std::string, MapAreaAssetData>& getAreaAssetData();
38 
45 
52 
58  const ItemAssetData& getItemAssetDataById(int id);
59 
64  std::map<std::string, ImageData>& getTextureAssetData();
65 
71 
76  std::map<int, ItemAssetData>& getItemAssetData();
77 
78 private:
81  void operator=(AssetCache const&);
82 
89  std::map<int, ObjectAssetData> loadGameObjectAssetData(const GameObjects& gameObjects);
90 
96  std::map<int, CharacterAssetData> loadCharacterAssetData(const GameCharacters& gameCharacters);
97 
104  std::map<std::string, MapAreaAssetData> loadAreaAssetData(const std::vector<std::vector<std::string>>& areaMap);
105 
111  std::map<int, ItemAssetData> loadItemAssetData(const GameItems& gameItems);
112 
113  std::map<std::string, MapAreaAssetData> areaAssetDataM;
114  std::map<int, ObjectAssetData> objectAssetDataM;
115  std::map<int, CharacterAssetData> characterAssetDataM;
116  std::map<int, ItemAssetData> itemAssetDataM;
117  std::map<std::string, ImageData> textureAssetDataM;
119 };
Loads all of the assets into memory (objects, textures, etc.).
Definition: AssetCache.hpp:17
std::map< int, ItemAssetData > itemAssetDataM
Definition: AssetCache.hpp:116
std::map< int, ItemAssetData > & getItemAssetData()
Get item asset data map.
Definition: AssetCache.cpp:39
ImageData defaultTextureM
Definition: AssetCache.hpp:118
std::map< std::string, MapAreaAssetData > loadAreaAssetData(const std::vector< std::vector< std::string >> &areaMap)
Loads the map area assets data.
Definition: AssetCache.cpp:160
std::map< std::string, MapAreaAssetData > areaAssetDataM
Definition: AssetCache.hpp:113
AssetCache(AssetCache const &)
std::map< std::string, ImageData > textureAssetDataM
Definition: AssetCache.hpp:117
void operator=(AssetCache const &)
const ItemAssetData & getItemAssetDataById(int id)
Returns the item asset data by type id.
Definition: AssetCache.cpp:54
std::map< std::string, ImageData > & getTextureAssetData()
Returns the map of texture asset data.
Definition: AssetCache.cpp:59
void loadAssets()
Loads all the assets into memory.
Definition: AssetCache.cpp:8
const ObjectAssetData & getObjectAssetDataById(int id)
Returns the object asset data by type id.
Definition: AssetCache.cpp:44
ImageData getDefaultTexture()
Get default texture.
Definition: AssetCache.cpp:287
std::map< int, ObjectAssetData > objectAssetDataM
Definition: AssetCache.hpp:114
AssetCache()
Definition: AssetCache.hpp:79
std::map< int, ItemAssetData > loadItemAssetData(const GameItems &gameItems)
Loads the item assets data.
Definition: AssetCache.cpp:226
std::map< std::string, MapAreaAssetData > & getAreaAssetData()
Returns the map of area asset data.
Definition: AssetCache.cpp:34
std::map< int, CharacterAssetData > characterAssetDataM
Definition: AssetCache.hpp:115
std::map< int, ObjectAssetData > loadGameObjectAssetData(const GameObjects &gameObjects)
Loads the game object assets data.
Definition: AssetCache.cpp:72
const CharacterAssetData & getCharacterAssetDataById(int id)
Returns the character asset data by type id.
Definition: AssetCache.cpp:49
static AssetCache & getInstance()
Returns the singleton instance of the AssetCache.
Definition: AssetCache.hpp:22
std::map< int, CharacterAssetData > loadCharacterAssetData(const GameCharacters &gameCharacters)
Loads the character assets data.
Definition: AssetCache.cpp:119
Contains asset data loaded into memory for a specific character.
Definition: AssetTypes.hpp:41
Contains all the character data. This is used to load character assets into memory and spawn characte...
Definition: CharacterReader.hpp:62
Contains all the item data in the game. This is used to load item assets into memory and create item ...
Definition: ItemReader.hpp:87
Contains all the objects defined in the objects.json file.
Definition: ObjectReader.hpp:101
Definition: BasicTypes.hpp:161
Contains asset data loaded into memory for a specific item.
Definition: AssetTypes.hpp:54
Contains asset data loaded into memory for a specific object.
Definition: AssetTypes.hpp:30