CaptureObjectsBehavior.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * CaptureObjectsBehavior.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 "../AIUtility.h"
  13. #include "../Goals/CGoal.h"
  14. namespace Goals
  15. {
  16. class CaptureObjectsBehavior : public CGoal<CaptureObjectsBehavior>
  17. {
  18. private:
  19. std::vector<int> objectTypes;
  20. std::vector<int> objectSubTypes;
  21. std::vector<const CGObjectInstance *> objectsToCapture;
  22. bool specificObjects;
  23. public:
  24. CaptureObjectsBehavior()
  25. :CGoal(CAPTURE_OBJECTS)
  26. {
  27. objectTypes = std::vector<int>();
  28. specificObjects = false;
  29. }
  30. CaptureObjectsBehavior(std::vector<const CGObjectInstance *> objectsToCapture)
  31. :CGoal(CAPTURE_OBJECTS)
  32. {
  33. this->objectsToCapture = objectsToCapture;
  34. specificObjects = true;
  35. }
  36. CaptureObjectsBehavior(const CGObjectInstance * objectToCapture)
  37. :CGoal(CAPTURE_OBJECTS)
  38. {
  39. objectsToCapture = std::vector<const CGObjectInstance *>();
  40. objectsToCapture.push_back(objectToCapture);
  41. specificObjects = true;
  42. }
  43. virtual Goals::TGoalVec decompose() const override;
  44. virtual std::string toString() const override;
  45. CaptureObjectsBehavior & ofType(int type)
  46. {
  47. objectTypes.push_back(type);
  48. return *this;
  49. }
  50. CaptureObjectsBehavior & ofType(int type, int subType)
  51. {
  52. objectTypes.push_back(type);
  53. objectSubTypes.push_back(subType);
  54. return *this;
  55. }
  56. virtual bool operator==(const CaptureObjectsBehavior & other) const override;
  57. private:
  58. bool shouldVisitObject(ObjectIdRef obj) const;
  59. };
  60. }