]> git.lizzy.rs Git - minetest.git/blob - src/materials.h
inventorycube: use all three specified textures; also moved mesh creation / modificat...
[minetest.git] / src / materials.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MATERIALS_HEADER
21 #define MATERIALS_HEADER
22
23 /*
24         Material properties
25 */
26
27 #include "common_irrlicht.h"
28 #include <string>
29 #include <iostream>
30
31 enum Diggability
32 {
33         DIGGABLE_NOT,
34         DIGGABLE_NORMAL,
35         DIGGABLE_CONSTANT
36 };
37
38 struct MaterialProperties
39 {
40         // Values can be anything. 0 is normal.
41         
42         enum Diggability diggability;
43
44         // Constant time for DIGGABLE_CONSTANT
45         float constant_time;
46
47         // Weight; the amount of stuff in the block. Not realistic.
48         float weight;
49         // Rock; wood a bit.
50         // A Pickaxe manages high crackiness well.
51         float crackiness;
52         // Sand is extremely crumble; dirt is quite crumble.
53         // A shovel is good for crumbly stuff. Pickaxe is horrible.
54         float crumbliness;
55         // An axe is best for cuttable heavy stuff.
56         // Sword is best for cuttable light stuff.
57         float cuttability;
58         // If high, ignites easily
59         float flammability;
60
61         MaterialProperties():
62                 diggability(DIGGABLE_NOT),
63                 constant_time(0.5),
64                 weight(0),
65                 crackiness(0),
66                 crumbliness(0),
67                 cuttability(0),
68                 flammability(0)
69         {}
70
71         void serialize(std::ostream &os);
72         void deSerialize(std::istream &is);
73 };
74
75 struct DiggingProperties
76 {
77         bool diggable;
78         // Digging time in seconds
79         float time;
80         // Caused wear
81         u16 wear;
82
83         DiggingProperties(bool a_diggable=false, float a_time=0, u16 a_wear=0):
84                 diggable(a_diggable),
85                 time(a_time),
86                 wear(a_wear)
87         {}
88 };
89
90 struct ToolDiggingProperties;
91 class INodeDefManager;
92
93 DiggingProperties getDiggingProperties(const MaterialProperties *mp,
94                 const ToolDiggingProperties *tp, float time_from_last_punch);
95
96 DiggingProperties getDiggingProperties(const MaterialProperties *mp,
97                 const ToolDiggingProperties *tp);
98
99 DiggingProperties getDiggingProperties(u16 content,
100                 const ToolDiggingProperties *tp, INodeDefManager *nodemgr);
101
102 struct HittingProperties
103 {
104         s16 hp;
105         s16 wear;
106
107         HittingProperties(s16 hp_=0, s16 wear_=0):
108                 hp(hp_),
109                 wear(wear_)
110         {}
111 };
112
113 HittingProperties getHittingProperties(const MaterialProperties *mp,
114                 const ToolDiggingProperties *tp, float time_from_last_punch);
115
116 #endif
117