summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockButton.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockButton.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index f4994f193..9d8bf3da1 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -48,7 +48,7 @@ public:
const auto SoundToPlay = (m_BlockType == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_on" : "block.wood_button.click_on";
a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta, false);
- a_WorldInterface.WakeUpSimulators(a_BlockPos);
+ WakeUpSimulators(a_WorldInterface, a_BlockPos);
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect(SoundToPlay, a_BlockPos, 0.5f, 0.6f, a_Player.GetClientHandle());
// Queue a button reset (unpress)
@@ -186,7 +186,7 @@ public:
}
a_World.SetBlockMeta(Pos, Meta | 0x08, false);
- a_World.WakeUpSimulators(Pos);
+ WakeUpSimulators(a_World, Pos);
// sound name is ok to be wood, because only wood gets triggered by arrow
a_World.GetBroadcastManager().BroadcastSoundEffect("block.wood_button.click_on", Pos, 0.5f, 0.6f);
@@ -195,6 +195,27 @@ public:
QueueButtonRelease(a_World, Pos, Type);
}
+ /** Notify, mainly the redstone simulator, that this toggle component has updated. */
+ template <class WorldType>
+ static void WakeUpSimulators(WorldType & a_World, const Vector3i a_Position)
+ {
+ // Contains our direct adjacents
+ static const Vector3i Offsets[] =
+ {
+ { 1, 0, 0 },
+ { -1, 0, 0 },
+ { 0, 1, 0 },
+ { 0, -1, 0 },
+ { 0, 0, 1 },
+ { 0, 0, -1 }
+ };
+
+ for (const auto & Offset : Offsets)
+ {
+ a_World.WakeUpSimulators(a_Position + Offset);
+ }
+ }
+
private:
/** Schedules a recurring event at appropriate intervals to release a button at a given position.
@@ -229,7 +250,7 @@ private:
const auto SoundToPlayOnRelease = (Type == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_off" : "block.wood_button.click_off";
a_World.SetBlockMeta(a_Position, Meta & 0x07, false);
- a_World.WakeUpSimulators(a_Position);
+ WakeUpSimulators(a_World, a_Position);
a_World.BroadcastSoundEffect(SoundToPlayOnRelease, a_Position, 0.5f, 0.5f);
}
);