1
0

Merge pull request #2908 from marvinkopf/FixMineCartSpeed

Fix cPawn push logic
This commit is contained in:
LogicParrot 2016-02-02 19:40:03 +02:00
commit a8599efd77
3 changed files with 22 additions and 0 deletions

View File

@ -1864,6 +1864,19 @@ bool cEntity::IsA(const char * a_ClassName) const
bool cEntity::IsAttachedTo(const cEntity * a_Entity) const
{
if ((m_AttachedTo != nullptr) && (a_Entity->GetUniqueID() == m_AttachedTo->GetUniqueID()))
{
return true;
}
return false;
}
void cEntity::SetHeadYaw(double a_HeadYaw)
{
m_HeadYaw = a_HeadYaw;

View File

@ -423,6 +423,9 @@ public:
/** Detaches from the currently attached entity, if any */
virtual void Detach(void);
/** Returns true if this entity is attached to the specified entity */
bool IsAttachedTo(const cEntity * a_Entity) const;
/** Makes sure head yaw is not over the specified range. */
void WrapHeadYaw();

View File

@ -73,6 +73,12 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
return false;
}
// do not push a boat / minecart you're sitting in
if (m_Pusher->IsAttachedTo(a_Entity))
{
return false;
}
Vector3d v3Delta = a_Entity->GetPosition() - m_Pusher->GetPosition();
v3Delta.y = 0.0; // we only push sideways
v3Delta *= 1.0 / (v3Delta.Length() + 0.01); // we push harder if we're close