BattleEffectsController.h 2.0 KB

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