Core/Movement: Defined movement force type enum

This commit is contained in:
Shauren
2021-12-08 19:02:02 +01:00
parent 8341082ac4
commit e2de5000ac
4 changed files with 13 additions and 6 deletions

View File

@@ -110,6 +110,12 @@ struct MovementInfo
void OutDebug();
};
enum class MovementForceType : uint8
{
SingleDirectional = 0, // always in a single direction
Gravity = 1 // pushes/pulls away from a single point
};
struct MovementForce
{
ObjectGuid ID;
@@ -117,7 +123,7 @@ struct MovementForce
TaggedPosition<Position::XYZ> Direction;
uint32 TransportID = 0;
float Magnitude = 0.0f;
uint8 Type = 0;
MovementForceType Type = MovementForceType::SingleDirectional;
int32 Unused910 = 0;
};

View File

@@ -12731,7 +12731,7 @@ void Unit::SendSetVehicleRecId(uint32 vehicleId)
SendMessageToSet(setVehicleRec.Write(), true);
}
void Unit::ApplyMovementForce(ObjectGuid id, Position origin, float magnitude, uint8 type, Position direction /*= {}*/, ObjectGuid transportGuid /*= ObjectGuid::Empty*/)
void Unit::ApplyMovementForce(ObjectGuid id, Position origin, float magnitude, MovementForceType type, Position direction /*= {}*/, ObjectGuid transportGuid /*= ObjectGuid::Empty*/)
{
if (!_movementForces)
_movementForces = std::make_unique<MovementForces>();

View File

@@ -1219,7 +1219,7 @@ class TC_GAME_API Unit : public WorldObject
void SendSetVehicleRecId(uint32 vehicleId);
MovementForces const* GetMovementForces() const { return _movementForces.get(); }
void ApplyMovementForce(ObjectGuid id, Position origin, float magnitude, uint8 type, Position direction = {}, ObjectGuid transportGuid = ObjectGuid::Empty);
void ApplyMovementForce(ObjectGuid id, Position origin, float magnitude, MovementForceType type, Position direction = {}, ObjectGuid transportGuid = ObjectGuid::Empty);
void RemoveMovementForce(ObjectGuid id);
bool SetIgnoreMovementForces(bool ignore);
void UpdateMovementForcesModMagnitude();

View File

@@ -21,6 +21,7 @@
#include "MovementTypedefs.h"
#include "PacketUtilities.h"
#include "Unit.h"
#include "Util.h"
ByteBuffer& operator<<(ByteBuffer& data, MovementInfo const& movementInfo)
{
@@ -438,7 +439,7 @@ void WorldPackets::Movement::CommonMovement::WriteMovementForceWithDirection(Mov
{
data << movementForce.ID;
data << movementForce.Origin;
if (movementForce.Type == 1 && objectPosition) // gravity
if (movementForce.Type == MovementForceType::Gravity && objectPosition)
{
TaggedPosition<Position::XYZ> direction;
if (movementForce.Magnitude != 0.0f)
@@ -468,7 +469,7 @@ void WorldPackets::Movement::CommonMovement::WriteMovementForceWithDirection(Mov
data << uint32(movementForce.TransportID);
data << float(movementForce.Magnitude);
data.WriteBits(movementForce.Type, 2);
data.WriteBits(AsUnderlyingType(movementForce.Type), 2);
data.WriteBit(movementForce.Unused910 != 0);
data.FlushBits();
@@ -696,7 +697,7 @@ ByteBuffer& operator>>(ByteBuffer& data, MovementForce& movementForce)
data >> movementForce.Direction;
data >> movementForce.TransportID;
data >> movementForce.Magnitude;
movementForce.Type = data.ReadBits(2);
movementForce.Type = MovementForceType(data.ReadBits(2));
bool has910 = data.ReadBit();
if (has910)
data >> movementForce.Unused910;