CBattleSiegeController.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * CBattleObstacleController.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/GameConstants.h"
  12. #include "../../lib/battle/BattleHex.h"
  13. struct CatapultAttack;
  14. struct Point;
  15. struct SDL_Surface;
  16. class CGTownInstance;
  17. class CBattleInterface;
  18. class CCreature;
  19. class IImage;
  20. namespace EWallVisual
  21. {
  22. enum EWallVisual
  23. {
  24. BACKGROUND,
  25. BACKGROUND_WALL,
  26. KEEP,
  27. BOTTOM_TOWER,
  28. BOTTOM_WALL,
  29. WALL_BELLOW_GATE,
  30. WALL_OVER_GATE,
  31. UPPER_WALL,
  32. UPPER_TOWER,
  33. GATE,
  34. GATE_ARCH,
  35. BOTTOM_STATIC_WALL,
  36. UPPER_STATIC_WALL,
  37. MOAT,
  38. BACKGROUND_MOAT,
  39. KEEP_BATTLEMENT,
  40. BOTTOM_BATTLEMENT,
  41. UPPER_BATTLEMENT,
  42. CREATURE_KEEP,
  43. CREATURE_BOTTOM_TOWER,
  44. CREATURE_UPPER_TOWER,
  45. WALL_FIRST = BACKGROUND_WALL,
  46. WALL_LAST = UPPER_BATTLEMENT,
  47. // these entries are mapped to EWallPart enum
  48. DESTRUCTIBLE_FIRST = KEEP,
  49. DESTRUCTIBLE_LAST = GATE,
  50. };
  51. }
  52. class CBattleSiegeController
  53. {
  54. CBattleInterface * owner;
  55. /// besieged town
  56. const CGTownInstance *town;
  57. /// sections of castle walls, in their currently visible state
  58. std::array<std::shared_ptr<IImage>, EWallVisual::WALL_LAST + 1> wallPieceImages;
  59. /// return URI for image for a wall piece
  60. std::string getWallPieceImageName(EWallVisual::EWallVisual what, EWallState::EWallState state) const;
  61. /// returns BattleHex to which chosen wall piece is bound
  62. BattleHex getWallPiecePosition(EWallVisual::EWallVisual what) const;
  63. /// returns true if chosen wall piece should be present in current battle
  64. bool getWallPieceExistance(EWallVisual::EWallVisual what) const;
  65. void showWallPiece(SDL_Surface *to, EWallVisual::EWallVisual what);
  66. public:
  67. CBattleSiegeController(CBattleInterface * owner, const CGTownInstance *siegeTown);
  68. /// call-ins from server
  69. void gateStateChanged(const EGateState state);
  70. void stackIsCatapulting(const CatapultAttack & ca);
  71. /// call-ins from other battle controllers
  72. void showAbsoluteObstacles(SDL_Surface * to);
  73. void showBattlefieldObjects(SDL_Surface *to, const BattleHex & location );
  74. /// queries from other battle controllers
  75. bool isAttackableByCatapult(BattleHex hex) const;
  76. std::string getBattleBackgroundName() const;
  77. const CCreature *getTurretCreature() const;
  78. Point getTurretCreaturePosition( BattleHex position ) const;
  79. };