diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 09:45:06 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-09-02 09:50:23 +0200 |
commit | 49c443896dcac8c4eaf08c4024e8bd2366ad899a (patch) | |
tree | b1ec46cab2b4e5731860c7136f1bbfca6fe9d458 /src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h | |
parent | SetSwimState now takes into account head height (diff) | |
download | cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.gz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.bz2 cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.lz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.xz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.zst cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h b/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h index 93759408d..14d7baf85 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/PressurePlateHandler.h @@ -27,37 +27,49 @@ public: { UNUSED(a_Meta); - unsigned int NumberOfEntities; - bool FoundPlayer; - a_World.ForEachEntityInBox(cBoundingBox(Vector3d(0.5, 0, 0.5) + a_Position, 0.5, 0.5), [&](cEntity & a_Entity) + class cPressurePlateCallback : + public cEntityCallback + { + public: + cPressurePlateCallback(void) : + m_NumberOfEntities(0), + m_FoundPlayer(false) { - if (a_Entity.IsPlayer()) + } + + virtual bool Item(cEntity * a_Entity) override + { + if (a_Entity->IsPlayer()) { - FoundPlayer = true; + m_FoundPlayer = true; } - NumberOfEntities++; + m_NumberOfEntities++; return false; } - ); + + unsigned int m_NumberOfEntities; + bool m_FoundPlayer; + } PressurePlateCallback; + a_World.ForEachEntityInBox(cBoundingBox(Vector3d(0.5, 0, 0.5) + a_Position, 0.5, 0.5), PressurePlateCallback); switch (a_BlockType) { case E_BLOCK_STONE_PRESSURE_PLATE: { - return (FoundPlayer ? 15 : 0); + return (PressurePlateCallback.m_FoundPlayer ? 15 : 0); } case E_BLOCK_WOODEN_PRESSURE_PLATE: { - return (NumberOfEntities != 0 ? 15 : 0); + return (PressurePlateCallback.m_NumberOfEntities != 0 ? 15 : 0); } case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: { - return std::min(static_cast<unsigned char>(CeilC(NumberOfEntities / 10.f)), static_cast<unsigned char>(15)); + return std::min(static_cast<unsigned char>(CeilC(PressurePlateCallback.m_NumberOfEntities / 10.f)), static_cast<unsigned char>(15)); } case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: { - return std::min(static_cast<unsigned char>(NumberOfEntities), static_cast<unsigned char>(15)); + return std::min(static_cast<unsigned char>(PressurePlateCallback.m_NumberOfEntities), static_cast<unsigned char>(15)); } default: { |