CBattleObstacleController.h 1.6 KB

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