Completely generalized mesh generation; ContentFeatures serialization
[oweals/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(1),
65                 crackiness(1),
66                 crumbliness(1),
67                 cuttability(1)
68         {}
69
70         void serialize(std::ostream &os);
71         void deSerialize(std::istream &is);
72 };
73
74 struct DiggingProperties
75 {
76         DiggingProperties():
77                 diggable(false),
78                 time(0.0),
79                 wear(0)
80         {
81         }
82         DiggingProperties(bool a_diggable, float a_time, u16 a_wear):
83                 diggable(a_diggable),
84                 time(a_time),
85                 wear(a_wear)
86         {
87         }
88         bool diggable;
89         // Digging time in seconds
90         float time;
91         // Caused wear
92         u16 wear;
93 };
94
95 class ToolDiggingProperties;
96 class INodeDefManager;
97
98 DiggingProperties getDiggingProperties(u16 content, ToolDiggingProperties *tp,
99                 INodeDefManager *nodemgr);
100
101 #endif
102