blob: 0fd3c34a8100bb08895957fa22eb04e01de80ba3 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include "stdafx.h"
#include "net.minecraft.world.entity.ai.control.h"
#include "net.minecraft.world.entity.ai.sensing.h"
#include "net.minecraft.world.entity.ai.navigation.h"
#include "net.minecraft.world.entity.monster.h"
#include "SwellGoal.h"
SwellGoal::SwellGoal(Creeper *creeper)
{
target = weak_ptr<LivingEntity>();
this->creeper = creeper;
setRequiredControlFlags(Control::MoveControlFlag);
}
bool SwellGoal::canUse()
{
shared_ptr<LivingEntity> target = creeper->getTarget();
return creeper->getSwellDir() > 0 || (target != nullptr && (creeper->distanceToSqr(target) < 3 * 3));
}
void SwellGoal::start()
{
creeper->getNavigation()->stop();
target = weak_ptr<LivingEntity>(creeper->getTarget());
}
void SwellGoal::stop()
{
target = weak_ptr<LivingEntity>();
}
void SwellGoal::tick()
{
if (target.lock() == nullptr)
{
creeper->setSwellDir(-1);
return;
}
if (creeper->distanceToSqr(target.lock()) > 7 * 7)
{
creeper->setSwellDir(-1);
return;
}
if (!creeper->getSensing()->canSee(target.lock()))
{
creeper->setSwellDir(-1);
return;
}
creeper->setSwellDir(1);
}
|