From 459d6369484107fbba93817469d038718ce41da2 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 16 Dec 2013 18:02:33 +0100 Subject: Added HandleSpeedFromAttachee so an entity can override the function. --- src/Entities/Entity.cpp | 18 ++++++++++++++---- src/Entities/Entity.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 0a2145e81..7721d58b3 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1341,6 +1341,19 @@ void cEntity::AddSpeedZ(double a_AddSpeedZ) +void cEntity::HandleSpeedFromAttachee(float a_Forward, float a_Sideways) +{ + Vector3d LookVector = m_Attachee->GetLookVector(); + double AddSpeedX = LookVector.x * a_Forward + LookVector.z * a_Sideways; + double AddSpeedZ = LookVector.z * a_Forward - LookVector.x * a_Sideways; + SetSpeed(AddSpeedX, 0, AddSpeedZ); + BroadcastMovementUpdate(); +} + + + + + void cEntity::SteerVehicle(float a_Forward, float a_Sideways) { if (m_AttachedTo == NULL) @@ -1349,10 +1362,7 @@ void cEntity::SteerVehicle(float a_Forward, float a_Sideways) } if ((a_Forward != 0) || (a_Sideways != 0)) { - Vector3d LookVector = GetLookVector(); - double AddSpeedX = LookVector.x * a_Forward + LookVector.z * a_Sideways; - double AddSpeedZ = LookVector.z * a_Forward - LookVector.x * a_Sideways; - m_AttachedTo->AddSpeed(AddSpeedX, 0, AddSpeedZ); + m_AttachedTo->HandleSpeedFromAttachee(a_Forward, a_Sideways); } } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index de5f176ae..8d1692c98 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -197,6 +197,7 @@ public: void AddSpeedY (double a_AddSpeedY); void AddSpeedZ (double a_AddSpeedZ); + virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways); void SteerVehicle(float a_Forward, float a_Sideways); inline int GetUniqueID(void) const { return m_UniqueID; } -- cgit v1.2.3