diff options
author | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-16 18:02:33 +0100 |
---|---|---|
committer | STRWarrior <niels.breuker@hotmail.nl> | 2013-12-16 18:02:33 +0100 |
commit | 459d6369484107fbba93817469d038718ce41da2 (patch) | |
tree | babf9a6c11b979deaac4b5630dc2bd4904d05835 /src | |
parent | You can spawn boats on water. (diff) | |
download | cuberite-459d6369484107fbba93817469d038718ce41da2.tar cuberite-459d6369484107fbba93817469d038718ce41da2.tar.gz cuberite-459d6369484107fbba93817469d038718ce41da2.tar.bz2 cuberite-459d6369484107fbba93817469d038718ce41da2.tar.lz cuberite-459d6369484107fbba93817469d038718ce41da2.tar.xz cuberite-459d6369484107fbba93817469d038718ce41da2.tar.zst cuberite-459d6369484107fbba93817469d038718ce41da2.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Entity.cpp | 18 | ||||
-rw-r--r-- | 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; } |