2015-06-26 22:24:51 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "RedstoneHandler.h"
|
2018-08-29 00:51:25 +00:00
|
|
|
#include "../../Blocks/BlockDoor.h"
|
2015-06-26 22:24:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-26 13:15:00 +00:00
|
|
|
class cDoorHandler final : public cRedstoneHandler
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2020-07-26 13:15:00 +00:00
|
|
|
virtual unsigned char GetPowerDeliveredToPosition(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
2020-07-26 13:15:00 +00:00
|
|
|
UNUSED(a_Chunk);
|
2015-06-26 22:24:51 +00:00
|
|
|
UNUSED(a_Position);
|
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
UNUSED(a_QueryPosition);
|
|
|
|
UNUSED(a_QueryBlockType);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-26 13:15:00 +00:00
|
|
|
virtual void Update(cChunk & a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
2015-12-24 15:57:45 +00:00
|
|
|
// LOGD("Evaluating dori the door (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
|
2015-06-26 22:24:51 +00:00
|
|
|
|
2020-07-26 13:15:00 +00:00
|
|
|
cChunkInterface ChunkInterface(a_Chunk.GetWorld()->GetChunkMap());
|
|
|
|
const bool ShouldBeOpen = a_PoweringData.PowerLevel != 0;
|
|
|
|
const auto AbsolutePosition = cChunkDef::RelativeToAbsolute(a_Position, a_Chunk.GetPos());
|
|
|
|
const bool IsOpen = cBlockDoorHandler::IsOpen(ChunkInterface, AbsolutePosition);
|
|
|
|
|
|
|
|
if (ShouldBeOpen != IsOpen)
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
2020-07-26 13:15:00 +00:00
|
|
|
cBlockDoorHandler::SetOpen(ChunkInterface, AbsolutePosition, ShouldBeOpen);
|
|
|
|
a_Chunk.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_WOODEN_DOOR_OPEN, AbsolutePosition, 0);
|
2015-06-26 22:24:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-26 13:15:00 +00:00
|
|
|
virtual void ForValidSourcePositions(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, SourceCallback Callback) const override
|
2015-06-26 22:24:51 +00:00
|
|
|
{
|
2020-07-26 13:15:00 +00:00
|
|
|
UNUSED(a_Chunk);
|
2015-06-26 22:24:51 +00:00
|
|
|
UNUSED(a_BlockType);
|
|
|
|
UNUSED(a_Meta);
|
2020-07-26 13:15:00 +00:00
|
|
|
InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
|
2015-06-26 22:24:51 +00:00
|
|
|
}
|
|
|
|
};
|