BoatActions.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * BoatActions.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 "SpecialAction.h"
  12. #include "../../../../lib/mapObjects/MapObjects.h"
  13. namespace NKAI
  14. {
  15. namespace AIPathfinding
  16. {
  17. class VirtualBoatAction : public SpecialAction
  18. {
  19. };
  20. class SummonBoatAction : public VirtualBoatAction
  21. {
  22. SpellID usedSpell;
  23. public:
  24. SummonBoatAction(SpellID usedSpell)
  25. : usedSpell(usedSpell)
  26. {
  27. }
  28. void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
  29. virtual void applyOnDestination(
  30. const CGHeroInstance * hero,
  31. CDestinationNodeInfo & destination,
  32. const PathNodeInfo & source,
  33. AIPathNode * dstMode,
  34. const AIPathNode * srcNode) const override;
  35. bool canAct(const Nullkiller * ai, const AIPathNode * source) const override;
  36. const ChainActor * getActor(const ChainActor * sourceActor) const override;
  37. std::string toString() const override;
  38. private:
  39. int32_t getManaCost(const CGHeroInstance * hero) const;
  40. };
  41. class BuildBoatAction : public VirtualBoatAction
  42. {
  43. private:
  44. const IShipyard * shipyard;
  45. const CPlayerSpecificInfoCallback * cb;
  46. public:
  47. BuildBoatAction(const CPlayerSpecificInfoCallback * cb, const IShipyard * shipyard)
  48. : cb(cb), shipyard(shipyard)
  49. {
  50. }
  51. bool canAct(const Nullkiller * ai, const AIPathNode * source) const override;
  52. bool canAct(const Nullkiller * ai, const AIPathNodeInfo & source) const override;
  53. bool canAct(const Nullkiller * ai, const CGHeroInstance * hero, const TResources & reservedResources) const;
  54. void execute(AIGateway * ai, const CGHeroInstance * hero) const override;
  55. Goals::TSubgoal decompose(const Nullkiller * ai, const CGHeroInstance * hero) const override;
  56. const ChainActor * getActor(const ChainActor * sourceActor) const override;
  57. std::string toString() const override;
  58. const CGObjectInstance * targetObject() const override;
  59. };
  60. class BuildBoatActionFactory : public ISpecialActionFactory
  61. {
  62. ObjectInstanceID shipyard;
  63. public:
  64. BuildBoatActionFactory(ObjectInstanceID shipyard)
  65. :shipyard(shipyard)
  66. {
  67. }
  68. std::shared_ptr<SpecialAction> create(const Nullkiller * ai) override;
  69. };
  70. }
  71. }