Core/Movement: split SetCanFly for player and creature class and handle their part accordingly
This commit is contained in:
1 parent
fbc1b8565a
commit
5ca475a764
3 files changed
+33
-20
No files matched your search
@@ -1112,6 +1112,10 @@ bool Creature::SetDisableGravity(bool disable, bool packetOnly /*= false*/, bool
|
||||
SetAnimationTier(AnimationTier::Ground);
|
||||
}
|
||||
|
||||
WorldPacket data(disable ? SMSG_SPLINE_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE);
|
||||
WriteMovementInfo(data);
|
||||
SendMessageToSet(&data, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1133,6 +1137,16 @@ bool Creature::SetHover(bool enable, bool packetOnly /*= false*/, bool updateAni
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Creature::SetCanFly(bool enable, bool packetOnly /*= false*/)
|
||||
{
|
||||
if (!Unit::SetCanFly(enable, packetOnly))
|
||||
return false;
|
||||
|
||||
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING);
|
||||
WriteMovementInfo(data);
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
||||
void Creature::InitializeReactState()
|
||||
{
|
||||
if (IsTotem() || IsTrigger() || IsCritter() || IsSpiritService())
|
||||
|
||||
@@ -101,6 +101,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool CanHover() const { return GetMovementTemplate().IsHoverEnabled() || IsHovering(); }
|
||||
bool SetDisableGravity(bool disable, bool packetOnly = false, bool updateAnimationTier = true) override;
|
||||
bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true) override;
|
||||
bool SetCanFly(bool enable, bool packetOnly = false) override;
|
||||
|
||||
bool IsDungeonBoss() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS) != 0; }
|
||||
bool IsAffectedByDiminishingReturns() const override { return Unit::IsAffectedByDiminishingReturns() || (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH) != 0; }
|
||||
|
||||
@@ -13892,8 +13892,12 @@ void Unit::PurgeAndApplyPendingMovementChanges(bool informObservers /* = true */
|
||||
case MovementChangeType::SPEED_CHANGE_FLIGHT_SPEED: moveType = MOVE_FLIGHT; break;
|
||||
case MovementChangeType::SPEED_CHANGE_FLIGHT_BACK_SPEED: moveType = MOVE_FLIGHT_BACK; break;
|
||||
case MovementChangeType::RATE_CHANGE_PITCH: moveType = MOVE_PITCH_RATE; break;
|
||||
case MovementChangeType::GRAVITY_DISABLE: break;
|
||||
case MovementChangeType::SET_CAN_FLY: break;
|
||||
case MovementChangeType::GRAVITY_DISABLE:
|
||||
Unit::SetDisableGravity(pendingChange.second.apply);
|
||||
break;
|
||||
case MovementChangeType::SET_CAN_FLY:
|
||||
Unit::SetCanFly(pendingChange.second.apply);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false);
|
||||
return;
|
||||
@@ -13907,6 +13911,18 @@ void Unit::PurgeAndApplyPendingMovementChanges(bool informObservers /* = true */
|
||||
if (informObservers)
|
||||
MovementPacketSender::SendSpeedChangeToObservers(this, *moveType, speedFlat);
|
||||
}
|
||||
else if (informObservers)
|
||||
{
|
||||
switch (changeType)
|
||||
{
|
||||
case MovementChangeType::GRAVITY_DISABLE:
|
||||
case MovementChangeType::SET_CAN_FLY:
|
||||
MovementPacketSender::SendMovementFlagChangeToObservers(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pendingMovementChanges.clear();
|
||||
@@ -14199,14 +14215,6 @@ bool Unit::SetDisableGravity(bool disable, bool packetOnly /*= false*/, bool /*u
|
||||
}
|
||||
}
|
||||
|
||||
WorldPacket data;
|
||||
if (disable)
|
||||
data.Initialize(IsMovedByClient() ? SMSG_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_DISABLE);
|
||||
else
|
||||
data.Initialize(IsMovedByClient() ? SMSG_MOVE_GRAVITY_ENABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE);
|
||||
|
||||
WriteMovementInfo(data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14269,16 +14277,6 @@ bool Unit::SetCanFly(bool enable, bool packetOnly)
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
RemoveExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_SWIM_TO_FLY_TRANS);
|
||||
}
|
||||
|
||||
if (Player* player = ToPlayer())
|
||||
player->SendMovementSetCanTransitionBetweenSwimAndFly(enable);
|
||||
}
|
||||
|
||||
if (IsCreature())
|
||||
{
|
||||
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING);
|
||||
WriteMovementInfo(data);
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user