BattleEffectsController.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * BattleEffectsController.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/battle/BattleHex.h"
  12. #include "../../lib/Point.h"
  13. #include "../../lib/filesystem/ResourcePath.h"
  14. #include "BattleConstants.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. class BattleAction;
  17. struct BattleTriggerEffect;
  18. VCMI_LIB_NAMESPACE_END
  19. struct ColorMuxerEffect;
  20. class CAnimation;
  21. class Canvas;
  22. class BattleInterface;
  23. class BattleRenderer;
  24. class EffectAnimation;
  25. /// Struct for battle effect animation e.g. morale, prayer, armageddon, bless,...
  26. struct BattleEffect
  27. {
  28. enum class AnimType : ui8
  29. {
  30. DEFAULT = 0, //If we have such animation
  31. REVERSE = 1 //Reverse DEFAULT will be used
  32. };
  33. AnimType type;
  34. Point pos; //position on the screen
  35. float currentFrame;
  36. std::shared_ptr<CAnimation> animation;
  37. int effectID; //uniqueID equal ot ID of appropriate CSpellEffectAnim
  38. BattleHex tile; //Indicates if effect which hex the effect is drawn on
  39. };
  40. /// Controls rendering of effects in battle, e.g. from spells, abilities and various other actions like morale
  41. class BattleEffectsController
  42. {
  43. BattleInterface & owner;
  44. /// list of current effects that are being displayed on screen (spells & creature abilities)
  45. std::vector<BattleEffect> battleEffects;
  46. std::map<std::string, ColorMuxerEffect> colorMuxerEffects;
  47. void loadColorMuxers();
  48. public:
  49. const ColorMuxerEffect &getMuxerEffect(const std::string & name);
  50. BattleEffectsController(BattleInterface & owner);
  51. void startAction(const BattleAction & action);
  52. //displays custom effect on the battlefield
  53. void displayEffect(EBattleEffect effect, const BattleHex & destTile);
  54. void displayEffect(EBattleEffect effect, const AudioPath & soundFile, const BattleHex & destTile);
  55. void battleTriggerEffect(const BattleTriggerEffect & bte);
  56. void collectRenderableObjects(BattleRenderer & renderer);
  57. friend class EffectAnimation;
  58. };