2012-06-14 09:06:06 -04:00
|
|
|
|
2012-08-10 16:42:59 -04:00
|
|
|
#pragma once
|
2012-06-14 09:06:06 -04:00
|
|
|
#include "Vector3i.h"
|
2012-08-10 16:42:59 -04:00
|
|
|
#include "Defines.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
class cTorch // tolua_export
|
|
|
|
{ // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
public:
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
static char DirectionToMetaData( char a_Direction ) // tolua_export
|
|
|
|
{ // tolua_export
|
2012-08-10 16:42:59 -04:00
|
|
|
switch (a_Direction)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2013-01-11 23:46:01 -05:00
|
|
|
case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this face"); return 0;
|
2012-08-10 16:42:59 -04:00
|
|
|
case BLOCK_FACE_TOP: return E_META_TORCH_FLOOR;
|
|
|
|
case BLOCK_FACE_EAST: return E_META_TORCH_EAST;
|
|
|
|
case BLOCK_FACE_WEST: return E_META_TORCH_WEST;
|
|
|
|
case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH;
|
|
|
|
case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
ASSERT(!"Unhandled torch direction!");
|
|
|
|
break;
|
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
};
|
|
|
|
return 0x0;
|
2013-01-11 23:46:01 -05:00
|
|
|
} // tolua_export
|
2012-08-10 16:42:59 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
static char MetaDataToDirection(char a_MetaData) // tolua_export
|
|
|
|
{ // tolua_export
|
2012-08-10 16:42:59 -04:00
|
|
|
switch (a_MetaData)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2012-08-14 11:53:05 -04:00
|
|
|
case 0: return BLOCK_FACE_TOP; // by default, the torches stand on the ground
|
2012-08-10 16:42:59 -04:00
|
|
|
case E_META_TORCH_FLOOR: return BLOCK_FACE_TOP;
|
|
|
|
case E_META_TORCH_EAST: return BLOCK_FACE_EAST;
|
|
|
|
case E_META_TORCH_WEST: return BLOCK_FACE_WEST;
|
|
|
|
case E_META_TORCH_NORTH: return BLOCK_FACE_NORTH;
|
|
|
|
case E_META_TORCH_SOUTH: return BLOCK_FACE_SOUTH;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
ASSERT(!"Unhandled torch metadata");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2013-01-11 23:46:01 -05:00
|
|
|
} // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2012-08-10 16:42:59 -04:00
|
|
|
|
|
|
|
static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2012-08-10 16:42:59 -04:00
|
|
|
switch (a_TorchMeta)
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2012-08-10 16:42:59 -04:00
|
|
|
case 0x0:
|
|
|
|
case E_META_TORCH_FLOOR: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 1, 0)));
|
|
|
|
case E_META_TORCH_EAST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, -1)));
|
|
|
|
case E_META_TORCH_WEST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, 1)));
|
|
|
|
case E_META_TORCH_NORTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(-1, 0, 0)));
|
|
|
|
case E_META_TORCH_SOUTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(1, 0, 0)));
|
|
|
|
default:
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
2012-08-10 16:42:59 -04:00
|
|
|
ASSERT(!"Unhandled torch meta!");
|
|
|
|
break;
|
2012-06-14 09:06:06 -04:00
|
|
|
}
|
2012-08-10 16:42:59 -04:00
|
|
|
}
|
2012-06-14 09:06:06 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
} ; // tolua_export
|
2012-08-10 16:42:59 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|