2
0

HeroMovementController.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * HeroMovementController.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/constants/EntityIdentifiers.h"
  12. #include "../lib/int3.h"
  13. #include "../lib/filesystem/ResourcePath.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. using TTeleportExitsList = std::vector<std::pair<ObjectInstanceID, int3>>;
  16. class CGHeroInstance;
  17. class CArmedInstance;
  18. struct CGPathNode;
  19. struct CGPath;
  20. struct TryMoveHero;
  21. enum class EPathNodeAction : ui8;
  22. VCMI_LIB_NAMESPACE_END
  23. class HeroMovementController
  24. {
  25. /// there is an ongoing movement loop, in one or another stage
  26. bool duringMovement = false;
  27. /// movement was requested to be terminated, e.g. by player or due to inability to move
  28. bool stoppingMovement = false;
  29. bool waitingForQueryApplyReply = false;
  30. const CGHeroInstance * currentlyMovingHero = nullptr;
  31. AudioPath currentMovementSoundName;
  32. int currentMovementSoundChannel = -1;
  33. bool canHeroStopAtNode(const CGPathNode & node) const;
  34. void updatePath(const CGHeroInstance * hero, const TryMoveHero & details);
  35. /// Moves hero 1 tile / path node
  36. void moveHeroOnce(const CGHeroInstance * h, const CGPath & path);
  37. void endHeroMove(const CGHeroInstance * h);
  38. AudioPath getMovementSoundFor(const CGHeroInstance * hero, int3 posPrev, int3 posNext, EPathNodeAction moveType);
  39. void updateMovementSound(const CGHeroInstance * hero, int3 posPrev, int3 posNext, EPathNodeAction moveType);
  40. void stopMovementSound();
  41. public:
  42. // const queries
  43. /// Returns true if hero should move through garrison without displaying garrison dialog
  44. bool isHeroMovingThroughGarrison(const CGHeroInstance * hero, const CArmedInstance * garrison) const;
  45. /// Returns true if there is an ongoing hero movement process
  46. bool isHeroMoving() const;
  47. // netpack handlers
  48. void onMoveHeroApplied();
  49. void onQueryReplyApplied();
  50. void onPlayerTurnStarted();
  51. void onBattleStarted();
  52. void showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID);
  53. void heroMoved(const CGHeroInstance * hero, const TryMoveHero & details);
  54. // UI handlers
  55. void movementStartRequested(const CGHeroInstance * h, const CGPath & path);
  56. void movementAbortRequested();
  57. };