summaryrefslogtreecommitdiffstats
path: root/src/Entities/Boat.cpp
diff options
context:
space:
mode:
authorbeeduck <b33duck@gmail.com>2016-07-18 22:10:00 +0200
committerMattes D <github@xoft.cz>2016-07-18 22:10:00 +0200
commitdb65e11d57fb52395a3ba2e9372bdaf29aca691c (patch)
tree25bcc8449ab859676dcc2dea7b318051c22e51f1 /src/Entities/Boat.cpp
parentUpdate README.md (#3266) (diff)
downloadcuberite-db65e11d57fb52395a3ba2e9372bdaf29aca691c.tar
cuberite-db65e11d57fb52395a3ba2e9372bdaf29aca691c.tar.gz
cuberite-db65e11d57fb52395a3ba2e9372bdaf29aca691c.tar.bz2
cuberite-db65e11d57fb52395a3ba2e9372bdaf29aca691c.tar.lz
cuberite-db65e11d57fb52395a3ba2e9372bdaf29aca691c.tar.xz
cuberite-db65e11d57fb52395a3ba2e9372bdaf29aca691c.tar.zst
cuberite-db65e11d57fb52395a3ba2e9372bdaf29aca691c.zip
Diffstat (limited to 'src/Entities/Boat.cpp')
-rw-r--r--src/Entities/Boat.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index e81e57529..330e54740 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -14,7 +14,10 @@
cBoat::cBoat(double a_X, double a_Y, double a_Z) :
- super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7)
+ super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7),
+ m_LastDamage(0), m_ForwardDirection(0),
+ m_DamageTaken(0.0f), m_Type(0),
+ m_RightPaddleUsed(false), m_LeftPaddleUsed(false)
{
SetMass(20.0f);
SetGravity(-16.0f);
@@ -37,12 +40,15 @@ void cBoat::SpawnOn(cClientHandle & a_ClientHandle)
bool cBoat::DoTakeDamage(TakeDamageInfo & TDI)
{
+ m_LastDamage = 10;
if (!super::DoTakeDamage(TDI))
{
return false;
}
- if (GetHealth() == 0)
+ m_World->BroadcastEntityMetadata(*this);
+
+ if (GetHealth() <= 0)
{
if (TDI.Attacker != nullptr)
{
@@ -112,6 +118,14 @@ void cBoat::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
AddSpeedY(0.2);
}
}
+
+ if (GetLastDamage() > 0)
+ {
+ SetLastDamage(GetLastDamage() - 1);
+ }
+
+ // Broadcast any changes in position
+ m_World->BroadcastEntityMetadata(*this);
}
@@ -130,3 +144,23 @@ void cBoat::HandleSpeedFromAttachee(float a_Forward, float a_Sideways)
AddSpeed(ToAddSpeed);
}
+
+
+
+
+void cBoat::SetLastDamage(int TimeSinceLastHit)
+{
+ m_LastDamage = TimeSinceLastHit;
+}
+
+
+
+
+
+void cBoat::UpdatePaddles(bool a_RightPaddleUsed, bool a_LeftPaddleUsed)
+{
+ m_RightPaddleUsed = a_RightPaddleUsed;
+ m_LeftPaddleUsed = a_LeftPaddleUsed;
+
+ m_World->BroadcastEntityMetadata(*this);
+}