diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-26 15:15:00 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-26 15:16:46 +0200 |
commit | 4e5ab02a589582e2fa908909e3ee30360dd08be5 (patch) | |
tree | 848bb5338a5c5e52168702ee78058a6cc76f867f /src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h | |
parent | Fix incorrect big flower translation (diff) | |
download | cuberite-4e5ab02a589582e2fa908909e3ee30360dd08be5.tar cuberite-4e5ab02a589582e2fa908909e3ee30360dd08be5.tar.gz cuberite-4e5ab02a589582e2fa908909e3ee30360dd08be5.tar.bz2 cuberite-4e5ab02a589582e2fa908909e3ee30360dd08be5.tar.lz cuberite-4e5ab02a589582e2fa908909e3ee30360dd08be5.tar.xz cuberite-4e5ab02a589582e2fa908909e3ee30360dd08be5.tar.zst cuberite-4e5ab02a589582e2fa908909e3ee30360dd08be5.zip |
Diffstat (limited to 'src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h')
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/DoorHandler.h | 52 |
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); } }; |