2021-05-15 18:23:11 +02:00
|
|
|
/*
|
2021-05-15 21:04:26 +02:00
|
|
|
* CaptureObjectsBehavior.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2021-05-15 18:23:11 +02:00
|
|
|
#pragma once
|
|
|
|
|
2021-05-16 13:45:35 +02:00
|
|
|
#include "../../../lib/VCMI_Lib.h"
|
2021-05-15 18:23:11 +02:00
|
|
|
#include "../AIUtility.h"
|
2021-05-16 13:38:26 +02:00
|
|
|
#include "../Goals/CGoal.h"
|
2021-05-16 13:55:47 +02:00
|
|
|
#include "../Pathfinding/AINodeStorage.h"
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2022-09-26 20:01:07 +02:00
|
|
|
namespace NKAI
|
|
|
|
{
|
2021-05-16 13:38:26 +02:00
|
|
|
namespace Goals
|
|
|
|
{
|
|
|
|
class CaptureObjectsBehavior : public CGoal<CaptureObjectsBehavior>
|
2021-05-15 18:23:11 +02:00
|
|
|
{
|
2021-05-16 13:38:26 +02:00
|
|
|
private:
|
|
|
|
std::vector<int> objectTypes;
|
|
|
|
std::vector<int> objectSubTypes;
|
|
|
|
std::vector<const CGObjectInstance *> objectsToCapture;
|
|
|
|
bool specificObjects;
|
|
|
|
public:
|
|
|
|
CaptureObjectsBehavior()
|
2021-05-16 13:38:53 +02:00
|
|
|
:CGoal(CAPTURE_OBJECTS)
|
2021-05-16 13:38:26 +02:00
|
|
|
{
|
|
|
|
objectTypes = std::vector<int>();
|
|
|
|
specificObjects = false;
|
|
|
|
}
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2021-05-16 13:38:26 +02:00
|
|
|
CaptureObjectsBehavior(std::vector<const CGObjectInstance *> objectsToCapture)
|
2021-05-16 13:38:53 +02:00
|
|
|
:CGoal(CAPTURE_OBJECTS)
|
2021-05-16 13:38:26 +02:00
|
|
|
{
|
|
|
|
this->objectsToCapture = objectsToCapture;
|
|
|
|
specificObjects = true;
|
|
|
|
}
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2021-05-16 13:38:26 +02:00
|
|
|
CaptureObjectsBehavior(const CGObjectInstance * objectToCapture)
|
2021-05-16 13:38:53 +02:00
|
|
|
:CGoal(CAPTURE_OBJECTS)
|
2021-05-16 13:38:26 +02:00
|
|
|
{
|
|
|
|
objectsToCapture = std::vector<const CGObjectInstance *>();
|
|
|
|
objectsToCapture.push_back(objectToCapture);
|
|
|
|
specificObjects = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Goals::TGoalVec decompose() const override;
|
|
|
|
virtual std::string toString() const override;
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2021-05-16 13:38:26 +02:00
|
|
|
CaptureObjectsBehavior & ofType(int type)
|
|
|
|
{
|
|
|
|
objectTypes.push_back(type);
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2021-05-16 13:38:26 +02:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
CaptureObjectsBehavior & ofType(int type, int subType)
|
|
|
|
{
|
|
|
|
objectTypes.push_back(type);
|
|
|
|
objectSubTypes.push_back(subType);
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2021-05-16 13:38:26 +02:00
|
|
|
return *this;
|
|
|
|
}
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2024-02-10 21:22:08 +02:00
|
|
|
bool operator==(const CaptureObjectsBehavior & other) const override;
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2021-05-16 13:45:12 +02:00
|
|
|
static Goals::TGoalVec getVisitGoals(const std::vector<AIPath> & paths, const CGObjectInstance * objToVisit = nullptr);
|
|
|
|
|
2021-05-16 13:38:26 +02:00
|
|
|
private:
|
2021-05-16 13:56:27 +02:00
|
|
|
bool objectMatchesFilter(const CGObjectInstance * obj) const;
|
2021-05-16 13:38:26 +02:00
|
|
|
};
|
|
|
|
}
|
2021-05-15 18:23:11 +02:00
|
|
|
|
2022-09-26 20:01:07 +02:00
|
|
|
|
|
|
|
}
|