feat(Core/Movement): implement Pause and Resume to WaypointMovementGenerator (#19176)
* implement Pause and Resume for WaypointMovementGenerator Co-authored-by: ccrs <ccrs@users.noreply.github.com> * prevent restart from external sources if wp is paused * don't update stopmove on every update SetFacing breaks otherwise * timer args not used --------- Co-authored-by: ccrs <ccrs@users.noreply.github.com>
This commit is contained in:
@@ -61,6 +61,10 @@ void WaypointMovementGenerator<Creature>::DoFinalize(Creature* creature)
|
|||||||
|
|
||||||
void WaypointMovementGenerator<Creature>::DoReset(Creature* creature)
|
void WaypointMovementGenerator<Creature>::DoReset(Creature* creature)
|
||||||
{
|
{
|
||||||
|
if (stalled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
|
creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
|
||||||
StartMoveNow(creature);
|
StartMoveNow(creature);
|
||||||
}
|
}
|
||||||
@@ -209,6 +213,11 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
|
|||||||
{
|
{
|
||||||
// Waypoint movement can be switched on/off
|
// Waypoint movement can be switched on/off
|
||||||
// This is quite handy for escort quests and other stuff
|
// This is quite handy for escort quests and other stuff
|
||||||
|
if (stalled)
|
||||||
|
{
|
||||||
|
Stop(1000);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE) || creature->IsMovementPreventedByCasting())
|
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE) || creature->IsMovementPreventedByCasting())
|
||||||
{
|
{
|
||||||
creature->StopMoving();
|
creature->StopMoving();
|
||||||
@@ -278,6 +287,17 @@ void WaypointMovementGenerator<Creature>::MovementInform(Creature* creature)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaypointMovementGenerator<Creature>::Pause(uint32 /*timer*/)
|
||||||
|
{
|
||||||
|
stalled = true;
|
||||||
|
i_nextMoveTime.Reset(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointMovementGenerator<Creature>::Resume(uint32 /*overrideTimer/*/)
|
||||||
|
{
|
||||||
|
stalled = false;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------//
|
//----------------------------------------------------//
|
||||||
|
|
||||||
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
|
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
|
||||||
|
|||||||
@@ -54,13 +54,15 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium< Crea
|
|||||||
public PathMovementBase<Creature, WaypointPath const*>
|
public PathMovementBase<Creature, WaypointPath const*>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WaypointMovementGenerator(uint32 _path_id = 0, bool _repeating = true)
|
WaypointMovementGenerator(uint32 _path_id = 0, bool _repeating = true, bool _stalled = false)
|
||||||
: PathMovementBase((WaypointPath const*)nullptr), i_nextMoveTime(0), m_isArrivalDone(false), path_id(_path_id), repeating(_repeating) {}
|
: PathMovementBase((WaypointPath const*)nullptr), i_nextMoveTime(0), m_isArrivalDone(false), path_id(_path_id), repeating(_repeating), stalled(_stalled) {}
|
||||||
~WaypointMovementGenerator() { i_path = nullptr; }
|
~WaypointMovementGenerator() { i_path = nullptr; }
|
||||||
void DoInitialize(Creature*);
|
void DoInitialize(Creature*);
|
||||||
void DoFinalize(Creature*);
|
void DoFinalize(Creature*);
|
||||||
void DoReset(Creature*);
|
void DoReset(Creature*);
|
||||||
bool DoUpdate(Creature*, uint32 diff);
|
bool DoUpdate(Creature*, uint32 diff);
|
||||||
|
void Pause(uint32 timer/* = 0*/);
|
||||||
|
void Resume(uint32 overrideTimer/* = 0*/);
|
||||||
|
|
||||||
void MovementInform(Creature*);
|
void MovementInform(Creature*);
|
||||||
|
|
||||||
@@ -93,6 +95,7 @@ private:
|
|||||||
bool m_isArrivalDone;
|
bool m_isArrivalDone;
|
||||||
uint32 path_id;
|
uint32 path_id;
|
||||||
bool repeating;
|
bool repeating;
|
||||||
|
bool stalled;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** FlightPathMovementGenerator generates movement of the player for the paths
|
/** FlightPathMovementGenerator generates movement of the player for the paths
|
||||||
|
|||||||
Reference in New Issue
Block a user