2014-06-28 15:44:34 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
2019-10-16 04:06:34 -04:00
|
|
|
#include "Mixins.h"
|
2014-06-28 15:44:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockTripwireHookHandler :
|
2019-10-16 04:06:34 -04:00
|
|
|
public cMetaRotator<cClearMetaOnDrop<cBlockHandler>, 0x03, 0x02, 0x03, 0x00, 0x01>
|
2014-06-28 15:44:34 -04:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cMetaRotator<cClearMetaOnDrop<cBlockHandler>, 0x03, 0x02, 0x03, 0x00, 0x01>;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2014-06-28 15:44:34 -04:00
|
|
|
public:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
using Super::Super;
|
|
|
|
|
|
|
|
inline static eBlockFace MetadataToDirection(NIBBLETYPE a_Meta)
|
2014-06-28 15:44:34 -04:00
|
|
|
{
|
2020-09-20 09:50:52 -04:00
|
|
|
switch (a_Meta & 0x03)
|
|
|
|
{
|
|
|
|
case 0x1: return BLOCK_FACE_XM;
|
|
|
|
case 0x3: return BLOCK_FACE_XP;
|
|
|
|
case 0x2: return BLOCK_FACE_ZM;
|
|
|
|
case 0x0: return BLOCK_FACE_ZP;
|
|
|
|
default: ASSERT(!"Unhandled tripwire hook metadata!"); return BLOCK_FACE_NONE;
|
|
|
|
}
|
2014-06-28 15:44:34 -04:00
|
|
|
}
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
private:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2014-06-28 15:44:34 -04:00
|
|
|
virtual bool GetPlacementBlockTypeMeta(
|
2020-04-21 16:19:22 -04:00
|
|
|
cChunkInterface & a_ChunkInterface,
|
|
|
|
cPlayer & a_Player,
|
|
|
|
const Vector3i a_PlacedBlockPos,
|
|
|
|
eBlockFace a_ClickedBlockFace,
|
|
|
|
const Vector3i a_CursorPos,
|
2014-06-28 15:44:34 -04:00
|
|
|
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
2020-09-20 09:50:52 -04:00
|
|
|
) const override
|
2014-06-28 15:44:34 -04:00
|
|
|
{
|
|
|
|
a_BlockType = m_BlockType;
|
|
|
|
|
2020-07-25 15:29:55 -04:00
|
|
|
switch (a_ClickedBlockFace)
|
2014-06-28 15:44:34 -04:00
|
|
|
{
|
2020-07-25 15:29:55 -04:00
|
|
|
case BLOCK_FACE_XM:
|
|
|
|
{
|
|
|
|
a_BlockMeta = 0x1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case BLOCK_FACE_XP:
|
|
|
|
{
|
|
|
|
a_BlockMeta = 0x3;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case BLOCK_FACE_ZM:
|
|
|
|
{
|
|
|
|
a_BlockMeta = 0x2;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case BLOCK_FACE_ZP:
|
|
|
|
{
|
|
|
|
a_BlockMeta = 0x0;
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-19 07:28:31 -04:00
|
|
|
case BLOCK_FACE_NONE:
|
|
|
|
case BLOCK_FACE_YM:
|
|
|
|
case BLOCK_FACE_YP:
|
|
|
|
{
|
2020-07-25 15:29:55 -04:00
|
|
|
return false;
|
2015-05-19 07:28:31 -04:00
|
|
|
}
|
2014-06-28 15:44:34 -04:00
|
|
|
}
|
2020-07-25 15:29:55 -04:00
|
|
|
|
2018-02-04 18:07:12 -05:00
|
|
|
UNREACHABLE("Unsupported block face");
|
2014-06-28 15:44:34 -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-06-28 15:44:34 -04:00
|
|
|
{
|
2020-07-25 15:29:55 -04:00
|
|
|
const auto Meta = a_Chunk.GetMeta(a_RelPos);
|
|
|
|
const auto RearPosition = AddFaceDirection(a_RelPos, MetadataToDirection(Meta), true);
|
|
|
|
|
|
|
|
BLOCKTYPE NeighborBlockType;
|
|
|
|
if (!a_Chunk.UnboundedRelGetBlockType(RearPosition, NeighborBlockType))
|
2020-04-21 16:19:22 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-25 15:29:55 -04:00
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
return cBlockInfo::FullyOccupiesVoxel(NeighborBlockType);
|
2014-06-28 15:44:34 -04:00
|
|
|
}
|
2015-06-30 10:50:15 -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 0;
|
|
|
|
}
|
2014-06-28 15:44:34 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|