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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-05 06:27:14 -04:00
|
|
|
class cBlockWallSignHandler final :
|
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;
|
|
|
|
|
|
|
|
private:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2021-03-28 09:41:34 -04:00
|
|
|
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
|
2014-07-17 20:19:30 -04:00
|
|
|
{
|
2021-05-05 09:25:10 -04:00
|
|
|
auto NeighborPos = a_Position + GetOffsetBehindTheSign(a_Meta);
|
2020-04-21 16:19:22 -04:00
|
|
|
BLOCKTYPE NeighborType;
|
|
|
|
if (!a_Chunk.UnboundedRelGetBlockType(NeighborPos, NeighborType))
|
|
|
|
{
|
|
|
|
// The neighbor is not accessible (unloaded chunk), bail out without changing this
|
|
|
|
return true;
|
|
|
|
}
|
2021-05-05 09:25:10 -04:00
|
|
|
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
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|