/// <inheritdoc /> public MovementBlockData Convert(MovementBlockData_Vanilla fromObj) { if (fromObj == null) { return(null); } ObjectUpdateFlags flags = ObjectUpdateFlagsConverter.Convert(fromObj.UpdateFlags); //Should be null if the object isn't living. MovementInfo info = MoveInfoConverter.Convert(fromObj.MoveInfo); SplineInfo spline = SplineInfoConverter.Convert(fromObj.SplineInformation); CorpseInfo corpseInfo = CorpseInfoConverter.Convert(fromObj.DeadMovementInformation); MovementBlockData data = new MovementBlockData(flags, info, fromObj.MovementSpeeds?.Concat(Enumerable.Repeat(1.0f, 3))?.ToArray(), spline, corpseInfo, null, /*TC always sends 0 but we can try this*/ (int)fromObj.HighGuid, /*Mangos always sends for UPDATE_ALL 0x10 AKA LOW_GUID. We can try TC hack if this doesn't work*/ 0x1, /*This is target*/ flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_HAS_TARGET) ? fromObj.FullGuid : PackedGuid.Empty, fromObj.TransportTime, null, /*This is a packed QUATERRION but Vanilla doesn't send anything. TODO compute this*/ 0); return(data); }
void ReadMovementUpdateData(InPacket packet) { flags = (ObjectUpdateFlags)packet.ReadUInt16(); if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_LIVING)) { ReadMovementInfo(packet); movementSpeeds = new Dictionary<UnitMoveType,float>(); movementSpeeds[UnitMoveType.MOVE_WALK] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_RUN] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_RUN_BACK] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_SWIM] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_SWIM_BACK] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_FLIGHT] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_FLIGHT_BACK] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_TURN_RATE] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_PITCH_RATE] = packet.ReadSingle(); if (movementInfo.Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SPLINE_ENABLED)) { splineFlags = (SplineFlags)packet.ReadUInt32(); if (splineFlags.HasFlag(SplineFlags.Final_Angle)) splineFacingAngle = packet.ReadSingle(); else if (splineFlags.HasFlag(SplineFlags.Final_Target)) splineFacingTargetGuid = packet.ReadUInt64(); else if (splineFlags.HasFlag(SplineFlags.Final_Point)) splineFacingPointX = packet.ReadVector3(); splineTimePassed = packet.ReadInt32(); splineDuration = packet.ReadInt32(); splineId = packet.ReadUInt32(); packet.ReadSingle(); packet.ReadSingle(); splineVerticalAcceleration = packet.ReadSingle(); splineEffectStartTime = packet.ReadInt32(); uint splineCount = packet.ReadUInt32(); for (uint index = 0; index < splineCount; index++) splinePoints.Add(packet.ReadVector3()); splineEvaluationMode = (SplineEvaluationMode)packet.ReadByte(); splineEndPoint = packet.ReadVector3(); } } else if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_POSITION)) { transportGuid = packet.ReadPackedGuid(); position = packet.ReadVector3(); transportOffset = packet.ReadVector3(); o = packet.ReadSingle(); corpseOrientation = packet.ReadSingle(); } else if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_STATIONARY_POSITION)) { position = packet.ReadVector3(); o = packet.ReadSingle(); } if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_UNKNOWN)) packet.ReadUInt32(); if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_LOWGUID)) lowGuid = packet.ReadUInt32(); if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_HAS_TARGET)) targetGuid = packet.ReadPackedGuid(); if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_TRANSPORT)) transportTimer = packet.ReadUInt32(); if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_VEHICLE)) { vehicledID = packet.ReadUInt32(); vehicleOrientation = packet.ReadSingle(); } if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_ROTATION)) goRotation = packet.ReadInt64(); }
void ReadMovementUpdateData(InPacket packet) { flags = (ObjectUpdateFlags)packet.ReadUInt16(); if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_LIVING)) { ReadMovementInfo(packet); movementSpeeds = new Dictionary <UnitMoveType, float>(); movementSpeeds[UnitMoveType.MOVE_WALK] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_RUN] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_RUN_BACK] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_SWIM] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_SWIM_BACK] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_FLIGHT] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_FLIGHT_BACK] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_TURN_RATE] = packet.ReadSingle(); movementSpeeds[UnitMoveType.MOVE_PITCH_RATE] = packet.ReadSingle(); if (movementInfo.Flags.HasFlag(MovementFlags.MOVEMENTFLAG_SPLINE_ENABLED)) { splineFlags = (SplineFlags)packet.ReadUInt32(); if (splineFlags.HasFlag(SplineFlags.Final_Angle)) { splineFacingAngle = packet.ReadSingle(); } else if (splineFlags.HasFlag(SplineFlags.Final_Target)) { splineFacingTargetGuid = packet.ReadUInt64(); } else if (splineFlags.HasFlag(SplineFlags.Final_Point)) { splineFacingPointX = packet.ReadVector3(); } splineTimePassed = packet.ReadInt32(); splineDuration = packet.ReadInt32(); splineId = packet.ReadUInt32(); packet.ReadSingle(); packet.ReadSingle(); splineVerticalAcceleration = packet.ReadSingle(); splineEffectStartTime = packet.ReadInt32(); uint splineCount = packet.ReadUInt32(); for (uint index = 0; index < splineCount; index++) { splinePoints.Add(packet.ReadVector3()); } splineEvaluationMode = (SplineEvaluationMode)packet.ReadByte(); splineEndPoint = packet.ReadVector3(); } } else if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_POSITION)) { transportGuid = packet.ReadPackedGuid(); position = packet.ReadVector3(); transportOffset = packet.ReadVector3(); o = packet.ReadSingle(); corpseOrientation = packet.ReadSingle(); } else if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_STATIONARY_POSITION)) { position = packet.ReadVector3(); o = packet.ReadSingle(); } if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_UNKNOWN)) { packet.ReadUInt32(); } if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_LOWGUID)) { lowGuid = packet.ReadUInt32(); } if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_HAS_TARGET)) { targetGuid = packet.ReadPackedGuid(); } if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_TRANSPORT)) { transportTimer = packet.ReadUInt32(); } if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_VEHICLE)) { vehicledID = packet.ReadUInt32(); vehicleOrientation = packet.ReadSingle(); } if (flags.HasFlag(ObjectUpdateFlags.UPDATEFLAG_ROTATION)) { goRotation = packet.ReadInt64(); } }