summaryrefslogtreecommitdiffstats
path: root/source/Entities
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-09-06 00:04:49 +0200
committermadmaxoft <github@xoft.cz>2013-09-06 00:04:49 +0200
commit67e8f7531809f48bad7dd92bc6f28f63bd7cbd21 (patch)
tree15ca13bfe3ebfab54b826c3340b2b6d94fcff572 /source/Entities
parentMoved daylight burning directly into cMonster. (diff)
downloadcuberite-67e8f7531809f48bad7dd92bc6f28f63bd7cbd21.tar
cuberite-67e8f7531809f48bad7dd92bc6f28f63bd7cbd21.tar.gz
cuberite-67e8f7531809f48bad7dd92bc6f28f63bd7cbd21.tar.bz2
cuberite-67e8f7531809f48bad7dd92bc6f28f63bd7cbd21.tar.lz
cuberite-67e8f7531809f48bad7dd92bc6f28f63bd7cbd21.tar.xz
cuberite-67e8f7531809f48bad7dd92bc6f28f63bd7cbd21.tar.zst
cuberite-67e8f7531809f48bad7dd92bc6f28f63bd7cbd21.zip
Diffstat (limited to 'source/Entities')
-rw-r--r--source/Entities/Entity.cpp33
-rw-r--r--source/Entities/Entity.h2
2 files changed, 29 insertions, 6 deletions
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index 56fd36a05..4066e81ab 100644
--- a/source/Entities/Entity.cpp
+++ b/source/Entities/Entity.cpp
@@ -546,22 +546,24 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
}
else
{
+ // TODO: This condition belongs to minecarts, without it, they derails too much.
+ // But it shouldn't be here for other entities. We need a complete minecart physics overhaul.
if (
- (BlockBelow != E_BLOCK_RAIL) &&
- (BlockBelow != E_BLOCK_DETECTOR_RAIL) &&
- (BlockBelow != E_BLOCK_POWERED_RAIL) &&
+ (BlockBelow != E_BLOCK_RAIL) &&
+ (BlockBelow != E_BLOCK_DETECTOR_RAIL) &&
+ (BlockBelow != E_BLOCK_POWERED_RAIL) &&
(BlockBelow != E_BLOCK_ACTIVATOR_RAIL)
- )
+ )
{
// Friction
if (NextSpeed.SqrLength() > 0.0004f)
{
- NextSpeed.x *= 0.7f / (1 + a_Dt);
+ NextSpeed.x *= 0.6666;
if (fabs(NextSpeed.x) < 0.05)
{
NextSpeed.x = 0;
}
- NextSpeed.z *= 0.7f / (1 + a_Dt);
+ NextSpeed.z *= 0.6666;
if (fabs(NextSpeed.z) < 0.05)
{
NextSpeed.z = 0;
@@ -1225,6 +1227,25 @@ void cEntity::AddSpeedZ(double a_AddSpeedZ)
+void cEntity::SteerVehicle(float a_Forward, float a_Sideways)
+{
+ if (m_AttachedTo == NULL)
+ {
+ return;
+ }
+ 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);
+ }
+}
+
+
+
+
+
//////////////////////////////////////////////////////////////////////////
// Get look vector (this is NOT a rotation!)
Vector3d cEntity::GetLookVector(void) const
diff --git a/source/Entities/Entity.h b/source/Entities/Entity.h
index 2d058abae..b4777d249 100644
--- a/source/Entities/Entity.h
+++ b/source/Entities/Entity.h
@@ -185,6 +185,8 @@ public:
void AddSpeedX (double a_AddSpeedX);
void AddSpeedY (double a_AddSpeedY);
void AddSpeedZ (double a_AddSpeedZ);
+
+ void SteerVehicle(float a_Forward, float a_Sideways);
inline int GetUniqueID(void) const { return m_UniqueID; }
inline bool IsDestroyed(void) const { return !m_IsInitialized; }