diff options
| author | ccrs <ccrs@users.noreply.github.com> | 2017-08-12 01:40:25 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2020-08-23 00:45:46 +0200 |
| commit | 97585597f0b1aff93873fe4d757556731bc0c1b2 (patch) | |
| tree | fda9b11c6e7abb9e4d3a6108a09def640c3eb2af /src/server/game/Entities/Unit | |
| parent | a86870622dd02921c4d2e32983a5a98ee91e5263 (diff) | |
Core/Movement: waypoint movement (#20121)
Following the work done in #19361 this is the cleanup and improvement of the related logic of waypoint management.
Ref 28050f3 #18020
(taking the good parts and ignoring the incomplete work)
(cherry picked from commit 7fff83d67526efff63867d41b9e036a19a9287b3)
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 30 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 2 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index ff0e1ea8cb3..390d8ee7b3c 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -45,6 +45,7 @@ #include "LootPackets.h" #include "MiscPackets.h" #include "MotionMaster.h" +#include "MovementGenerator.h" #include "MovementPackets.h" #include "MoveSpline.h" #include "MoveSplineInit.h" @@ -10703,6 +10704,26 @@ void Unit::StopMoving() init.Stop(); } +void Unit::PauseMovement(uint32 timer/* = 0*/, uint8 slot/* = 0*/) +{ + if (slot >= MAX_MOTION_SLOT) + return; + + if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(slot)) + movementGenerator->Pause(timer); + + StopMoving(); +} + +void Unit::ResumeMovement(uint32 timer/* = 0*/, uint8 slot/* = 0*/) +{ + if (slot >= MAX_MOTION_SLOT) + return; + + if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(slot)) + movementGenerator->Resume(timer); +} + bool Unit::IsSitState() const { UnitStandStateType s = GetStandState(); @@ -11866,8 +11887,14 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au if (GetTypeId() == TYPEID_UNIT) { + if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE)) + movementGenerator->Pause(0); + + GetMotionMaster()->Clear(MOTION_SLOT_ACTIVE); + + StopMoving(); + ToCreature()->AI()->OnCharmed(true); - GetMotionMaster()->MoveIdle(); } else if (Player* player = ToPlayer()) { @@ -11981,6 +12008,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) else RestoreFaction(); + ///@todo Handle SLOT_IDLE motion resume GetMotionMaster()->InitDefault(); if (Creature* creature = ToCreature()) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index fb04300b841..fb2af4bb11c 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1909,6 +1909,8 @@ class TC_GAME_API Unit : public WorldObject bool IsStopped() const { return !(HasUnitState(UNIT_STATE_MOVING)); } void StopMoving(); + virtual void PauseMovement(uint32 timer = 0, uint8 slot = 0); // timer in ms + void ResumeMovement(uint32 timer = 0, uint8 slot = 0); void AddUnitMovementFlag(uint32 f) { m_movementInfo.AddMovementFlag(f); } void RemoveUnitMovementFlag(uint32 f) { m_movementInfo.RemoveMovementFlag(f); } |
