BattleEffectsController.h 2.2 KB

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