2026-03-01 12:16:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "TargetGoal.h"
|
2026-03-03 03:04:10 +08:00
|
|
|
#include "EntitySelector.h"
|
|
|
|
|
|
|
|
|
|
class NearestAttackableTargetGoal;
|
|
|
|
|
|
|
|
|
|
// Anonymous class from NearestAttackableTargetGoal
|
|
|
|
|
class SubselectEntitySelector : public EntitySelector
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
EntitySelector *m_subselector;
|
|
|
|
|
NearestAttackableTargetGoal *m_parent;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SubselectEntitySelector(NearestAttackableTargetGoal *parent, EntitySelector *subselector);
|
|
|
|
|
~SubselectEntitySelector();
|
|
|
|
|
bool matches(shared_ptr<Entity> entity) const;
|
|
|
|
|
};
|
2026-03-01 12:16:08 +08:00
|
|
|
|
|
|
|
|
class NearestAttackableTargetGoal : public TargetGoal
|
|
|
|
|
{
|
2026-03-03 03:04:10 +08:00
|
|
|
friend class SubselectEntitySelector;
|
2026-03-01 12:16:08 +08:00
|
|
|
public:
|
|
|
|
|
class DistComp
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
Entity *source;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
DistComp(Entity *source);
|
|
|
|
|
|
2026-03-02 17:37:16 +07:00
|
|
|
bool operator() (shared_ptr<Entity> e1, shared_ptr<Entity> e2);
|
2026-03-01 12:16:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const type_info& targetType;
|
|
|
|
|
int randomInterval;
|
|
|
|
|
DistComp *distComp;
|
2026-03-03 03:04:10 +08:00
|
|
|
EntitySelector *selector;
|
|
|
|
|
weak_ptr<LivingEntity> target;
|
2026-03-01 12:16:08 +08:00
|
|
|
|
|
|
|
|
public:
|
2026-03-03 03:04:10 +08:00
|
|
|
NearestAttackableTargetGoal(PathfinderMob *mob, const type_info& targetType, int randomInterval, bool mustSee, bool mustReach = false, EntitySelector *entitySelector = NULL);
|
2026-03-01 12:16:08 +08:00
|
|
|
|
|
|
|
|
virtual ~NearestAttackableTargetGoal();
|
|
|
|
|
|
|
|
|
|
virtual bool canUse();
|
|
|
|
|
void start();
|
|
|
|
|
};
|