2023-09-07 21:37:42 +02:00
|
|
|
/*
|
|
|
|
* CPlayerInterface.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../lib/constants/EntityIdentifiers.h"
|
|
|
|
#include "../lib/int3.h"
|
2023-09-11 11:54:25 +02:00
|
|
|
#include "../lib/filesystem/ResourcePath.h"
|
2023-09-07 21:37:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
using TTeleportExitsList = std::vector<std::pair<ObjectInstanceID, int3>>;
|
|
|
|
|
|
|
|
class CGHeroInstance;
|
2023-09-08 17:02:36 +02:00
|
|
|
class CArmedInstance;
|
2023-09-15 21:18:36 +02:00
|
|
|
struct CGPathNode;
|
2023-09-07 21:37:42 +02:00
|
|
|
|
|
|
|
struct CGPath;
|
|
|
|
struct TryMoveHero;
|
2023-09-11 11:54:25 +02:00
|
|
|
enum class EPathNodeAction : ui8;
|
2023-09-07 21:37:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
|
|
|
class HeroMovementController
|
|
|
|
{
|
2023-09-15 21:18:36 +02:00
|
|
|
/// there is an ongoing movement loop, in one or another stage
|
|
|
|
bool duringMovement = false;
|
|
|
|
/// movement was requested to be terminated, e.g. by player or due to inability to move
|
|
|
|
bool stoppingMovement = false;
|
2023-09-07 21:37:42 +02:00
|
|
|
|
2023-09-16 12:40:49 +02:00
|
|
|
const CGHeroInstance * currentlyMovingHero = nullptr;
|
2023-09-15 21:18:36 +02:00
|
|
|
AudioPath currentMovementSoundName;
|
|
|
|
int currentMovementSoundChannel = -1;
|
2023-09-07 21:37:42 +02:00
|
|
|
|
2023-09-15 21:18:36 +02:00
|
|
|
/// return final node in a path, if exists
|
|
|
|
std::optional<int3> getLastTile(const CGHeroInstance * h) const;
|
|
|
|
/// return first path in a path, if exists
|
|
|
|
std::optional<int3> getNextTile(const CGHeroInstance * h) const;
|
2023-09-07 21:37:42 +02:00
|
|
|
|
2023-09-15 21:18:36 +02:00
|
|
|
bool canHeroStopAtNode(const CGPathNode & node) const;
|
2023-09-07 21:37:42 +02:00
|
|
|
|
2023-09-15 21:18:36 +02:00
|
|
|
void updatePath(const CGHeroInstance * hero, const TryMoveHero & details);
|
2023-09-08 17:02:36 +02:00
|
|
|
|
2023-09-15 21:18:36 +02:00
|
|
|
/// Moves hero 1 tile / path node
|
|
|
|
void moveHeroOnce(const CGHeroInstance * h, const CGPath & path);
|
2023-09-11 11:54:25 +02:00
|
|
|
|
2023-09-15 21:18:36 +02:00
|
|
|
void endHeroMove(const CGHeroInstance * h);
|
2023-09-11 11:54:25 +02:00
|
|
|
|
|
|
|
AudioPath getMovementSoundFor(const CGHeroInstance * hero, int3 posPrev, int3 posNext, EPathNodeAction moveType);
|
|
|
|
void updateMovementSound(const CGHeroInstance * hero, int3 posPrev, int3 posNext, EPathNodeAction moveType);
|
|
|
|
void stopMovementSound();
|
2023-09-07 21:37:42 +02:00
|
|
|
|
2023-09-15 21:18:36 +02:00
|
|
|
public:
|
2023-09-08 17:02:36 +02:00
|
|
|
// const queries
|
|
|
|
bool isHeroMovingThroughGarrison(const CGHeroInstance * hero, const CArmedInstance * garrison) const;
|
2023-09-07 21:37:42 +02:00
|
|
|
bool isHeroMoving() const;
|
|
|
|
|
2023-09-08 17:02:36 +02:00
|
|
|
// netpack handlers
|
2023-09-07 21:37:42 +02:00
|
|
|
void onMoveHeroApplied();
|
|
|
|
void onPlayerTurnStarted();
|
|
|
|
void onBattleStarted();
|
2023-09-15 21:18:36 +02:00
|
|
|
void showTeleportDialog(const CGHeroInstance * hero, TeleportChannelID channel, TTeleportExitsList exits, bool impassable, QueryID askID);
|
2023-09-07 21:37:42 +02:00
|
|
|
void heroMoved(const CGHeroInstance * hero, const TryMoveHero & details);
|
|
|
|
|
2023-09-08 17:02:36 +02:00
|
|
|
// UI handlers
|
|
|
|
void movementStartRequested(const CGHeroInstance * h, const CGPath & path);
|
2023-09-15 21:18:36 +02:00
|
|
|
void movementAbortRequested();
|
2023-09-07 21:37:42 +02:00
|
|
|
};
|