summaryrefslogtreecommitdiffstats
path: root/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h52
1 files changed, 15 insertions, 37 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h b/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h
index a22a6ff50..c91886f4e 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h
@@ -8,16 +8,13 @@
-class cDoorHandler:
- public cRedstoneHandler
+class cDoorHandler final : public cRedstoneHandler
{
- using Super = cRedstoneHandler;
-
public:
- virtual unsigned char GetPowerDeliveredToPosition(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
+ virtual unsigned char GetPowerDeliveredToPosition(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType) const override
{
- UNUSED(a_World);
+ UNUSED(a_Chunk);
UNUSED(a_Position);
UNUSED(a_BlockType);
UNUSED(a_Meta);
@@ -26,46 +23,27 @@ public:
return 0;
}
-
-
-
-
- virtual unsigned char GetPowerLevel(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
- {
- UNUSED(a_World);
- UNUSED(a_Position);
- UNUSED(a_BlockType);
- UNUSED(a_Meta);
- return 0;
- }
-
-
-
-
-
- virtual cVector3iArray Update(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
+ virtual void Update(cChunk & a_Chunk, cChunk &, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, PoweringData a_PoweringData) const override
{
// LOGD("Evaluating dori the door (%d %d %d)", a_Position.x, a_Position.y, a_Position.z);
- if (a_PoweringData != static_cast<cIncrementalRedstoneSimulator *>(a_World.GetRedstoneSimulator())->GetChunkData()->ExchangeUpdateOncePowerData(a_Position, a_PoweringData))
+ 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)
{
- cChunkInterface ChunkInterface(a_World.GetChunkMap());
- cBlockDoorHandler::SetOpen(ChunkInterface, a_Position, (a_PoweringData.PowerLevel != 0));
- a_World.BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_WOODEN_DOOR_OPEN, a_Position, 0);
+ cBlockDoorHandler::SetOpen(ChunkInterface, AbsolutePosition, ShouldBeOpen);
+ a_Chunk.GetWorld()->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_WOODEN_DOOR_OPEN, AbsolutePosition, 0);
}
-
- return {};
}
-
-
-
-
- virtual cVector3iArray GetValidSourcePositions(cWorld & a_World, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta) const override
+ virtual void ForValidSourcePositions(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, SourceCallback Callback) const override
{
- UNUSED(a_World);
+ UNUSED(a_Chunk);
UNUSED(a_BlockType);
UNUSED(a_Meta);
- return GetAdjustedRelatives(a_Position, GetRelativeAdjacents());
+ InvokeForAdjustedRelatives(Callback, a_Position, RelativeAdjacents);
}
};