From 73a3c4e3be1916bdd4830e7ce7454035a1f572f6 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Tue, 9 May 2017 14:21:25 +0200 Subject: Exported boat - NBT: Added saving / loading of material - Added the material in the item handler of the boat - Drop the correct boat if destroyed - APIDoc: Added desc and functions --- src/Entities/Boat.h | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'src/Entities/Boat.h') diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h index 5815ff88c..a6a99d683 100644 --- a/src/Entities/Boat.h +++ b/src/Entities/Boat.h @@ -13,7 +13,7 @@ - +// tolua_begin class cBoat : public cEntity @@ -21,6 +21,18 @@ class cBoat : typedef cEntity super; public: + enum eMaterial + { + bmOak, + bmSpruce, + bmBirch, + bmJungle, + bmAcacia, + bmDarkOak + }; + + // tolua_end + CLASS_PROTODEF(cBoat) // cEntity overrides: @@ -30,14 +42,34 @@ public: virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override; - cBoat(double a_X, double a_Y, double a_Z); + cBoat(double a_X, double a_Y, double a_Z, eMaterial a_Material); int GetLastDamage(void) const { return m_LastDamage; } int GetForwardDirection(void) const { return m_ForwardDirection; } float GetDamageTaken(void) const { return m_DamageTaken; } - int GetType(void) const { return m_Type; } + // tolua_begin + + /** Returns the eMaterial of the boat */ + eMaterial GetMaterial(void) const { return m_Material; } + + /** Sets the eMaterial of the boat */ + void SetMaterial(cBoat::eMaterial a_Material) { m_Material = a_Material; } + + /** Returns the eMaterial that should be used for a boat created from the specified item. Returns bmOak if not a boat item */ + static eMaterial ItemToMaterial(const cItem & a_Item); + + /** Returns the boat item of the boat material */ + static cItem MaterialToItem(eMaterial a_Material); + + /** Returns the eMaterial as string */ + static AString MaterialToString(const eMaterial a_Material); + + /** Returns the boat material for the passed string. Returns oak if not valid */ + static eMaterial StringToMaterial(const AString & a_Material); + + // tolua_end bool IsRightPaddleUsed(void) const { return m_RightPaddleUsed; } bool IsLeftPaddleUsed(void) const { return m_LeftPaddleUsed; } @@ -45,15 +77,14 @@ public: void SetLastDamage(int TimeSinceLastHit); void UpdatePaddles(bool rightPaddleUsed, bool leftPaddleUsed); - private: int m_LastDamage; int m_ForwardDirection; float m_DamageTaken; - int m_Type; + eMaterial m_Material; bool m_RightPaddleUsed; bool m_LeftPaddleUsed; -} ; +} ; // tolua_export -- cgit v1.2.3