summaryrefslogtreecommitdiffstats
path: root/src/Entities/Minecart.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/Minecart.h')
-rw-r--r--src/Entities/Minecart.h47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index b1b48be4e..874d0204e 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -51,17 +51,38 @@ public:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
+ virtual void Destroyed() override;
int LastDamage(void) const { return m_LastDamage; }
- void HandleRailPhysics(float a_Dt, cChunk & a_Chunk);
ePayload GetPayload(void) const { return m_Payload; }
protected:
ePayload m_Payload;
+ int m_LastDamage;
+ Vector3i m_DetectorRailPosition;
+ bool m_bIsOnDetectorRail;
cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z);
- int m_LastDamage;
+ /** Handles physics on normal rails
+ For each tick, slow down on flat rails, speed up or slow down on ascending/descending rails (depending on direction), and turn on curved rails
+ */
+ void HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt);
+
+ /** Handles powered rail physics
+ Each tick, speed up or slow down cart, depending on metadata of rail (powered or not)
+ */
+ void HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta);
+
+ /** Handles detector rail activation
+ Activates detector rails when a minecart is on them. Calls HandleRailPhysics() for physics simulations
+ */
+ void HandleDetectorRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt);
+
+ /** Snaps a minecart to a rail's axis, resetting its speed */
+ void SnapToRail(NIBBLETYPE a_RailMeta);
+ /** Tests is a solid block is in front of a cart, and stops the cart (and returns true) if so; returns false if no obstruction*/
+ bool TestBlockCollision(NIBBLETYPE a_RailMeta);
} ;
@@ -69,18 +90,24 @@ protected:
-class cEmptyMinecart :
+class cRideableMinecart :
public cMinecart
{
typedef cMinecart super;
public:
- CLASS_PROTODEF(cEmptyMinecart);
+ CLASS_PROTODEF(cRideableMinecart);
- cEmptyMinecart(double a_X, double a_Y, double a_Z);
+ cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height);
+ const cItem & GetContent(void) const {return m_Content;}
+ int GetBlockHeight(void) const {return m_Height;}
// cEntity overrides:
virtual void OnRightClicked(cPlayer & a_Player) override;
+protected:
+
+ cItem m_Content;
+ int m_Height;
} ;
@@ -130,10 +157,18 @@ public:
// cEntity overrides:
virtual void OnRightClicked(cPlayer & a_Player) override;
- bool IsFueled (void) const { return m_IsFueled; }
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+
+ // Set functions.
+ void SetIsFueled(bool a_IsFueled, int a_FueledTimeLeft = -1) {m_IsFueled = a_IsFueled; m_FueledTimeLeft = a_FueledTimeLeft;}
+
+ // Get functions.
+ int GetFueledTimeLeft(void) const {return m_FueledTimeLeft; }
+ bool IsFueled (void) const {return m_IsFueled;}
private:
+ int m_FueledTimeLeft;
bool m_IsFueled;
} ;