Obstacle.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Obstacle.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 "LocationEffect.h"
  12. #include "../../GameConstants.h"
  13. #include "../../battle/BattleHexArray.h"
  14. #include "../../battle/CObstacleInstance.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. namespace spells
  17. {
  18. namespace effects
  19. {
  20. class ObstacleSideOptions
  21. {
  22. public:
  23. using RelativeShape = std::vector<std::vector<BattleHex::EDir>>;
  24. RelativeShape shape; //shape of single obstacle relative to obstacle position
  25. RelativeShape range; //position of obstacles relative to effect destination
  26. AudioPath appearSound;
  27. AnimationPath appearAnimation;
  28. AnimationPath animation;
  29. int offsetY = 0;
  30. void serializeJson(JsonSerializeFormat & handler);
  31. };
  32. class Obstacle : public LocationEffect
  33. {
  34. public:
  35. void adjustAffectedHexes(BattleHexArray & hexes, const Mechanics * m, const Target & spellTarget) const override;
  36. bool applicable(Problem & problem, const Mechanics * m) const override;
  37. bool applicable(Problem & problem, const Mechanics * m, const EffectTarget & target) const override;
  38. EffectTarget transformTarget(const Mechanics * m, const Target & aimPoint, const Target & spellTarget) const override;
  39. void apply(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const override;
  40. protected:
  41. void serializeJsonEffect(JsonSerializeFormat & handler) override;
  42. virtual void placeObstacles(ServerCallback * server, const Mechanics * m, const EffectTarget & target) const;
  43. bool hidden = false;
  44. bool trigger = false;
  45. bool trap = false;
  46. bool removeOnTrigger = false;
  47. bool hideNative = false;
  48. SpellID triggerAbility;
  49. private:
  50. int32_t patchCount = 0; //random patches to place, for massive spells should be >= 1, for non-massive ones if >= 1, then place only this number inside a target (like H5 landMine)
  51. bool passable = false;
  52. int32_t turnsRemaining = -1;
  53. BattleSideArray<ObstacleSideOptions> sideOptions;
  54. static bool isHexAvailable(const CBattleInfoCallback * cb, const BattleHex & hex, const bool mustBeClear);
  55. static bool noRoomToPlace(Problem & problem, const Mechanics * m);
  56. };
  57. }
  58. }
  59. VCMI_LIB_NAMESPACE_END