public static void WriteCreateBits(MoveSpline moveSpline, ref PacketWriter data) { if (!moveSpline.Finalized()) { return; } data.WriteBit(moveSpline.Finalized()); data.WriteBits(moveSpline.getPath().Length, 22); data.WriteBits(moveSpline.splineflags.Raw(), 25); switch (moveSpline.splineflags.Raw() & MoveSplineFlag.eFlags.Mask_Final_Facing) { case MoveSplineFlag.eFlags.Final_Target: { ObjectGuid targetGuid = new ObjectGuid(moveSpline.facing.target); data.WriteBits(1, 2); data.WriteBit(targetGuid[0]); data.WriteBit(targetGuid[1]); data.WriteBit(targetGuid[6]); data.WriteBit(targetGuid[5]); data.WriteBit(targetGuid[2]); data.WriteBit(targetGuid[3]); data.WriteBit(targetGuid[4]); data.WriteBit(targetGuid[7]); break; } case MoveSplineFlag.eFlags.Final_Angle: data.WriteBits(0, 2); break; case MoveSplineFlag.eFlags.Final_Point: data.WriteBits(3, 2); break; default: data.WriteBits(2, 2); break; } data.WriteBits(moveSpline.spline.m_mode, 2); data.WriteBit(Convert.ToBoolean(moveSpline.splineflags.Raw() & MoveSplineFlag.eFlags.Parabolic) && moveSpline.effect_start_time < moveSpline.Duration()); }
public static void WriteCreateData(MoveSpline moveSpline, ref PacketWriter data) { if (!moveSpline.Finalized()) { MoveSplineFlag splineFlags = moveSpline.splineflags; if (splineFlags.final_target) { ObjectGuid facingGuid = new ObjectGuid(moveSpline.facing.target); data.WriteByteSeq(facingGuid[3]); data.WriteByteSeq(facingGuid[2]); data.WriteByteSeq(facingGuid[0]); data.WriteByteSeq(facingGuid[5]); data.WriteByteSeq(facingGuid[6]); data.WriteByteSeq(facingGuid[7]); data.WriteByteSeq(facingGuid[4]); data.WriteByteSeq(facingGuid[1]); } data.WriteInt32(moveSpline.timePassed()); data.WriteUInt32(moveSpline.Duration()); if (Convert.ToBoolean(splineFlags.Raw() & MoveSplineFlag.eFlags.Parabolic) && moveSpline.effect_start_time < moveSpline.Duration()) { data.WriteFloat(moveSpline.vertical_acceleration); } data.WriteFloat(1.0f); // splineInfo.duration_mod_next; added in 3.1 data.WriteFloat(1.0f); // splineInfo.duration_mod; added in 3.1 if (splineFlags.final_point) { data.WriteFloat(moveSpline.facing.x); data.WriteFloat(moveSpline.facing.y); data.WriteFloat(moveSpline.facing.z); } if (Convert.ToBoolean(splineFlags.Raw() & (MoveSplineFlag.eFlags.Parabolic | MoveSplineFlag.eFlags.Animation))) { data.WriteInt32(moveSpline.effect_start_time); // added in 3.1 } int nodes = moveSpline.getPath().Length; for (var i = 0; i < nodes; ++i) { data.WriteFloat(moveSpline.getPath()[i].Z); data.WriteFloat(moveSpline.getPath()[i].X); data.WriteFloat(moveSpline.getPath()[i].Y); } if (splineFlags.final_angle) { data.WriteFloat(moveSpline.facing.angle); } } if (!moveSpline.isCyclic()) { Vector3 dest = moveSpline.FinalDestination(); data.WriteFloat(dest.Z); data.WriteFloat(dest.X); data.WriteFloat(dest.Y); } else { data.WriteVec3(Vector3.Zero); } data.WriteUInt32(moveSpline.GetId()); }