]> git.lizzy.rs Git - dragonfireclient.git/blob - src/tile.h
c35c27e6457257f5240abd02871a48437b64d2bd
[dragonfireclient.git] / src / tile.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 TILE_HEADER
21 #define TILE_HEADER
22
23 #include "common_irrlicht.h"
24 #include "utility.h"
25
26 // TileID is supposed to be stored in a u16
27
28 enum TileID
29 {
30         TILE_NONE, // Nothing shown
31         TILE_STONE,
32         TILE_WATER,
33         TILE_GRASS,
34         TILE_TREE,
35         TILE_LEAVES,
36         TILE_GRASS_FOOTSTEPS,
37         TILE_MESE,
38         TILE_MUD,
39         TILE_TREE_TOP,
40         TILE_MUD_WITH_GRASS,
41         TILE_CLOUD,
42         TILE_COALSTONE,
43         TILE_WOOD,
44         
45         // Count of tile ids
46         TILES_COUNT
47 };
48
49 enum TileSpecialFeature
50 {
51         TILEFEAT_NONE,
52         TILEFEAT_CRACK,
53 };
54
55 struct TileCrackParam
56 {
57         bool operator==(TileCrackParam &other)
58         {
59                 return progression == other.progression;
60         }
61
62         u16 progression;
63 };
64
65 struct TileSpec
66 {
67         TileSpec()
68         {
69                 id = TILE_NONE;
70                 feature = TILEFEAT_NONE;
71         }
72
73         bool operator==(TileSpec &other)
74         {
75                 if(id != other.id)
76                         return false;
77                 if(feature != other.feature)
78                         return false;
79                 if(feature == TILEFEAT_NONE)
80                         return true;
81                 if(feature == TILEFEAT_CRACK)
82                 {
83                         return param.crack == other.param.crack;
84                 }
85                 // Invalid feature
86                 assert(0);
87                 return false;
88         }
89
90         u16 id; // Id in g_tile_materials, TILE_NONE=none
91         enum TileSpecialFeature feature;
92         union
93         {
94                 TileCrackParam crack;
95         } param;
96 };
97
98 /*extern const char * g_tile_texture_paths[TILES_COUNT];
99 extern video::SMaterial g_tile_materials[TILES_COUNT];*/
100
101 /*
102         Functions
103 */
104
105 const char * tile_texture_path_get(u32 i);
106
107 // Initializes g_tile_materials
108 void tile_materials_preload(IrrlichtWrapper *irrlicht);
109
110 video::SMaterial & tile_material_get(u32 i);
111
112 #endif