CBattleObstacleController.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. VCMI_LIB_NAMESPACE_BEGIN
  12. struct BattleHex;
  13. struct CObstacleInstance;
  14. VCMI_LIB_NAMESPACE_END
  15. struct SDL_Surface;
  16. class IImage;
  17. class CCanvas;
  18. class CAnimation;
  19. class CBattleInterface;
  20. class CBattleRenderer;
  21. struct Point;
  22. class CBattleObstacleController
  23. {
  24. std::map<std::string, std::shared_ptr<CAnimation>> animationsCache;
  25. CBattleInterface * owner;
  26. std::map<si32, std::shared_ptr<CAnimation>> obstacleAnimations;
  27. // semi-debug member, contains obstacles that should not yet be visible due to ongoing placement animation
  28. // used only for sanity checks to ensure that there are no invisible obstacles
  29. std::vector<si32> obstaclesBeingPlaced;
  30. void loadObstacleImage(const CObstacleInstance & oi);
  31. std::shared_ptr<IImage> getObstacleImage(const CObstacleInstance & oi);
  32. Point getObstaclePosition(std::shared_ptr<IImage> image, const CObstacleInstance & obstacle);
  33. public:
  34. CBattleObstacleController(CBattleInterface * owner);
  35. void obstaclePlaced(const std::vector<std::shared_ptr<const CObstacleInstance>> & oi);
  36. void showObstacles(SDL_Surface *to, std::vector<std::shared_ptr<const CObstacleInstance>> &obstacles);
  37. void showAbsoluteObstacles(std::shared_ptr<CCanvas> canvas, const Point & offset);
  38. void collectRenderableObjects(CBattleRenderer & renderer);
  39. };