Removed LVector, LQuaternion.
Server side optimization. Nework optimization (streaming distance).
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using GTA.Math;
|
||||
|
||||
namespace RageCoop.Core
|
||||
{
|
||||
@ -103,18 +104,18 @@ namespace RageCoop.Core
|
||||
return value;
|
||||
}
|
||||
|
||||
public LVector3 ReadLVector3()
|
||||
public Vector3 ReadVector3()
|
||||
{
|
||||
return new LVector3()
|
||||
return new Vector3()
|
||||
{
|
||||
X = ReadFloat(),
|
||||
Y = ReadFloat(),
|
||||
Z = ReadFloat()
|
||||
};
|
||||
}
|
||||
public LQuaternion ReadLQuaternion()
|
||||
public Quaternion ReadLQuaternion()
|
||||
{
|
||||
return new LQuaternion()
|
||||
return new Quaternion()
|
||||
{
|
||||
X = ReadFloat(),
|
||||
Y = ReadFloat(),
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GTA.Math;
|
||||
namespace RageCoop.Core
|
||||
{
|
||||
public class CoreUtils
|
||||
@ -37,13 +38,13 @@ namespace RageCoop.Core
|
||||
}
|
||||
public static class Extensions
|
||||
{
|
||||
public static void AddLVector3(this List<byte> bytes, LVector3 vec3)
|
||||
public static void AddVector3(this List<byte> bytes, Vector3 vec3)
|
||||
{
|
||||
bytes.AddRange(BitConverter.GetBytes(vec3.X));
|
||||
bytes.AddRange(BitConverter.GetBytes(vec3.Y));
|
||||
bytes.AddRange(BitConverter.GetBytes(vec3.Z));
|
||||
}
|
||||
public static void AddLQuaternion(this List<byte> bytes, LQuaternion quat)
|
||||
public static void AddQuaternion(this List<byte> bytes, Quaternion quat)
|
||||
{
|
||||
bytes.AddRange(BitConverter.GetBytes(quat.X));
|
||||
bytes.AddRange(BitConverter.GetBytes(quat.Y));
|
||||
|
@ -7,6 +7,7 @@ using GTA.Math;
|
||||
|
||||
namespace RageCoop.Core
|
||||
{
|
||||
/*
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -111,7 +112,7 @@ namespace RageCoop.Core
|
||||
/// </summary>
|
||||
public float W { get; set; }
|
||||
}
|
||||
|
||||
*/
|
||||
public enum PacketTypes:byte
|
||||
{
|
||||
Handshake=0,
|
||||
@ -190,6 +191,7 @@ namespace RageCoop.Core
|
||||
IsOnLadder = 1 << 8,
|
||||
IsVaulting = 1 << 9,
|
||||
IsInCover=1<< 10,
|
||||
IsPlayer=1<<11,
|
||||
}
|
||||
|
||||
#region ===== VEHICLE DATA =====
|
||||
@ -493,10 +495,10 @@ namespace RageCoop.Core
|
||||
byteArray.AddRange(BitConverter.GetBytes(stringBytes.Length));
|
||||
byteArray.AddRange(stringBytes);
|
||||
}
|
||||
else if (type == typeof(LVector3))
|
||||
else if (type == typeof(Vector3))
|
||||
{
|
||||
byteArray.Add(0x04);
|
||||
LVector3 vector = (LVector3)x;
|
||||
Vector3 vector = (Vector3)x;
|
||||
byteArray.AddRange(BitConverter.GetBytes(vector.X));
|
||||
byteArray.AddRange(BitConverter.GetBytes(vector.Y));
|
||||
byteArray.AddRange(BitConverter.GetBytes(vector.Z));
|
||||
@ -540,7 +542,7 @@ namespace RageCoop.Core
|
||||
Args.Add(reader.ReadString(stringLength));
|
||||
break;
|
||||
case 0x04:
|
||||
Args.Add(new LVector3()
|
||||
Args.Add(new Vector3()
|
||||
{
|
||||
X = reader.ReadFloat(),
|
||||
Y = reader.ReadFloat(),
|
||||
@ -603,10 +605,10 @@ namespace RageCoop.Core
|
||||
byteArray.AddRange(BitConverter.GetBytes(stringBytes.Length));
|
||||
byteArray.AddRange(stringBytes);
|
||||
}
|
||||
else if (type == typeof(LVector3))
|
||||
else if (type == typeof(Vector3))
|
||||
{
|
||||
byteArray.Add(0x04);
|
||||
LVector3 vector = (LVector3)x;
|
||||
Vector3 vector = (Vector3)x;
|
||||
byteArray.AddRange(BitConverter.GetBytes(vector.X));
|
||||
byteArray.AddRange(BitConverter.GetBytes(vector.Y));
|
||||
byteArray.AddRange(BitConverter.GetBytes(vector.Z));
|
||||
@ -658,7 +660,7 @@ namespace RageCoop.Core
|
||||
Args.Add(reader.ReadString(stringLength));
|
||||
break;
|
||||
case 0x04:
|
||||
Args.Add(new LVector3()
|
||||
Args.Add(new Vector3()
|
||||
{
|
||||
X = reader.ReadFloat(),
|
||||
Y = reader.ReadFloat(),
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using GTA.Math;
|
||||
using Lidgren.Network;
|
||||
|
||||
namespace RageCoop.Core
|
||||
@ -126,17 +126,17 @@ namespace RageCoop.Core
|
||||
|
||||
public int Health { get; set; }
|
||||
|
||||
public LVector3 Position { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
|
||||
public LVector3 Rotation { get; set; }
|
||||
public Vector3 Rotation { get; set; }
|
||||
|
||||
public LVector3 Velocity { get; set; }
|
||||
public Vector3 Velocity { get; set; }
|
||||
|
||||
public LVector3 RotationVelocity { get; set; }
|
||||
public Vector3 RotationVelocity { get; set; }
|
||||
|
||||
public byte Speed { get; set; }
|
||||
|
||||
public LVector3 AimCoords { get; set; }
|
||||
public Vector3 AimCoords { get; set; }
|
||||
|
||||
public uint CurrentWeaponHash { get; set; }
|
||||
|
||||
@ -160,17 +160,17 @@ namespace RageCoop.Core
|
||||
byteArray.AddRange(BitConverter.GetBytes(Health));
|
||||
|
||||
// Write ped position
|
||||
byteArray.AddLVector3(Position);
|
||||
byteArray.AddVector3(Position);
|
||||
|
||||
// Write ped rotation
|
||||
byteArray.AddLVector3(Rotation);
|
||||
byteArray.AddVector3(Rotation);
|
||||
|
||||
// Write ped velocity
|
||||
byteArray.AddLVector3(Velocity);
|
||||
byteArray.AddVector3(Velocity);
|
||||
|
||||
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
||||
{
|
||||
byteArray.AddLVector3(RotationVelocity);
|
||||
byteArray.AddVector3(RotationVelocity);
|
||||
}
|
||||
|
||||
// Write ped speed
|
||||
@ -182,7 +182,7 @@ namespace RageCoop.Core
|
||||
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
||||
{
|
||||
// Write ped aim coords
|
||||
byteArray.AddLVector3(AimCoords);
|
||||
byteArray.AddVector3(AimCoords);
|
||||
}
|
||||
|
||||
byteArray.AddFloat(Heading);
|
||||
@ -209,18 +209,18 @@ namespace RageCoop.Core
|
||||
Health = reader.ReadInt();
|
||||
|
||||
// Read player position
|
||||
Position = reader.ReadLVector3();
|
||||
Position = reader.ReadVector3();
|
||||
|
||||
// Read player rotation
|
||||
Rotation = reader.ReadLVector3();
|
||||
Rotation = reader.ReadVector3();
|
||||
|
||||
// Read player velocity
|
||||
Velocity = reader.ReadLVector3();
|
||||
Velocity = reader.ReadVector3();
|
||||
|
||||
// Read rotation velocity if in ragdoll
|
||||
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
||||
{
|
||||
RotationVelocity=reader.ReadLVector3();
|
||||
RotationVelocity=reader.ReadVector3();
|
||||
}
|
||||
|
||||
// Read player speed
|
||||
@ -233,7 +233,7 @@ namespace RageCoop.Core
|
||||
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
||||
{
|
||||
// Read player aim coords
|
||||
AimCoords = reader.ReadLVector3();
|
||||
AimCoords = reader.ReadVector3();
|
||||
}
|
||||
|
||||
Heading=reader.ReadFloat();
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTA.Math;
|
||||
using Lidgren.Network;
|
||||
|
||||
namespace RageCoop.Core
|
||||
@ -15,11 +16,11 @@ namespace RageCoop.Core
|
||||
public int ShooterID { get; set; }
|
||||
public uint WeaponHash { get; set; }
|
||||
|
||||
public LVector3 Position { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
|
||||
public LVector3 Rotation { get; set; }
|
||||
public Vector3 Rotation { get; set; }
|
||||
|
||||
public LVector3 Velocity { get; set; }
|
||||
public Vector3 Velocity { get; set; }
|
||||
|
||||
public bool Exploded { get; set; }
|
||||
|
||||
@ -41,14 +42,14 @@ namespace RageCoop.Core
|
||||
byteArray.AddUint(WeaponHash);
|
||||
|
||||
// Write position
|
||||
byteArray.AddLVector3(Position);
|
||||
byteArray.AddVector3(Position);
|
||||
|
||||
|
||||
// Write rotation
|
||||
byteArray.AddLVector3(Rotation);
|
||||
byteArray.AddVector3(Rotation);
|
||||
|
||||
// Write velocity
|
||||
byteArray.AddLVector3(Velocity);
|
||||
byteArray.AddVector3(Velocity);
|
||||
|
||||
if (Exploded) { byteArray.Add(1); }
|
||||
|
||||
@ -73,13 +74,13 @@ namespace RageCoop.Core
|
||||
WeaponHash= reader.ReadUInt();
|
||||
|
||||
// Read position
|
||||
Position = reader.ReadLVector3();
|
||||
Position = reader.ReadVector3();
|
||||
|
||||
// Read rotation
|
||||
Rotation = reader.ReadLVector3();
|
||||
Rotation = reader.ReadVector3();
|
||||
|
||||
// Read velocity
|
||||
Velocity =reader.ReadLVector3();
|
||||
Velocity =reader.ReadVector3();
|
||||
|
||||
if (reader.CanRead(1))
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using GTA.Math;
|
||||
using Lidgren.Network;
|
||||
|
||||
namespace RageCoop.Core
|
||||
@ -15,8 +15,8 @@ namespace RageCoop.Core
|
||||
|
||||
public uint WeaponHash { get; set; }
|
||||
|
||||
public LVector3 StartPosition { get; set; }
|
||||
public LVector3 EndPosition { get; set; }
|
||||
public Vector3 StartPosition { get; set; }
|
||||
public Vector3 EndPosition { get; set; }
|
||||
|
||||
public override void Pack(NetOutgoingMessage message)
|
||||
{
|
||||
@ -32,10 +32,10 @@ namespace RageCoop.Core
|
||||
byteArray.AddRange(BitConverter.GetBytes(WeaponHash));
|
||||
|
||||
// Write StartPosition
|
||||
byteArray.AddLVector3(StartPosition);
|
||||
byteArray.AddVector3(StartPosition);
|
||||
|
||||
// Write EndPosition
|
||||
byteArray.AddLVector3(EndPosition);
|
||||
byteArray.AddVector3(EndPosition);
|
||||
|
||||
|
||||
byte[] result = byteArray.ToArray();
|
||||
@ -57,10 +57,10 @@ namespace RageCoop.Core
|
||||
WeaponHash=reader.ReadUInt();
|
||||
|
||||
// Read StartPosition
|
||||
StartPosition=reader.ReadLVector3();
|
||||
StartPosition=reader.ReadVector3();
|
||||
|
||||
// Read EndPosition
|
||||
EndPosition=reader.ReadLVector3();
|
||||
EndPosition=reader.ReadVector3();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTA;
|
||||
using GTA.Math;
|
||||
using Lidgren.Network;
|
||||
|
||||
namespace RageCoop.Core
|
||||
@ -207,13 +208,13 @@ namespace RageCoop.Core
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
public LVector3 Position { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
|
||||
public LVector3 Rotation { get; set; }
|
||||
public Vector3 Rotation { get; set; }
|
||||
|
||||
public LVector3 Velocity { get; set; }
|
||||
public Vector3 Velocity { get; set; }
|
||||
|
||||
public LVector3 RotationVelocity { get; set; }
|
||||
public Vector3 RotationVelocity { get; set; }
|
||||
|
||||
public float ThrottlePower { get; set; }
|
||||
public float BrakePower { get; set; }
|
||||
@ -231,17 +232,17 @@ namespace RageCoop.Core
|
||||
byteArray.AddInt(ID);
|
||||
|
||||
// Write position
|
||||
byteArray.AddLVector3(Position);
|
||||
byteArray.AddVector3(Position);
|
||||
|
||||
|
||||
// Write rotation
|
||||
byteArray.AddLVector3(Rotation);
|
||||
byteArray.AddVector3(Rotation);
|
||||
|
||||
// Write velocity
|
||||
byteArray.AddLVector3(Velocity);
|
||||
byteArray.AddVector3(Velocity);
|
||||
|
||||
// Write rotation velocity
|
||||
byteArray.AddLVector3(RotationVelocity);
|
||||
byteArray.AddVector3(RotationVelocity);
|
||||
|
||||
|
||||
byteArray.AddFloat(ThrottlePower);
|
||||
@ -268,16 +269,16 @@ namespace RageCoop.Core
|
||||
ID = reader.ReadInt();
|
||||
|
||||
// Read position
|
||||
Position = reader.ReadLVector3();
|
||||
Position = reader.ReadVector3();
|
||||
|
||||
// Read rotation
|
||||
Rotation = reader.ReadLVector3();
|
||||
Rotation = reader.ReadVector3();
|
||||
|
||||
// Read velocity
|
||||
Velocity =reader.ReadLVector3();
|
||||
Velocity =reader.ReadVector3();
|
||||
|
||||
// Read rotation velocity
|
||||
RotationVelocity=reader.ReadLVector3();
|
||||
RotationVelocity=reader.ReadVector3();
|
||||
|
||||
// Read throttle power
|
||||
ThrottlePower=reader.ReadFloat();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using GTA.Math;
|
||||
namespace RageCoop.Core
|
||||
{
|
||||
public class PlayerData
|
||||
@ -18,17 +19,12 @@ namespace RageCoop.Core
|
||||
/// </summary>
|
||||
public int VehicleID { get; set; }
|
||||
public bool IsInVehicle { get; internal set; }
|
||||
public LVector3 Position { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Player Latency in second.
|
||||
/// </summary>
|
||||
public float Latency { get; set; }
|
||||
public int Health { get; set; }
|
||||
|
||||
public bool IsInRangeOf(LVector3 position, float distance)
|
||||
{
|
||||
return LVector3.Subtract(Position, position).Length() < distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user