-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathGroundMaterialConfiguration.h
71 lines (60 loc) · 1.96 KB
/
GroundMaterialConfiguration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include "tinyxml.h"
#include "MaterialMatcher.h"
struct OverridingMaterial {
int gameID;
t_SpriteWithOffset sprite;
};
class TerrainMaterialConfiguration
{
private:
std::vector<std::pair<c_sprite, int>> defaultSprite;
std::vector<std::map<int, std::pair<c_sprite, int>> > overridingMaterials;
public:
TerrainMaterialConfiguration();
void updateSprite(int j, c_sprite& sprite, int x);
void updateOverridingMaterials(auto j, auto subtypeId, auto sprite, auto x);
c_sprite& getSprite(int idx)
{
return defaultSprite[idx].first;
}
c_sprite& getOverridingMaterial(int idx, auto material, auto terrain)
{
auto it = overridingMaterials[idx].find(material.index);
if (it != overridingMaterials[idx].end()) {
return (it->second.first);
}
if (defaultSprite[idx].first.get_sheetindex() != UNCONFIGURED_INDEX) {
return (defaultSprite[idx].first);
}
auto it2 = overridingMaterials[0].find(material.index);
if (it2 != overridingMaterials[0].end()) {
return (it2->second.first);
}
if (defaultSprite[0].first.get_sheetindex() != UNCONFIGURED_INDEX) {
return (defaultSprite[0].first);
}
return (terrain->getDefaultSprite(0));
}
};
class TerrainConfiguration
{
private:
std::unordered_map<int, std::unique_ptr<TerrainMaterialConfiguration>> terrainMaterials;
std::vector<std::pair<c_sprite, int>> defaultSprite;
public:
TerrainConfiguration();
void updateSprite(auto j, auto sprite, auto x);
void expand(auto elemIndex);
auto& getTerrainMaterials(int idx)
{
return terrainMaterials[idx];
}
c_sprite& getDefaultSprite(auto idx)
{
return defaultSprite[idx].first;
}
};
bool addSingleTerrainConfig( TiXmlElement* elemRoot);
void flushTerrainConfig(std::vector<std::unique_ptr<TerrainConfiguration>>& config);
void DumpInorganicMaterialNamesToDisk();