summaryrefslogtreecommitdiffstats
path: root/src/Mobs/PassiveMonster.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Mobs/PassiveMonster.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index c9345662d..cd0f59153 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -136,16 +136,17 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
GetFollowedItems(FollowedItems);
if (FollowedItems.Size() > 0)
{
- cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance));
- if (a_Closest_Player != nullptr)
+ m_World->DoWithNearestPlayer(GetPosition(), static_cast<float>(m_SightDistance), [&](cPlayer & a_Player) -> bool
{
- cItem EquippedItem = a_Closest_Player->GetEquippedItem();
+ cItem EquippedItem = a_Player.GetEquippedItem();
if (FollowedItems.ContainsType(EquippedItem))
{
- Vector3d PlayerPos = a_Closest_Player->GetPosition();
+ Vector3d PlayerPos = a_Player.GetPosition();
MoveToPosition(PlayerPos);
}
- }
+
+ return true;
+ });
}
}