BattleObstacleController.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. VCMI_LIB_NAMESPACE_BEGIN
  12. struct BattleHex;
  13. struct CObstacleInstance;
  14. VCMI_LIB_NAMESPACE_END
  15. class IImage;
  16. class Canvas;
  17. class CAnimation;
  18. class BattleInterface;
  19. class BattleRenderer;
  20. struct Point;
  21. /// Controls all currently active projectiles on the battlefield
  22. /// (with exception of moat, which is apparently handled by siege controller)
  23. class BattleObstacleController
  24. {
  25. BattleInterface & owner;
  26. /// cached animations of all obstacles in current battle
  27. std::map<std::string, std::shared_ptr<CAnimation>> animationsCache;
  28. /// list of all obstacles that are currently being rendered
  29. std::map<si32, std::shared_ptr<CAnimation>> obstacleAnimations;
  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. BattleObstacleController(BattleInterface & owner);
  35. /// call-in from network pack, add newly placed obstacles with any required animations
  36. void obstaclePlaced(const std::vector<std::shared_ptr<const CObstacleInstance>> & oi);
  37. /// renders all "absolute" obstacles
  38. void showAbsoluteObstacles(Canvas & canvas, const Point & offset);
  39. /// adds all non-"absolute" visible obstacles for rendering
  40. void collectRenderableObjects(BattleRenderer & renderer);
  41. };