BattleSiegeController.h 2.6 KB

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