Code cleanup, prepare fo ProjectileSync
This commit is contained in:
@ -68,7 +68,6 @@ namespace RageCoop.Client.Menus.Sub
|
|||||||
Main.Settings.PassengerKey.ToString(), 20));
|
Main.Settings.PassengerKey.ToString(), 20));
|
||||||
_passengerKey.AltTitle=Main.Settings.PassengerKey.ToString();
|
_passengerKey.AltTitle=Main.Settings.PassengerKey.ToString();
|
||||||
Util.SaveSettings();
|
Util.SaveSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GTA;
|
using GTA;
|
||||||
|
using GTA.Math;
|
||||||
|
|
||||||
namespace RageCoop.Client
|
namespace RageCoop.Client
|
||||||
{
|
{
|
||||||
@ -45,5 +46,9 @@ namespace RageCoop.Client
|
|||||||
public ulong LastUpdated { get; set; } = 0;
|
public ulong LastUpdated { get; set; } = 0;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public Vector3 Position { get; set; }
|
||||||
|
public Vector3 Rotation { get; set; }
|
||||||
|
public Vector3 Velocity { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,12 +82,6 @@ namespace RageCoop.Client
|
|||||||
public Dictionary<byte, short> Clothes { get; set; }
|
public Dictionary<byte, short> Clothes { get; set; }
|
||||||
|
|
||||||
public float Heading { get; set; }
|
public float Heading { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The latest character position (may not have been applied yet)
|
|
||||||
/// </summary>
|
|
||||||
public Vector3 Position { get; internal set; }
|
|
||||||
public Vector3 Velocity { get; set; }
|
|
||||||
public Vector3 RotationVelocity { get; set; }
|
public Vector3 RotationVelocity { get; set; }
|
||||||
public Vector3 AimCoords { get; set; }
|
public Vector3 AimCoords { get; set; }
|
||||||
|
|
||||||
@ -311,7 +305,6 @@ namespace RageCoop.Client
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The latest character rotation (may not have been applied yet)
|
/// The latest character rotation (may not have been applied yet)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector3 Rotation { get; internal set; }
|
|
||||||
public byte Speed { get; set; }
|
public byte Speed { get; set; }
|
||||||
private bool _lastIsJumping = false;
|
private bool _lastIsJumping = false;
|
||||||
public bool IsJumping { get; set; }
|
public bool IsJumping { get; set; }
|
||||||
|
@ -66,10 +66,7 @@ namespace RageCoop.Client
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region -- CRITICAL STUFF --
|
#region -- CRITICAL STUFF --
|
||||||
public Vector3 Position { get; set; }
|
|
||||||
public Vector3 Velocity { get; set; }
|
|
||||||
public Vector3 RotationVelocity { get; set; }
|
public Vector3 RotationVelocity { get; set; }
|
||||||
public Vector3 Rotation { get; set; }
|
|
||||||
public float SteeringAngle { get; set; }
|
public float SteeringAngle { get; set; }
|
||||||
public float ThrottlePower { get; set; }
|
public float ThrottlePower { get; set; }
|
||||||
public float BrakePower { get; set; }
|
public float BrakePower { get; set; }
|
||||||
|
@ -135,31 +135,20 @@ namespace RageCoop.Core
|
|||||||
VehicleStateSync = 21,
|
VehicleStateSync = 21,
|
||||||
CharacterSync = 22,
|
CharacterSync = 22,
|
||||||
CharacterStateSync = 23,
|
CharacterStateSync = 23,
|
||||||
|
ProjectileSync=24,
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EVENT
|
#region EVENT
|
||||||
|
|
||||||
PedKilled=30,
|
PedKilled=30,
|
||||||
BulletShot=31,
|
BulletShot=31,
|
||||||
ProjectileShot=32,
|
EnteringVehicle=32,
|
||||||
ProjectileExploded=33,
|
LeaveVehicle = 33,
|
||||||
EnteringVehicle=34,
|
EnteredVehicle=34,
|
||||||
LeaveVehicle = 35,
|
OwnerChanged=35,
|
||||||
EnteredVehicle=36,
|
VehicleBulletShot = 36,
|
||||||
OwnerChanged=37,
|
|
||||||
VehicleBulletShot = 38,
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
/// obsolete sync method
|
|
||||||
/*
|
|
||||||
FullSyncPlayer = 3,
|
|
||||||
FullSyncPlayerVeh = 4,
|
|
||||||
LightSyncPlayer = 5,
|
|
||||||
LightSyncPlayerVeh = 6,
|
|
||||||
SuperLightSync = 7,
|
|
||||||
FullSyncNpc = 8,
|
|
||||||
FullSyncNpcVeh = 9,
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,11 @@ namespace RageCoop.Core
|
|||||||
|
|
||||||
List<byte> byteArray = new List<byte>();
|
List<byte> byteArray = new List<byte>();
|
||||||
|
|
||||||
// Write player netHandle
|
// Write ID
|
||||||
byteArray.AddRange(BitConverter.GetBytes(ID));
|
byteArray.AddInt(ID);
|
||||||
|
|
||||||
// Write player model hash
|
// Write model hash
|
||||||
byteArray.AddRange(BitConverter.GetBytes(ModelHash));
|
byteArray.AddInt(ModelHash);
|
||||||
|
|
||||||
// Write player clothes
|
// Write player clothes
|
||||||
// Write the count of clothes
|
// Write the count of clothes
|
||||||
@ -150,7 +150,7 @@ namespace RageCoop.Core
|
|||||||
List<byte> byteArray = new List<byte>();
|
List<byte> byteArray = new List<byte>();
|
||||||
|
|
||||||
// Write ped ID
|
// Write ped ID
|
||||||
byteArray.AddRange(BitConverter.GetBytes(ID));
|
byteArray.AddInt(ID);
|
||||||
|
|
||||||
|
|
||||||
// Write ped flags
|
// Write ped flags
|
||||||
@ -160,19 +160,13 @@ namespace RageCoop.Core
|
|||||||
byteArray.AddRange(BitConverter.GetBytes(Health));
|
byteArray.AddRange(BitConverter.GetBytes(Health));
|
||||||
|
|
||||||
// Write ped position
|
// Write ped position
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Position.X));
|
byteArray.AddLVector3(Position);
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Position.Y));
|
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Position.Z));
|
|
||||||
|
|
||||||
// Write ped rotation
|
// Write ped rotation
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Rotation.X));
|
byteArray.AddLVector3(Rotation);
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Rotation.Y));
|
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Rotation.Z));
|
|
||||||
|
|
||||||
// Write ped velocity
|
// Write ped velocity
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Velocity.X));
|
byteArray.AddLVector3(Velocity);
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Velocity.Y));
|
|
||||||
byteArray.AddRange(BitConverter.GetBytes(Velocity.Z));
|
|
||||||
|
|
||||||
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
||||||
{
|
{
|
||||||
@ -188,9 +182,7 @@ namespace RageCoop.Core
|
|||||||
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
||||||
{
|
{
|
||||||
// Write ped aim coords
|
// Write ped aim coords
|
||||||
byteArray.AddRange(BitConverter.GetBytes(AimCoords.X));
|
byteArray.AddLVector3(AimCoords);
|
||||||
byteArray.AddRange(BitConverter.GetBytes(AimCoords.Y));
|
|
||||||
byteArray.AddRange(BitConverter.GetBytes(AimCoords.Z));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byteArray.AddFloat(Heading);
|
byteArray.AddFloat(Heading);
|
||||||
@ -217,28 +209,13 @@ namespace RageCoop.Core
|
|||||||
Health = reader.ReadInt();
|
Health = reader.ReadInt();
|
||||||
|
|
||||||
// Read player position
|
// Read player position
|
||||||
Position = new LVector3()
|
Position = reader.ReadLVector3();
|
||||||
{
|
|
||||||
X = reader.ReadFloat(),
|
|
||||||
Y = reader.ReadFloat(),
|
|
||||||
Z = reader.ReadFloat()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Read player rotation
|
// Read player rotation
|
||||||
Rotation = new LVector3()
|
Rotation = reader.ReadLVector3();
|
||||||
{
|
|
||||||
X = reader.ReadFloat(),
|
|
||||||
Y = reader.ReadFloat(),
|
|
||||||
Z = reader.ReadFloat()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Read player velocity
|
// Read player velocity
|
||||||
Velocity = new LVector3()
|
Velocity = reader.ReadLVector3();
|
||||||
{
|
|
||||||
X = reader.ReadFloat(),
|
|
||||||
Y = reader.ReadFloat(),
|
|
||||||
Z = reader.ReadFloat()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Read rotation velocity if in ragdoll
|
// Read rotation velocity if in ragdoll
|
||||||
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
||||||
@ -256,12 +233,7 @@ namespace RageCoop.Core
|
|||||||
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
||||||
{
|
{
|
||||||
// Read player aim coords
|
// Read player aim coords
|
||||||
AimCoords = new LVector3()
|
AimCoords = reader.ReadLVector3();
|
||||||
{
|
|
||||||
X = reader.ReadFloat(),
|
|
||||||
Y = reader.ReadFloat(),
|
|
||||||
Z = reader.ReadFloat()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Heading=reader.ReadFloat();
|
Heading=reader.ReadFloat();
|
||||||
|
67
Core/Packets/ProjectileSync.cs
Normal file
67
Core/Packets/ProjectileSync.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using Lidgren.Network;
|
||||||
|
|
||||||
|
namespace RageCoop.Core
|
||||||
|
{
|
||||||
|
internal class ProjectileSync:Packet
|
||||||
|
{
|
||||||
|
|
||||||
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public LVector3 Position { get; set; }
|
||||||
|
|
||||||
|
public LVector3 Rotation { get; set; }
|
||||||
|
|
||||||
|
public LVector3 Velocity { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public override void Pack(NetOutgoingMessage message)
|
||||||
|
{
|
||||||
|
#region PacketToNetOutGoingMessage
|
||||||
|
message.Write((byte)PacketTypes.ProjectileSync);
|
||||||
|
|
||||||
|
List<byte> byteArray = new List<byte>();
|
||||||
|
|
||||||
|
// Write vehicle id
|
||||||
|
byteArray.AddInt(ID);
|
||||||
|
|
||||||
|
// Write position
|
||||||
|
byteArray.AddLVector3(Position);
|
||||||
|
|
||||||
|
|
||||||
|
// Write rotation
|
||||||
|
byteArray.AddLVector3(Rotation);
|
||||||
|
|
||||||
|
// Write velocity
|
||||||
|
byteArray.AddLVector3(Velocity);
|
||||||
|
|
||||||
|
byte[] result = byteArray.ToArray();
|
||||||
|
|
||||||
|
message.Write(result.Length);
|
||||||
|
message.Write(result);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Unpack(byte[] array)
|
||||||
|
{
|
||||||
|
#region NetIncomingMessageToPacket
|
||||||
|
BitReader reader = new BitReader(array);
|
||||||
|
|
||||||
|
// Read id
|
||||||
|
ID = reader.ReadInt();
|
||||||
|
|
||||||
|
// Read position
|
||||||
|
Position = reader.ReadLVector3();
|
||||||
|
|
||||||
|
// Read rotation
|
||||||
|
Rotation = reader.ReadLVector3();
|
||||||
|
|
||||||
|
// Read velocity
|
||||||
|
Velocity =reader.ReadLVector3();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,50 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using Lidgren.Network;
|
|
||||||
|
|
||||||
namespace RageCoop.Core
|
|
||||||
{
|
|
||||||
public partial class Packets
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Non-critical stuff, such as damage model, landing gear, health, etc..
|
|
||||||
/// </summary>
|
|
||||||
public class UpdateOwner : Packet
|
|
||||||
{
|
|
||||||
public int ID { get; set; }
|
|
||||||
public int OwnerID { get; set; }
|
|
||||||
public override void Pack(NetOutgoingMessage message)
|
|
||||||
{
|
|
||||||
#region PacketToNetOutGoingMessage
|
|
||||||
message.Write((byte)PacketTypes.PlayerConnect);
|
|
||||||
|
|
||||||
List<byte> byteArray = new List<byte>();
|
|
||||||
|
|
||||||
// Write ID
|
|
||||||
byteArray.AddRange(BitConverter.GetBytes(ID));
|
|
||||||
|
|
||||||
// Write OwnerID
|
|
||||||
byteArray.AddRange(BitConverter.GetBytes(OwnerID));
|
|
||||||
|
|
||||||
byte[] result = byteArray.ToArray();
|
|
||||||
|
|
||||||
message.Write(result.Length);
|
|
||||||
message.Write(result);
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Unpack(byte[] array)
|
|
||||||
{
|
|
||||||
BitReader reader = new BitReader(array);
|
|
||||||
|
|
||||||
// Read player ID
|
|
||||||
ID = reader.ReadInt();
|
|
||||||
|
|
||||||
// Read Username
|
|
||||||
OwnerID = reader.ReadInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -228,7 +228,7 @@ namespace RageCoop.Core
|
|||||||
List<byte> byteArray = new List<byte>();
|
List<byte> byteArray = new List<byte>();
|
||||||
|
|
||||||
// Write vehicle id
|
// Write vehicle id
|
||||||
byteArray.AddRange(BitConverter.GetBytes(ID));
|
byteArray.AddInt(ID);
|
||||||
|
|
||||||
// Write position
|
// Write position
|
||||||
byteArray.AddLVector3(Position);
|
byteArray.AddLVector3(Position);
|
||||||
|
Reference in New Issue
Block a user