Files

50 lines
952 B
C
Raw Permalink Normal View History

2026-03-01 12:16:08 +08:00
#pragma once
#include "Goal.h"
class PathfinderMob;
2026-03-01 12:16:08 +08:00
class TargetGoal : public Goal
{
public:
static const int TargetFlag = 1;
private:
static const int EmptyReachCache = 0;
static const int CanReachCache = 1;
static const int CantReachCache = 2;
static const int UnseenMemoryTicks = 60;
protected:
PathfinderMob *mob; // Owner of this goal
2026-03-01 12:16:08 +08:00
bool mustSee;
private:
bool mustReach;
int reachCache;
int reachCacheTime;
int unseenTicks;
void _init(PathfinderMob *mob, bool mustSee, bool mustReach);
2026-03-01 12:16:08 +08:00
public:
TargetGoal(PathfinderMob *mob, bool mustSee);
TargetGoal(PathfinderMob *mob, bool mustSee, bool mustReach);
2026-03-01 12:16:08 +08:00
virtual ~TargetGoal() {}
virtual bool canContinueToUse();
protected:
virtual double getFollowDistance();
public:
2026-03-01 12:16:08 +08:00
virtual void start();
virtual void stop();
protected:
virtual bool canAttack(shared_ptr<LivingEntity> target, bool allowInvulnerable);
2026-03-01 12:16:08 +08:00
private:
bool canReach(shared_ptr<LivingEntity> target);
2026-03-01 12:16:08 +08:00
};