summaryrefslogtreecommitdiffstats
path: root/src/Entities/Minecart.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/Minecart.cpp')
-rw-r--r--src/Entities/Minecart.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index 1501eea84..a3927298e 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -1103,29 +1103,54 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
// cMinecartWithChest:
cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
- super(mpChest, a_X, a_Y, a_Z)
+ super(mpChest, a_X, a_Y, a_Z),
+ m_Contents(ContentsWidth, ContentsHeight)
{
+ m_Contents.AddListener(*this);
}
-void cMinecartWithChest::SetSlot(size_t a_Idx, const cItem & a_Item)
+void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
{
- ASSERT(a_Idx < ARRAYCOUNT(m_Items));
-
- m_Items[a_Idx] = a_Item;
+ // If the window is not created, open it anew:
+ cWindow * Window = GetWindow();
+ if (Window == NULL)
+ {
+ OpenNewWindow();
+ Window = GetWindow();
+ }
+
+ // Open the window for the player:
+ if (Window != NULL)
+ {
+ if (a_Player.GetWindow() != Window)
+ {
+ a_Player.OpenWindow(Window);
+ }
+ }
}
-void cMinecartWithChest::OnRightClicked(cPlayer & a_Player)
+void cMinecartWithChest::OpenNewWindow()
+{
+ OpenWindow(new cMinecartWithChestWindow(this));
+}
+
+
+
+
+
+void cMinecartWithChest::Destroyed()
{
- // Show the chest UI window to the player
- // TODO
+ cItems Pickups;
+ m_Contents.CopyToItems(Pickups);
+ GetWorld()->SpawnItemPickups(Pickups, GetPosX(), GetPosY() + 1, GetPosZ(), 4);
}