BattleSiegeController.h 2.8 KB

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