BattleEffectsController.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. VCMI_LIB_NAMESPACE_BEGIN
  13. class BattleAction;
  14. struct CustomEffectInfo;
  15. struct BattleTriggerEffect;
  16. VCMI_LIB_NAMESPACE_END
  17. class CAnimation;
  18. class Canvas;
  19. class BattleInterface;
  20. class BattleRenderer;
  21. class CPointEffectAnimation;
  22. namespace EBattleEffect
  23. {
  24. enum EBattleEffect
  25. {
  26. // list of battle effects that have hardcoded triggers
  27. FEAR = 15,
  28. GOOD_LUCK = 18,
  29. GOOD_MORALE = 20,
  30. BAD_MORALE = 30,
  31. BAD_LUCK = 48,
  32. RESURRECT = 50,
  33. DRAIN_LIFE = 52, // hardcoded constant in CGameHandler
  34. POISON = 67,
  35. DEATH_BLOW = 73,
  36. REGENERATION = 74,
  37. MANA_DRAIN = 77,
  38. INVALID = -1,
  39. };
  40. }
  41. /// Struct for battle effect animation e.g. morale, prayer, armageddon, bless,...
  42. struct BattleEffect
  43. {
  44. int x, y; //position on the screen
  45. float currentFrame;
  46. std::shared_ptr<CAnimation> animation;
  47. int effectID; //uniqueID equal ot ID of appropriate CSpellEffectAnim
  48. BattleHex position; //Indicates if effect which hex the effect is drawn on
  49. };
  50. /// Controls rendering of effects in battle, e.g. from spells, abilities and various other actions like morale
  51. class BattleEffectsController
  52. {
  53. BattleInterface & owner;
  54. /// list of current effects that are being displayed on screen (spells & creature abilities)
  55. std::vector<BattleEffect> battleEffects;
  56. public:
  57. BattleEffectsController(BattleInterface & owner);
  58. void startAction(const BattleAction* action);
  59. void displayCustomEffects(const std::vector<CustomEffectInfo> & customEffects);
  60. //displays custom effect on the battlefield
  61. void displayEffect(EBattleEffect::EBattleEffect effect, const BattleHex & destTile);
  62. void displayEffect(EBattleEffect::EBattleEffect effect, uint32_t soundID, const BattleHex & destTile);
  63. //void displayEffects(EBattleEffect::EBattleEffect effect, uint32_t soundID, const std::vector<BattleHex> & destTiles);
  64. void battleTriggerEffect(const BattleTriggerEffect & bte);
  65. void collectRenderableObjects(BattleRenderer & renderer);
  66. friend class CPointEffectAnimation;
  67. };