diff options
Diffstat (limited to 'Minecraft.World/PanicGoal.cpp')
| -rw-r--r-- | Minecraft.World/PanicGoal.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Minecraft.World/PanicGoal.cpp b/Minecraft.World/PanicGoal.cpp new file mode 100644 index 00000000..da951ca2 --- /dev/null +++ b/Minecraft.World/PanicGoal.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "net.minecraft.world.entity.ai.control.h" +#include "net.minecraft.world.entity.ai.navigation.h" +#include "net.minecraft.world.entity.ai.util.h" +#include "net.minecraft.world.entity.h" +#include "net.minecraft.world.phys.h" +#include "PanicGoal.h" + +PanicGoal::PanicGoal(PathfinderMob *mob, float speed) +{ + this->mob = mob; + this->speed = speed; + setRequiredControlFlags(Control::MoveControlFlag); +} + +bool PanicGoal::canUse() +{ + if (mob->getLastHurtByMob() == NULL) return false; + Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5, 4); + if (pos == NULL) return false; + posX = pos->x; + posY = pos->y; + posZ = pos->z; + return true; +} + +void PanicGoal::start() +{ + mob->getNavigation()->moveTo(posX, posY, posZ, speed); +} + +bool PanicGoal::canContinueToUse() +{ + return !mob->getNavigation()->isDone(); +}
\ No newline at end of file |
