diff options
author | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-16 18:03:39 +0100 |
---|---|---|
committer | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-16 18:03:39 +0100 |
commit | 199123d4f23aa6d1957b96382c96bd89cbcdf092 (patch) | |
tree | a15a90118aea42229d2aea4113b5dcaa449ffe3f | |
parent | Added HandleSpeedFromAttachee so an entity can override the function. (diff) | |
download | cuberite-199123d4f23aa6d1957b96382c96bd89cbcdf092.tar cuberite-199123d4f23aa6d1957b96382c96bd89cbcdf092.tar.gz cuberite-199123d4f23aa6d1957b96382c96bd89cbcdf092.tar.bz2 cuberite-199123d4f23aa6d1957b96382c96bd89cbcdf092.tar.lz cuberite-199123d4f23aa6d1957b96382c96bd89cbcdf092.tar.xz cuberite-199123d4f23aa6d1957b96382c96bd89cbcdf092.tar.zst cuberite-199123d4f23aa6d1957b96382c96bd89cbcdf092.zip |
-rw-r--r-- | src/Entities/Boat.cpp | 33 | ||||
-rw-r--r-- | src/Entities/Boat.h | 3 |
2 files changed, 33 insertions, 3 deletions
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index 56e766dd4..184aeeeeb 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -39,6 +39,15 @@ void cBoat::DoTakeDamage(TakeDamageInfo & TDI) if (GetHealth() == 0) { + if (TDI.Attacker != NULL) + { + if (TDI.Attacker->IsPlayer()) + { + cItems Pickups; + Pickups.Add(cItem(E_ITEM_BOAT)); + m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 0, 0, 0, true); + } + } Destroy(true); } } @@ -76,12 +85,32 @@ void cBoat::OnRightClicked(cPlayer & a_Player) -void cBoat::HandlePhysics(float a_Dt, cChunk & a_Chunk) +void cBoat::Tick(float a_Dt, cChunk & a_Chunk) { - super::HandlePhysics(a_Dt, a_Chunk); + super::Tick(a_Dt, a_Chunk); BroadcastMovementUpdate(); + SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed. + if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()))) + { + SetSpeedY(1); + } } + +void cBoat::HandleSpeedFromAttachee(float a_Forward, float a_Sideways) +{ + if (GetSpeed().Length() > 7) + { + return; + } + + Vector3d ToAddSpeed(m_Attachee->GetLookVector() * (a_Sideways * 1.5)); + ToAddSpeed.y = 0; + + AddSpeed(ToAddSpeed); +} + +
\ No newline at end of file diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h index 8c51ab86c..c4c9afe7a 100644 --- a/src/Entities/Boat.h +++ b/src/Entities/Boat.h @@ -27,7 +27,8 @@ public: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void OnRightClicked(cPlayer & a_Player) override; virtual void DoTakeDamage(TakeDamageInfo & TDI) override; - virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(float 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); } ; |