1
0

Slight cleanup of wolf code

This commit is contained in:
Tiger Wang 2014-02-16 13:47:55 +00:00
parent 5330a88365
commit 1a84102b10

View File

@ -124,12 +124,6 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
{ {
super::Tick(a_Dt, a_Chunk); super::Tick(a_Dt, a_Chunk);
} }
// The wolf is sitting so don't move him at all.
if (IsSitting())
{
m_bMovingToDestination = false;
}
cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance); cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance);
if (a_Closest_Player != NULL) if (a_Closest_Player != NULL)
@ -148,18 +142,15 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
SetIsBegging(true); SetIsBegging(true);
m_World->BroadcastEntityMetadata(*this); m_World->BroadcastEntityMetadata(*this);
} }
// Don't move to the player if the wolf is sitting. // Don't move to the player if the wolf is sitting.
if (IsSitting()) if (IsSitting())
{ {
m_bMovingToDestination = false; m_bMovingToDestination = false;
return;
} }
else
{ MoveToPosition(a_Closest_Player->GetPosition());
m_bMovingToDestination = true;
}
Vector3d PlayerPos = a_Closest_Player->GetPosition();
PlayerPos.y++;
m_FinalDestination = PlayerPos;
break; break;
} }
default: default:
@ -173,7 +164,7 @@ void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
} }
} }
if (IsTame()) if (IsTame() && !IsSitting())
{ {
TickFollowPlayer(); TickFollowPlayer();
} }
@ -196,6 +187,7 @@ void cWolf::TickFollowPlayer()
public: public:
Vector3d OwnerPos; Vector3d OwnerPos;
} Callback; } Callback;
if (m_World->DoWithPlayer(m_OwnerName, Callback)) if (m_World->DoWithPlayer(m_OwnerName, Callback))
{ {
// The player is present in the world, follow him: // The player is present in the world, follow him:
@ -210,15 +202,7 @@ void cWolf::TickFollowPlayer()
} }
else else
{ {
m_FinalDestination = Callback.OwnerPos; MoveToPosition(Callback.OwnerPos);
if (IsSitting())
{
m_bMovingToDestination = false;
}
else
{
m_bMovingToDestination = true;
}
} }
} }
} }