-
Notifications
You must be signed in to change notification settings - Fork 0
/
Material.h
84 lines (69 loc) · 1.33 KB
/
Material.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
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
class Material
{
char short_name;
std::string name;
float speed_factor;
const sf::Image* image;
public:
Material():
speed_factor(0.0),
image(0)
{
}
Material(const std::string& name, char short_name, float speed_factor, const sf::Image* image):
short_name(short_name),
name(name),
speed_factor(speed_factor),
image(image)
{
}
float GetSpeedFactor()
{
return speed_factor;
}
char GetShortName() const
{
return short_name;
}
std::string GetName() const
{
return name;
}
const sf::Image* GetImage() const
{
return image;
}
};
class MaterialManager
{
std::map<std::string, Material> db_material;
std::map<char, Material> db_short_material;
public:
void Add(const Material& mat)
{
db_material[mat.GetName()] = mat;
db_short_material[mat.GetShortName()] = mat;
}
Material GetByName(const std::string& name) const
{
std::map<std::string, Material>::const_iterator it = db_material.find(name);
if(it != db_material.end())
{
return it->second;
}
throw std::runtime_error("bla");
}
Material GetByShortName(char short_name) const
{
std::map<char, Material>::const_iterator it = db_short_material.find(short_name);
if(it != db_short_material.end())
{
return it->second;
}
throw std::runtime_error("bla");
}
};
/*
Material CreateMaterial(MATERIAL_TYPE mt);
*/