BattleEffectsController.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 = 0.0;
  36. float transparencyFactor = 1.0;
  37. std::shared_ptr<CAnimation> animation;
  38. int effectID; //uniqueID equal ot ID of appropriate CSpellEffectAnim
  39. BattleHex tile; //Indicates if effect which hex the effect is drawn on
  40. };
  41. /// Controls rendering of effects in battle, e.g. from spells, abilities and various other actions like morale
  42. class BattleEffectsController
  43. {
  44. BattleInterface & owner;
  45. /// list of current effects that are being displayed on screen (spells & creature abilities)
  46. std::vector<BattleEffect> battleEffects;
  47. std::map<std::string, ColorMuxerEffect> colorMuxerEffects;
  48. void loadColorMuxers();
  49. public:
  50. const ColorMuxerEffect &getMuxerEffect(const std::string & name);
  51. BattleEffectsController(BattleInterface & owner);
  52. void startAction(const BattleAction & action);
  53. //displays custom effect on the battlefield
  54. void displayEffect(EBattleEffect effect, const BattleHex & destTile);
  55. void displayEffect(EBattleEffect effect, const AudioPath & soundFile, const BattleHex & destTile, float transparencyFactor = 1.f);
  56. void battleTriggerEffect(const BattleTriggerEffect & bte);
  57. void collectRenderableObjects(BattleRenderer & renderer);
  58. friend class EffectAnimation;
  59. };