4 #include "../../Blocks/BlockDoor.h"
38 const bool IsTop = (a_Meta & 0x8) == 0x8;
39 const auto TopPosition = IsTop ? a_Position : a_Position.
addedY(1);
61 const auto OppositeHalfPosition = a_Position + (IsTop ?
OffsetYM :
OffsetYP);
68 const bool ShouldBeOpen =
Power != 0;
69 const bool PreviouslyPowered = (TopMeta & 0x2) == 0x2;
73 if (ShouldBeOpen == PreviouslyPowered)
81 a_Chunk.
SetMeta(TopPosition, TopMeta | 0x2);
85 a_Chunk.
SetMeta(TopPosition, TopMeta & ~0x2);
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
@ SFX_RANDOM_WOODEN_DOOR_OPEN
constexpr Vector3i OffsetYP
constexpr std::array< Vector3i, 6 > RelativeAdjacents
constexpr Vector3i OffsetYM
void InvokeForAdjustedRelatives(ForEachSourceCallback &Callback, const Vector3i Position, const ArrayType &Relative)
unsigned char Power(const BlockState Block)
static PowerLevel GetPowerDeliveredToPosition(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)
static void ForValidSourcePositions(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback &Callback)
static void Update(cChunk &a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PowerLevel Power)
static void SetOpen(cChunkInterface &a_ChunkInterface, const Vector3i a_BlockPos, bool a_Open)
Sets the door to the specified state.
static bool IsOpen(cChunkInterface &a_ChunkInterface, const Vector3i a_BlockPos)
Returns true iff the door at the specified coords is open.
static bool IsDoorBlockType(BLOCKTYPE a_Block)
Returns true if the specified blocktype is any kind of door.
cChunkCoords GetPos() const
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
cWorld * GetWorld(void) const
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
static Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition, cChunkCoords a_ChunkCoords)
Converts relative block coordinates into absolute coordinates with a known chunk location.
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
cChunkMap * GetChunkMap(void)