diff options
| author | ccrs <ccrs@users.noreply.github.com> | 2018-06-03 10:06:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-03 10:06:57 -0700 |
| commit | 982643cd96790ffc54e7a3e507469649f3b074d2 (patch) | |
| tree | 90e65482d064fc9b2e8d0e215f2dec6e5fe663c9 /src/server/game/Entities/Unit | |
| parent | b84348f6fc7746349fdcbd443b32fe5483174442 (diff) | |
Core/Movement: MotionMaster reimplementation (#21888)
Internal structure and handling changes, nothing behavioural (or thats the intention at least).
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 7c78ca3f649..4817ef51515 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -452,7 +452,7 @@ void Unit::Update(uint32 p_time) } UpdateSplineMovement(p_time); - i_motionMaster->UpdateMotion(p_time); + i_motionMaster->Update(p_time); } bool Unit::haveOffhandWeapon() const @@ -468,7 +468,7 @@ void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool gen Movement::MoveSplineInit init(this); init.MoveTo(x, y, z, generatePath, forceDestination); init.SetVelocity(speed); - GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_SLOT_ACTIVE, POINT_MOTION_TYPE); + GetMotionMaster()->LaunchMoveSpline(std::move(init), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE); } void Unit::UpdateSplineMovement(uint32 t_diff) @@ -8543,7 +8543,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype) { if (GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE) { - Unit* followed = ASSERT_NOTNULL(dynamic_cast<AbstractFollower*>(GetMotionMaster()->top()))->GetTarget(); + Unit* followed = ASSERT_NOTNULL(dynamic_cast<AbstractFollower*>(GetMotionMaster()->GetCurrentMovementGenerator()))->GetTarget(); if (followed && followed->GetGUID() == GetOwnerGUID() && !followed->IsInCombat()) { float ownerSpeed = followed->GetSpeedRate(mtype); @@ -8698,7 +8698,7 @@ void Unit::setDeathState(DeathState s) // * Using 'call pet' on dead pets // * Using 'call stabled pet' // * Logging in with dead pets - GetMotionMaster()->Clear(false); + GetMotionMaster()->Clear(); GetMotionMaster()->MoveIdle(); } StopMoving(); @@ -10186,10 +10186,10 @@ void Unit::PauseMovement(uint32 timer/* = 0*/, uint8 slot/* = 0*/, bool forced/* if (IsInvalidMovementSlot(slot)) return; - if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(MovementSlot(slot))) + if (MovementGenerator* movementGenerator = GetMotionMaster()->GetCurrentMovementGenerator(MovementSlot(slot))) movementGenerator->Pause(timer); - if (forced) + if (forced && GetMotionMaster()->GetCurrentSlot() == MovementSlot(slot)) StopMoving(); } @@ -10198,7 +10198,7 @@ void Unit::ResumeMovement(uint32 timer/* = 0*/, uint8 slot/* = 0*/) if (IsInvalidMovementSlot(slot)) return; - if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(MovementSlot(slot))) + if (MovementGenerator* movementGenerator = GetMotionMaster()->GetCurrentMovementGenerator(MovementSlot(slot))) movementGenerator->Resume(timer); } @@ -11274,8 +11274,7 @@ void Unit::SetFeared(bool apply) { if (IsAlive()) { - if (GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE) - GetMotionMaster()->MovementExpired(); + GetMotionMaster()->Remove(FLEEING_MOTION_TYPE); if (GetVictim()) SetTarget(EnsureVictim()->GetGUID()); } @@ -11300,8 +11299,7 @@ void Unit::SetConfused(bool apply) { if (IsAlive()) { - if (GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE) - GetMotionMaster()->MovementExpired(); + GetMotionMaster()->Remove(CONFUSED_MOTION_TYPE); if (GetVictim()) SetTarget(EnsureVictim()->GetGUID()); } @@ -11393,10 +11391,8 @@ 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); + PauseMovement(0, 0, false); + GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL); StopMoving(); @@ -11515,7 +11511,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) RestoreFaction(); ///@todo Handle SLOT_IDLE motion resume - GetMotionMaster()->InitDefault(); + GetMotionMaster()->InitializeDefault(); if (Creature* creature = ToCreature()) { @@ -11584,8 +11580,6 @@ void Unit::RemoveCharmedBy(Unit* charmer) player->SetClientControl(this, true); } - EngageWithTarget(charmer); - // a guardian should always have charminfo if (playerCharmer && this != charmer->GetFirstControlled()) playerCharmer->SendRemoveControlBar(); @@ -12619,7 +12613,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false); init.SetFacing(GetOrientation()); init.SetTransportExit(); - GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_EXIT, MOTION_SLOT_CONTROLLED); + GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_EXIT, MOTION_PRIORITY_HIGHEST); if (player) player->ResummonPetTemporaryUnSummonedIfAny(); @@ -13041,7 +13035,7 @@ void Unit::SetFacingTo(float ori, bool force) init.DisableTransportPathTransformations(); // It makes no sense to target global orientation init.SetFacing(ori); - //GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_FACE, MOTION_SLOT_CONTROLLED); + //GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_FACE, MOTION_PRIORITY_HIGHEST); init.Launch(); } @@ -13056,7 +13050,7 @@ void Unit::SetFacingToObject(WorldObject const* object, bool force) init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZ(), false); init.SetFacing(GetAbsoluteAngle(object)); // when on transport, GetAbsoluteAngle will still return global coordinates (and angle) that needs transforming - //GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_FACE, MOTION_SLOT_CONTROLLED); + //GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_FACE, MOTION_PRIORITY_HIGHEST); init.Launch(); } |
