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:
Jelle Meeus 2024-06-26 22:24:59 +02:00 committed by GitHub
parent 77d3eb52df
commit 40b63666ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 2 deletions

View file

@ -61,6 +61,10 @@ void WaypointMovementGenerator<Creature>::DoFinalize(Creature* creature)
void WaypointMovementGenerator<Creature>::DoReset(Creature* creature)
{
if (stalled)
{
return;
}
creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
StartMoveNow(creature);
}
@ -209,6 +213,11 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
{
// Waypoint movement can be switched on/off
// 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())
{
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