Move tool stuff to tool.{h,cpp}
[oweals/minetest.git] / src / materials.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010 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
30 enum Diggability
31 {
32         DIGGABLE_NOT,
33         DIGGABLE_NORMAL,
34         DIGGABLE_CONSTANT
35 };
36
37 struct MaterialProperties
38 {
39         // Values can be anything. 0 is normal.
40         
41         enum Diggability diggability;
42
43         // Constant time for DIGGABLE_CONSTANT
44         float constant_time;
45
46         // Weight; the amount of stuff in the block. Not realistic.
47         float weight;
48         // Rock; wood a bit.
49         // A Pickaxe manages high crackiness well.
50         float crackiness;
51         // Sand is extremely crumble; dirt is quite crumble.
52         // A shovel is good for crumbly stuff. Pickaxe is horrible.
53         float crumbliness;
54         // An axe is best for cuttable heavy stuff.
55         // Sword is best for cuttable light stuff.
56         float cuttability;
57         // If high, ignites easily
58         //float flammability;
59
60         MaterialProperties():
61                 diggability(DIGGABLE_NOT),
62                 constant_time(0.5),
63                 weight(1),
64                 crackiness(1),
65                 crumbliness(1),
66                 cuttability(1)
67         {}
68 };
69
70 struct DiggingProperties
71 {
72         DiggingProperties():
73                 diggable(false),
74                 time(0.0),
75                 wear(0)
76         {
77         }
78         DiggingProperties(bool a_diggable, float a_time, u16 a_wear):
79                 diggable(a_diggable),
80                 time(a_time),
81                 wear(a_wear)
82         {
83         }
84         bool diggable;
85         // Digging time in seconds
86         float time;
87         // Caused wear
88         u16 wear;
89 };
90
91 // Tool "" is bare hands
92 DiggingProperties getDiggingProperties(u16 material, const std::string &tool);
93
94 #endif
95