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
85
86
87
88
89
90
91
92
|
#include "materials.h"
#define MATERIAL_PROPERTIES_COUNT 256
// These correspond to the CONTENT_* constants
MaterialProperties g_material_properties[MATERIAL_PROPERTIES_COUNT];
bool g_material_properties_initialized = false;
void setStoneLikeDiggingProperties(u8 material, float toughness)
{
g_material_properties[material].setDiggingProperties("",
DiggingProperties(true, 15.0*toughness, 0));
g_material_properties[material].setDiggingProperties("WPick",
DiggingProperties(true, 1.3*toughness, 65535./30.*toughness));
g_material_properties[material].setDiggingProperties("STPick",
DiggingProperties(true, 0.65*toughness, 65535./100.*toughness));
/*g_material_properties[material].setDiggingProperties("MesePick",
DiggingProperties(true, 0.0*toughness, 65535./20.*toughness));*/
}
void initializeMaterialProperties()
{
/*
Now, the g_material_properties array is already initialized
by the constructors to such that no digging is possible.
Add some digging properties to them.
*/
setStoneLikeDiggingProperties(CONTENT_STONE, 1.0);
g_material_properties[CONTENT_GRASS].setDiggingProperties("",
DiggingProperties(true, 0.4, 0));
g_material_properties[CONTENT_TORCH].setDiggingProperties("",
DiggingProperties(true, 0.0, 0));
g_material_properties[CONTENT_TREE].setDiggingProperties("",
DiggingProperties(true, 1.5, 0));
g_material_properties[CONTENT_LEAVES].setDiggingProperties("",
DiggingProperties(true, 0.35, 0));
g_material_properties[CONTENT_GRASS_FOOTSTEPS].setDiggingProperties("",
DiggingProperties(true, 0.5, 0));
setStoneLikeDiggingProperties(CONTENT_MESE, 0.5);
g_material_properties[CONTENT_MUD].setDiggingProperties("",
DiggingProperties(true, 0.4, 0));
setStoneLikeDiggingProperties(CONTENT_COALSTONE, 1.5);
g_material_properties[CONTENT_WOOD].setDiggingProperties("",
DiggingProperties(true, 1.0, 0));
g_material_properties[CONTENT_SAND].setDiggingProperties("",
DiggingProperties(true, 0.4, 0));
setStoneLikeDiggingProperties(CONTENT_FURNACE, 1.0);
/*
Add MesePick to everything
*/
for(u16 i=0; i<MATERIAL_PROPERTIES_COUNT; i++)
{
g_material_properties[i].setDiggingProperties("MesePick",
DiggingProperties(true, 0.0, 65535./1337));
}
g_material_properties_initialized = true;
}
MaterialProperties * getMaterialProperties(u8 material)
{
assert(g_material_properties_initialized);
return &g_material_properties[material];
}
DiggingProperties getDiggingProperties(u8 material, const std::string &tool)
{
MaterialProperties *mprop = getMaterialProperties(material);
if(mprop == NULL)
// Not diggable
return DiggingProperties();
return mprop->getDiggingProperties(tool);
}
|