diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-01 21:12:44 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-01 21:12:44 +0200 |
commit | 6e3e7552e67dfc0254c3e99bcd32fea02f10d062 (patch) | |
tree | 84bfd40d2c2693cab44a47d4902aa601d8a715e6 /src/Mobs/Wolf.cpp | |
parent | d (diff) | |
parent | SetSwimState now takes into account head height (diff) | |
download | cuberite-6e3e7552e67dfc0254c3e99bcd32fea02f10d062.tar cuberite-6e3e7552e67dfc0254c3e99bcd32fea02f10d062.tar.gz cuberite-6e3e7552e67dfc0254c3e99bcd32fea02f10d062.tar.bz2 cuberite-6e3e7552e67dfc0254c3e99bcd32fea02f10d062.tar.lz cuberite-6e3e7552e67dfc0254c3e99bcd32fea02f10d062.tar.xz cuberite-6e3e7552e67dfc0254c3e99bcd32fea02f10d062.tar.zst cuberite-6e3e7552e67dfc0254c3e99bcd32fea02f10d062.zip |
Diffstat (limited to 'src/Mobs/Wolf.cpp')
-rw-r--r-- | src/Mobs/Wolf.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index c08e572fb..f1c082ce7 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -83,19 +83,22 @@ void cWolf::NotifyAlliesOfFight(cPawn * a_Opponent) return; } m_NotificationCooldown = 15; - class cCallback : public cPlayerListCallback - { - virtual bool Item(cPlayer * a_Player) override + + m_World->DoWithPlayerByUUID(m_OwnerUUID, [=](cPlayer & a_Player) { - a_Player->NotifyNearbyWolves(m_Opponent, false); + a_Player.NotifyNearbyWolves(a_Opponent, false); return false; } +<<<<<<< HEAD public: cPawn * m_Opponent; } Callback; Callback.m_Opponent = a_Opponent; m_World->DoWithPlayerByUUID(m_OwnerUUID, Callback);*/ +======= + ); +>>>>>>> master } /*bool cWolf::Attack(std::chrono::milliseconds a_Dt) @@ -356,31 +359,31 @@ void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) void cWolf::TickFollowPlayer() { +<<<<<<< HEAD /* class cCallback : public cPlayerListCallback +======= + Vector3d OwnerPos; + bool OwnerFlying; + auto Callback = [&](cPlayer & a_Player) +>>>>>>> master { - virtual bool Item(cPlayer * a_Player) override - { - OwnerPos = a_Player->GetPosition(); - OwnerFlying = a_Player->IsFlying(); - return true; - } - public: - Vector3d OwnerPos; - bool OwnerFlying; - } Callback; + OwnerPos = a_Player.GetPosition(); + OwnerFlying = a_Player.IsFlying(); + return true; + }; if (m_World->DoWithPlayerByUUID(m_OwnerUUID, Callback)) { // The player is present in the world, follow him: - double Distance = (Callback.OwnerPos - GetPosition()).Length(); + double Distance = (OwnerPos - GetPosition()).Length(); if (Distance > 20) { - if (!Callback.OwnerFlying) + if (!OwnerFlying) { - Callback.OwnerPos.y = FindFirstNonAirBlockPosition(Callback.OwnerPos.x, Callback.OwnerPos.z); - TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z); + OwnerPos.y = FindFirstNonAirBlockPosition(OwnerPos.x, OwnerPos.z); + TeleportToCoords(OwnerPos.x, OwnerPos.y, OwnerPos.z); SetTarget(nullptr); } } @@ -395,9 +398,9 @@ void cWolf::TickFollowPlayer() { if (GetTarget() == nullptr) { - if (!Callback.OwnerFlying) + if (!OwnerFlying) { - MoveToPosition(Callback.OwnerPos); + MoveToPosition(OwnerPos); } } } |