2014-07-17 20:19:30 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-07-18 11:04:01 -04:00
|
|
|
#include "BlockHandler.h"
|
2018-08-28 20:51:25 -04:00
|
|
|
#include "../Chunk.h"
|
2014-07-17 20:19:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
class cBlockWallSignHandler:
|
2014-07-18 11:04:01 -04:00
|
|
|
public cBlockHandler
|
2014-07-17 20:19:30 -04:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cBlockHandler;
|
2014-07-18 16:41:48 -04:00
|
|
|
|
2014-07-17 20:19:30 -04:00
|
|
|
public:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
using Super::Super;
|
|
|
|
|
|
|
|
/** Converts the block face of the neighbor to which the wallsign is attached to the wallsign block's meta. */
|
|
|
|
static NIBBLETYPE BlockFaceToMetaData(eBlockFace a_NeighborBlockFace)
|
2014-07-17 20:19:30 -04:00
|
|
|
{
|
2020-09-20 09:50:52 -04:00
|
|
|
switch (a_NeighborBlockFace)
|
|
|
|
{
|
|
|
|
case BLOCK_FACE_ZM: return 0x02;
|
|
|
|
case BLOCK_FACE_ZP: return 0x03;
|
|
|
|
case BLOCK_FACE_XM: return 0x04;
|
|
|
|
case BLOCK_FACE_XP: return 0x05;
|
|
|
|
case BLOCK_FACE_NONE:
|
|
|
|
case BLOCK_FACE_YP:
|
|
|
|
case BLOCK_FACE_YM:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0x02;
|
2014-07-17 20:19:30 -04:00
|
|
|
}
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
private:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-23 11:06:27 -04:00
|
|
|
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
2014-07-18 11:04:01 -04:00
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
return cItem(E_ITEM_SIGN, 1, 0);
|
2014-07-18 11:04:01 -04:00
|
|
|
}
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, const Vector3i a_RelPos, const cChunk & a_Chunk) const override
|
2014-07-17 20:19:30 -04:00
|
|
|
{
|
2020-04-21 16:19:22 -04:00
|
|
|
auto NeighborPos = a_RelPos + GetOffsetBehindTheSign(a_Chunk.GetMeta(a_RelPos));
|
|
|
|
BLOCKTYPE NeighborType;
|
|
|
|
if (!a_Chunk.UnboundedRelGetBlockType(NeighborPos, NeighborType))
|
|
|
|
{
|
|
|
|
// The neighbor is not accessible (unloaded chunk), bail out without changing this
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return ((NeighborType == E_BLOCK_WALLSIGN) || (NeighborType == E_BLOCK_SIGN_POST) || cBlockInfo::IsSolid(NeighborType));
|
2014-07-17 20:19:30 -04:00
|
|
|
}
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
/** Returns the offset from the sign coords to the block to which the wallsign is attached, based on the wallsign's block meta.
|
|
|
|
Asserts / returns a zero vector on wrong meta. */
|
|
|
|
static Vector3i GetOffsetBehindTheSign(NIBBLETYPE a_BlockMeta)
|
2014-07-17 20:19:30 -04:00
|
|
|
{
|
|
|
|
switch (a_BlockMeta)
|
|
|
|
{
|
2020-04-21 16:19:22 -04:00
|
|
|
case 2: return Vector3i( 0, 0, 1);
|
|
|
|
case 3: return Vector3i( 0, 0, -1);
|
|
|
|
case 4: return Vector3i( 1, 0, 0);
|
|
|
|
case 5: return Vector3i(-1, 0, 0);
|
2014-07-17 20:19:30 -04:00
|
|
|
}
|
2020-04-21 16:19:22 -04:00
|
|
|
ASSERT(!"Invalid wallsign block meta");
|
|
|
|
return Vector3i();
|
2014-07-17 20:19:30 -04:00
|
|
|
}
|
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
|
2015-06-30 10:50:15 -04:00
|
|
|
{
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
return 13;
|
|
|
|
}
|
2014-07-17 20:19:30 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|