blob: 564fa59da25e25e428e318af7788c424761824ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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, double speedModifier)
{
this->mob = mob;
this->speedModifier = speedModifier;
setRequiredControlFlags(Control::MoveControlFlag);
}
bool PanicGoal::canUse()
{
if (mob->getLastHurtByMob() == NULL && !mob->isOnFire()) 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, speedModifier);
}
bool PanicGoal::canContinueToUse()
{
return !mob->getNavigation()->isDone();
}
|