CaptureObjectsBehavior.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Goals.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "lib/VCMI_Lib.h"
  12. #include "Behavior.h"
  13. #include "../AIUtility.h"
  14. class CaptureObjectsBehavior : public Behavior {
  15. private:
  16. std::vector<int> objectTypes;
  17. std::vector<int> objectSubTypes;
  18. std::vector<const CGObjectInstance *> objectsToCapture;
  19. bool specificObjects;
  20. public:
  21. CaptureObjectsBehavior()
  22. {
  23. objectTypes = std::vector<int>();
  24. specificObjects = false;
  25. }
  26. CaptureObjectsBehavior(std::vector<const CGObjectInstance *> objectsToCapture)
  27. {
  28. this->objectsToCapture = objectsToCapture;
  29. specificObjects = true;
  30. }
  31. CaptureObjectsBehavior(const CGObjectInstance * objectToCapture)
  32. {
  33. objectsToCapture = std::vector<const CGObjectInstance *>();
  34. objectsToCapture.push_back(objectToCapture);
  35. specificObjects = true;
  36. }
  37. virtual Goals::TGoalVec getTasks() override;
  38. virtual std::string toString() const override;
  39. CaptureObjectsBehavior & ofType(int type) {
  40. objectTypes.push_back(type);
  41. return *this;
  42. }
  43. CaptureObjectsBehavior & ofType(int type, int subType) {
  44. objectTypes.push_back(type);
  45. objectSubTypes.push_back(subType);
  46. return *this;
  47. }
  48. private:
  49. bool shouldVisitObject(ObjectIdRef obj) const;
  50. };