diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-05-27 19:28:42 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-05-27 19:28:42 +0200 |
commit | 9b8dff31e6140cab7ea44ae219771ad6a043c62e (patch) | |
tree | 9e2c7d14fef7b933fdc8f7929f59eeb5ee979274 | |
parent | Fixed cItemGrid API, no more changeable GetSlot(). (diff) | |
download | cuberite-9b8dff31e6140cab7ea44ae219771ad6a043c62e.tar cuberite-9b8dff31e6140cab7ea44ae219771ad6a043c62e.tar.gz cuberite-9b8dff31e6140cab7ea44ae219771ad6a043c62e.tar.bz2 cuberite-9b8dff31e6140cab7ea44ae219771ad6a043c62e.tar.lz cuberite-9b8dff31e6140cab7ea44ae219771ad6a043c62e.tar.xz cuberite-9b8dff31e6140cab7ea44ae219771ad6a043c62e.tar.zst cuberite-9b8dff31e6140cab7ea44ae219771ad6a043c62e.zip |
Diffstat (limited to '')
-rw-r--r-- | source/DropSpenserEntity.cpp | 16 | ||||
-rw-r--r-- | source/DropSpenserEntity.h | 7 | ||||
-rw-r--r-- | source/Simulator/RedstoneSimulator.cpp | 24 |
3 files changed, 33 insertions, 14 deletions
diff --git a/source/DropSpenserEntity.cpp b/source/DropSpenserEntity.cpp index 3830e1d01..85eaa8297 100644 --- a/source/DropSpenserEntity.cpp +++ b/source/DropSpenserEntity.cpp @@ -14,7 +14,8 @@ cDropSpenserEntity::cDropSpenserEntity(BLOCKTYPE a_BlockType, int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, ContentsWidth, ContentsHeight, a_World),
- m_ShouldDropSpense(false)
+ m_ShouldDropSpense(false),
+ m_IsPowered(false)
{
SetBlockEntity(this); // cBlockEntityWindowOwner
}
@@ -120,6 +121,19 @@ void cDropSpenserEntity::Activate(void) +void cDropSpenserEntity::SetRedstonePower(bool a_IsPowered)
+{
+ if (a_IsPowered && !m_IsPowered)
+ {
+ Activate();
+ }
+ m_IsPowered = a_IsPowered;
+}
+
+
+
+
+
bool cDropSpenserEntity::Tick(float a_Dt)
{
if (!m_ShouldDropSpense)
diff --git a/source/DropSpenserEntity.h b/source/DropSpenserEntity.h index f4221808c..d58f74f04 100644 --- a/source/DropSpenserEntity.h +++ b/source/DropSpenserEntity.h @@ -65,11 +65,16 @@ public: /// Sets the dropspenser to dropspense an item in the next tick
void Activate(void);
+ /// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
+ void SetRedstonePower(bool a_IsPowered);
+
// tolua_end
protected:
bool m_ShouldDropSpense; ///< If true, the dropspenser will dropspense an item in the next tick
-
+ bool m_IsPowered; ///< Set to true when the dropspenser receives redstone power.
+
+ /// Does the actual work on dropspensing an item. Chooses the slot, calls DropSpenseFromSlot() and handles smoke / sound effects
void DropSpense(void);
/// Override this function to provide the specific behavior for item dropspensing (drop / shoot / pour / ...)
diff --git a/source/Simulator/RedstoneSimulator.cpp b/source/Simulator/RedstoneSimulator.cpp index 03ad43ace..5db40192f 100644 --- a/source/Simulator/RedstoneSimulator.cpp +++ b/source/Simulator/RedstoneSimulator.cpp @@ -433,20 +433,20 @@ void cRedstoneSimulator::HandleChange(const Vector3i & a_BlockPos) BLOCKTYPE BlockType = m_World.GetBlock(pos); if ((BlockType == E_BLOCK_DISPENSER) || (BlockType == E_BLOCK_DROPPER)) { - if (IsPowered(pos)) + class cSetPowerToDropSpenser : + public cDropSpenserCallback { - class cActivateDropSpenser : - public cDropSpenserCallback + bool m_IsPowered; + public: + cSetPowerToDropSpenser(bool a_IsPowered) : m_IsPowered(a_IsPowered) {} + + virtual bool Item(cDropSpenserEntity * a_DropSpenser) override { - virtual bool Item(cDropSpenserEntity * a_DropSpenser) override - { - a_DropSpenser->Activate(); - return false; - } - } ; - cActivateDropSpenser DrSpAct; - m_World.DoWithDropSpenserAt(pos.x, pos.y, pos.z, DrSpAct); - } + a_DropSpenser->Activate(); + return false; + } + } DrSpSP(IsPowered(pos)); + m_World.DoWithDropSpenserAt(pos.x, pos.y, pos.z, DrSpSP); } } } |