2
0

CBattleStacksController.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * CBattleStacksController.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. struct BattleObjectsByHex;
  12. struct SDL_Surface;
  13. struct BattleHex;
  14. struct StackAttackedInfo;
  15. struct BattleAction;
  16. class SpellID;
  17. class CBattleInterface;
  18. class CBattleAnimation;
  19. class CCreatureAnimation;
  20. class CStack;
  21. class CBattleAnimation;
  22. class IImage;
  23. class CBattleStacksController
  24. {
  25. CBattleInterface * owner;
  26. std::shared_ptr<IImage> amountNormal;
  27. std::shared_ptr<IImage> amountNegative;
  28. std::shared_ptr<IImage> amountPositive;
  29. std::shared_ptr<IImage> amountEffNeutral;
  30. std::list<std::pair<CBattleAnimation *, bool>> pendingAnims; //currently displayed animations <anim, initialized>
  31. std::map<int32_t, std::shared_ptr<CCreatureAnimation>> creAnims; //animations of creatures from fighting armies (order by BattleInfo's stacks' ID)
  32. std::map<int, bool> creDir; // <creatureID, if false reverse creature's animation> //TODO: move it to battle callback
  33. const CStack *activeStack; //number of active stack; nullptr - no one
  34. const CStack *mouseHoveredStack; // stack below mouse pointer, used for border animation
  35. const CStack *stackToActivate; //when animation is playing, we should wait till the end to make the next stack active; nullptr of none
  36. const CStack *selectedStack; //for Teleport / Sacrifice
  37. bool stackCanCastSpell; //if true, active stack could possibly cast some target spell
  38. si32 creatureSpellToCast;
  39. ui32 animIDhelper; //for giving IDs for animations
  40. bool stackNeedsAmountBox(const CStack * stack);
  41. void showStackAmountBox(SDL_Surface *to, const CStack * stack);
  42. public:
  43. CBattleStacksController(CBattleInterface * owner);
  44. bool shouldRotate(const CStack * stack, const BattleHex & oldPos, const BattleHex & nextHex);
  45. bool facingRight(const CStack * stack);
  46. void stackReset(const CStack * stack);
  47. void stackAdded(const CStack * stack); //new stack appeared on battlefield
  48. void stackRemoved(uint32_t stackID); //stack disappeared from batlefiled
  49. void stackActivated(const CStack *stack); //active stack has been changed
  50. void stackMoved(const CStack *stack, std::vector<BattleHex> destHex, int distance); //stack with id number moved to destHex
  51. void stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked
  52. void stackAttacking(const CStack *attacker, BattleHex dest, const CStack *attacked, bool shooting); //called when stack with id ID is attacking something on hex dest
  53. void startAction(const BattleAction* action);
  54. void endAction(const BattleAction* action);
  55. bool activeStackSpellcaster();
  56. SpellID activeStackSpellToCast();
  57. void activateStack(); //sets activeStack to stackToActivate etc. //FIXME: No, it's not clear at all
  58. void setActiveStack(const CStack *stack);
  59. void setHoveredStack(const CStack *stack);
  60. void setSelectedStack(const CStack *stack);
  61. void showAliveStack(SDL_Surface *to, const CStack * stack);
  62. void showStack(SDL_Surface *to, const CStack * stack);
  63. void showBattlefieldObjects(SDL_Surface *to, const BattleHex & location );
  64. void addNewAnim(CBattleAnimation *anim); //adds new anim to pendingAnims
  65. void updateBattleAnimations();
  66. const CStack* getActiveStack();
  67. const CStack* getSelectedStack();
  68. friend class CBattleAnimation; // for exposing pendingAnims/creAnims/creDir to animations
  69. };