3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
20 #ifndef MAPNODE_CONTENTFEATURES_HEADER
21 #define MAPNODE_CONTENTFEATURES_HEADER
23 #include "common_irrlicht.h"
33 Used for determining properties of MapNodes by content type without
34 storing such properties in the nodes itself.
38 Initialize content feature table.
40 Must be called before accessing the table.
42 void init_contentfeatures();
49 // Direction for chests and furnaces and such
63 struct ContentFeatures
76 video::ITexture *inventory_texture;
78 // Used currently for flowing liquids
80 // Post effect color, drawn when the camera is inside the node.
81 video::SColor post_effect_color;
82 // Special irrlicht material, used sometimes
83 video::SMaterial *special_material;
84 video::SMaterial *special_material2;
85 AtlasPointer *special_atlas;
88 // List of all block textures that have been used (value is dummy)
89 // Used for texture atlas making.
90 // Exists on server too for cleaner code in content_mapnode.cpp.
91 core::map<std::string, bool> used_texturenames;
93 // Type of MapNode::param1
94 ContentParamType param_type;
95 // True for all ground-like things like stone and mud, false for eg. trees
96 bool is_ground_content;
97 bool light_propagates;
98 bool sunlight_propagates;
99 u8 solidness; // Used when choosing which face is drawn
100 u8 visual_solidness; // When solidness=0, this tells how it looks like
101 // This is used for collision detection.
102 // Also for general solidness queries.
104 // Player can point to these
106 // Player can dig these
108 // Player can climb these
110 // Player can build on these
112 // If true, param2 is set to direction when placed. Used for torches.
113 // NOTE: the direction format is quite inefficient and should be changed
115 // If true, node is equivalent to air. Torches are, air is. Water is not.
116 // Is used for example to check whether a mud block can have grass on.
118 // Whether this content type often contains mineral.
119 // Used for texture atlas creation.
120 // Currently only enabled for CONTENT_STONE.
121 bool often_contains_mineral;
123 // Inventory item string as which the node appears in inventory when dug.
124 // Mineral overrides this.
125 std::string dug_item;
127 // Extra dug item and its rarity
128 std::string extra_dug_item;
129 s32 extra_dug_item_rarity;
131 // Initial metadata is cloned from this
132 NodeMetadata *initial_metadata;
134 // Whether the node is non-liquid, source liquid or flowing liquid
135 enum LiquidType liquid_type;
136 // If the content is liquid, this is the flowing version of the liquid.
137 content_t liquid_alternative_flowing;
138 // If the content is liquid, this is the source version of the liquid.
139 content_t liquid_alternative_source;
140 // Viscosity for fluid flow, ranging from 1 to 7, with
141 // 1 giving almost instantaneous propagation and 7 being
142 // the slowest possible
145 // Amount of light the node emits
148 // Digging properties for different tools
149 DiggingPropertiesList digging_properties;
151 u32 damage_per_second;
153 // NOTE: Move relevant properties to here from elsewhere
158 inventory_texture = NULL;
161 post_effect_color = video::SColor(0, 0, 0, 0);
162 special_material = NULL;
163 special_material2 = NULL;
164 special_atlas = NULL;
166 param_type = CPT_NONE;
167 is_ground_content = false;
168 light_propagates = false;
169 sunlight_propagates = false;
171 visual_solidness = 0;
176 buildable_to = false;
177 wall_mounted = false;
178 air_equivalent = false;
179 often_contains_mineral = false;
181 initial_metadata = NULL;
182 liquid_type = LIQUID_NONE;
183 liquid_alternative_flowing = CONTENT_IGNORE;
184 liquid_alternative_source = CONTENT_IGNORE;
185 liquid_viscosity = 0;
187 digging_properties.clear();
188 damage_per_second = 0;
199 Quickhands for simple materials
203 void setTexture(u16 i, std::string name, u8 alpha=255)
205 void setAllTextures(std::string name, u8 alpha=255)
208 void setTexture(u16 i, std::string name, u8 alpha=255);
210 void setAllTextures(std::string name, u8 alpha=255)
212 for(u16 i=0; i<6; i++)
214 setTexture(i, name, alpha);
216 // Force inventory texture too
217 setInventoryTexture(name);
222 void setTile(u16 i, const TileSpec &tile)
226 void setAllTiles(const TileSpec &tile)
228 for(u16 i=0; i<6; i++)
236 void setInventoryTexture(std::string imgname)
238 void setInventoryTextureCube(std::string top,
239 std::string left, std::string right)
242 void setInventoryTexture(std::string imgname);
244 void setInventoryTextureCube(std::string top,
245 std::string left, std::string right);
250 Call this to access the ContentFeature list
252 ContentFeatures & content_features(content_t i);
253 ContentFeatures & content_features(MapNode &n);
256 Here is a bunch of DEPRECATED functions.
260 If true, the material allows light propagation and brightness is stored
262 NOTE: Don't use, use "content_features(m).whatever" instead
264 inline bool light_propagates_content(content_t m)
266 return content_features(m).light_propagates;
269 If true, the material allows lossless sunlight propagation.
270 NOTE: It doesn't seem to go through torches regardlessly of this
271 NOTE: Don't use, use "content_features(m).whatever" instead
273 inline bool sunlight_propagates_content(content_t m)
275 return content_features(m).sunlight_propagates;
278 On a node-node surface, the material of the node with higher solidness
283 NOTE: Don't use, use "content_features(m).whatever" instead
285 inline u8 content_solidness(content_t m)
287 return content_features(m).solidness;
289 // Objects collide with walkable contents
290 // NOTE: Don't use, use "content_features(m).whatever" instead
291 inline bool content_walkable(content_t m)
293 return content_features(m).walkable;
295 // NOTE: Don't use, use "content_features(m).whatever" instead
296 inline bool content_liquid(content_t m)
298 return content_features(m).liquid_type != LIQUID_NONE;
300 // NOTE: Don't use, use "content_features(m).whatever" instead
301 inline bool content_flowing_liquid(content_t m)
303 return content_features(m).liquid_type == LIQUID_FLOWING;
305 // NOTE: Don't use, use "content_features(m).whatever" instead
306 inline bool content_liquid_source(content_t m)
308 return content_features(m).liquid_type == LIQUID_SOURCE;
310 // CONTENT_WATER || CONTENT_WATERSOURCE -> CONTENT_WATER
311 // CONTENT_LAVA || CONTENT_LAVASOURCE -> CONTENT_LAVA
312 // NOTE: Don't use, use "content_features(m).whatever" instead
313 inline content_t make_liquid_flowing(content_t m)
315 u8 c = content_features(m).liquid_alternative_flowing;
316 assert(c != CONTENT_IGNORE);
319 // Pointable contents can be pointed to in the map
320 // NOTE: Don't use, use "content_features(m).whatever" instead
321 inline bool content_pointable(content_t m)
323 return content_features(m).pointable;
325 // NOTE: Don't use, use "content_features(m).whatever" instead
326 inline bool content_diggable(content_t m)
328 return content_features(m).diggable;
330 // NOTE: Don't use, use "content_features(m).whatever" instead
331 inline bool content_buildable_to(content_t m)
333 return content_features(m).buildable_to;