#include "utility.h"
#include "exceptions.h"
#include "serialization.h"
+#include "tile.h"
// Size of node in rendering units
#define BS 10
enum Content
{
- CONTENT_STONE=0,
-
- CONTENT_GRASS=1,
-
- CONTENT_WATER=2,
-
- CONTENT_LIGHT=3,
-
- CONTENT_TREE=4,
-
- CONTENT_LEAVES=5,
-
- CONTENT_GRASS_FOOTSTEPS=6,
-
- CONTENT_MESE=7,
-
- CONTENT_MUD=8,
-
- CONTENT_OCEAN=9,
+ CONTENT_STONE,
+ CONTENT_GRASS,
+ CONTENT_WATER,
+ CONTENT_TORCH,
+ CONTENT_TREE,
+ CONTENT_LEAVES,
+ CONTENT_GRASS_FOOTSTEPS,
+ CONTENT_MESE,
+ CONTENT_MUD,
+ CONTENT_OCEAN,
+ CONTENT_CLOUD,
// This is set to the number of the actual values in this enum
USEFUL_CONTENT_COUNT
};
+extern u16 g_content_tiles[USEFUL_CONTENT_COUNT][6];
+extern const char * g_content_inventory_textures[USEFUL_CONTENT_COUNT];
+
/*
If true, the material allows light propagation and brightness is stored
in param.
*/
inline bool light_propagates_content(u8 m)
{
- return (m == CONTENT_AIR || m == CONTENT_LIGHT || m == CONTENT_WATER || m == CONTENT_OCEAN);
+ return (m == CONTENT_AIR || m == CONTENT_TORCH || m == CONTENT_WATER || m == CONTENT_OCEAN);
}
/*
*/
inline bool sunlight_propagates_content(u8 m)
{
- return (m == CONTENT_AIR || m == CONTENT_LIGHT);
+ return (m == CONTENT_AIR || m == CONTENT_TORCH);
}
/*
*/
inline u8 content_solidness(u8 m)
{
- if(m == CONTENT_AIR)
+ // As of now, every pseudo node like torches are added to this
+ if(m == CONTENT_AIR || m == CONTENT_TORCH)
return 0;
if(m == CONTENT_WATER || m == CONTENT_OCEAN)
return 1;
// Objects collide with walkable contents
inline bool content_walkable(u8 m)
{
- return (m != CONTENT_AIR && m != CONTENT_WATER && m != CONTENT_OCEAN && m != CONTENT_LIGHT);
+ return (m != CONTENT_AIR && m != CONTENT_WATER && m != CONTENT_OCEAN && m != CONTENT_TORCH);
}
// A liquid resists fast movement
return (m == CONTENT_AIR || m == CONTENT_WATER || m == CONTENT_OCEAN);
}
-/*
- TODO: Make a mapper class for mapping every side of a content
- to some tile.
- This dumbily maps all sides of content to the tile of the same id.
-*/
-inline u8 content_tile(u8 c)
-{
- if(c == CONTENT_IGNORE || c == CONTENT_LIGHT)
- return CONTENT_AIR;
- return c;
-}
-
/*
Returns true for contents that form the base ground that
follows the main heightmap
);
}
+/*inline bool content_has_faces(u8 c)
+{
+ return (m != CONTENT_IGNORE
+ && m != CONTENT_AIR
+ && m != CONTENT_TORCH);
+}*/
+
/*
Nodes make a face if contents differ and solidness differs.
Return value:
inline bool liquid_replaces_content(u8 c)
{
- return (c == CONTENT_AIR || c == CONTENT_LIGHT);
+ return (c == CONTENT_AIR || c == CONTENT_TORCH);
}
/*
*/
inline bool content_directional(u8 c)
{
- return (c == CONTENT_LIGHT);
+ return (c == CONTENT_TORCH);
}
/*
return d;
}
+inline u16 content_tile(u8 c, v3s16 dir)
+{
+ if(c == CONTENT_IGNORE || c == CONTENT_AIR
+ || c >= USEFUL_CONTENT_COUNT)
+ return TILE_NONE;
+
+ s32 dir_i = -1;
+
+ if(dir == v3s16(0,1,0))
+ dir_i = 0;
+ else if(dir == v3s16(0,-1,0))
+ dir_i = 1;
+ else if(dir == v3s16(1,0,0))
+ dir_i = 2;
+ else if(dir == v3s16(-1,0,0))
+ dir_i = 3;
+ else if(dir == v3s16(0,0,1))
+ dir_i = 4;
+ else if(dir == v3s16(0,0,-1))
+ dir_i = 5;
+
+ /*if(dir_i == -1)
+ return TILE_NONE;*/
+ assert(dir_i != -1);
+
+ return g_content_tiles[c][dir_i];
+}
+
struct MapNode
{
// Content
/*
Note that a block that isn't light_propagates() can be a light source.
*/
- if(d == CONTENT_LIGHT)
+ if(d == CONTENT_TORCH)
return LIGHT_MAX;
return 0;
// If not transparent, can't set light
if(light_propagates() == false)
return;
- param = a_light;
+ param &= 0xf0;
+ param |= a_light;
+ }
+
+ u16 getTile(v3s16 dir)
+ {
+ return content_tile(d, dir);
}
/*