summaryrefslogtreecommitdiffstats
path: root/source/Entities/Entity.cpp
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/Entity.cpp
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/Entity.cpp')
-rw-r--r--source/Entities/Entity.cpp33
1 files changed, 27 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