2022-10-23 19:02:39 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Lidgren.Network;
|
2022-01-01 03:07:18 +01:00
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
namespace RageCoop.Core
|
2022-01-01 03:07:18 +01:00
|
|
|
|
{
|
2022-09-08 12:41:56 -07:00
|
|
|
|
internal enum PacketType : byte
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-09-08 12:41:56 -07:00
|
|
|
|
Handshake = 0,
|
|
|
|
|
PlayerConnect = 1,
|
|
|
|
|
PlayerDisconnect = 2,
|
|
|
|
|
PlayerInfoUpdate = 3,
|
|
|
|
|
PublicKeyRequest = 4,
|
|
|
|
|
PublicKeyResponse = 5,
|
|
|
|
|
Request = 6,
|
|
|
|
|
Response = 7,
|
2022-07-29 21:15:23 +08:00
|
|
|
|
PingPong = 8,
|
2022-08-08 17:03:41 +08:00
|
|
|
|
HandshakeSuccess = 9,
|
2022-09-08 12:41:56 -07:00
|
|
|
|
ChatMessage = 10,
|
|
|
|
|
|
|
|
|
|
FileTransferChunk = 11,
|
|
|
|
|
FileTransferRequest = 12,
|
2022-07-01 12:22:31 +08:00
|
|
|
|
FileTransferResponse = 13,
|
2022-09-08 12:41:56 -07:00
|
|
|
|
FileTransferComplete = 14,
|
|
|
|
|
AllResourcesSent = 15,
|
|
|
|
|
|
2022-07-01 12:22:31 +08:00
|
|
|
|
CustomEvent = 16,
|
2022-08-06 11:40:38 +08:00
|
|
|
|
|
2022-09-08 12:41:56 -07:00
|
|
|
|
ConnectionRequest = 18,
|
2022-08-10 20:42:47 +08:00
|
|
|
|
P2PConnect = 19,
|
2022-09-08 12:41:56 -07:00
|
|
|
|
HolePunchInit = 20,
|
|
|
|
|
HolePunch = 21,
|
2022-08-13 02:19:40 +02:00
|
|
|
|
|
|
|
|
|
Voice = 22,
|
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
#region Sync
|
2022-10-23 19:02:39 +08:00
|
|
|
|
|
2022-08-13 02:19:40 +02:00
|
|
|
|
PedSync = 23,
|
|
|
|
|
VehicleSync = 24,
|
2022-09-08 12:41:56 -07:00
|
|
|
|
ProjectileSync = 25,
|
2022-10-23 19:02:39 +08:00
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region EVENT
|
|
|
|
|
|
2022-09-08 12:41:56 -07:00
|
|
|
|
PedKilled = 30,
|
|
|
|
|
BulletShot = 31,
|
|
|
|
|
OwnerChanged = 35,
|
|
|
|
|
NozzleTransform = 37,
|
2022-05-22 15:55:26 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2022-09-08 12:41:56 -07:00
|
|
|
|
Unknown = 255
|
2022-05-22 15:55:26 +08:00
|
|
|
|
}
|
2022-10-23 19:02:39 +08:00
|
|
|
|
|
2022-07-01 14:39:43 +08:00
|
|
|
|
internal enum ConnectionChannel
|
2022-01-01 03:07:18 +01:00
|
|
|
|
{
|
|
|
|
|
Default = 0,
|
2022-08-13 02:19:40 +02:00
|
|
|
|
Chat = 1,
|
|
|
|
|
Voice = 2,
|
|
|
|
|
Native = 3,
|
|
|
|
|
Mod = 4,
|
|
|
|
|
File = 5,
|
|
|
|
|
Event = 6,
|
2022-09-08 12:41:56 -07:00
|
|
|
|
RequestResponse = 7,
|
2022-08-13 02:19:40 +02:00
|
|
|
|
PingPong = 8,
|
|
|
|
|
VehicleSync = 9,
|
2022-09-08 12:41:56 -07:00
|
|
|
|
PedSync = 10,
|
2022-08-13 02:19:40 +02:00
|
|
|
|
ProjectileSync = 11,
|
2022-10-23 19:02:39 +08:00
|
|
|
|
SyncEvents = 12
|
2022-01-01 03:07:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
[Flags]
|
2022-09-08 12:41:56 -07:00
|
|
|
|
internal enum PedDataFlags : ushort
|
2022-01-01 03:07:18 +01:00
|
|
|
|
{
|
2022-09-08 12:41:56 -07:00
|
|
|
|
None = 0,
|
2022-01-01 03:07:18 +01:00
|
|
|
|
IsAiming = 1 << 0,
|
2022-06-22 14:18:20 +08:00
|
|
|
|
IsInStealthMode = 1 << 1,
|
2022-01-01 03:07:18 +01:00
|
|
|
|
IsReloading = 1 << 2,
|
|
|
|
|
IsJumping = 1 << 3,
|
|
|
|
|
IsRagdoll = 1 << 4,
|
|
|
|
|
IsOnFire = 1 << 5,
|
|
|
|
|
IsInParachuteFreeFall = 1 << 6,
|
2022-01-01 04:16:24 +01:00
|
|
|
|
IsParachuteOpen = 1 << 7,
|
|
|
|
|
IsOnLadder = 1 << 8,
|
2022-05-22 15:55:26 +08:00
|
|
|
|
IsVaulting = 1 << 9,
|
2022-07-03 10:46:24 +08:00
|
|
|
|
IsInCover = 1 << 10,
|
2022-08-14 19:06:51 +08:00
|
|
|
|
IsInLowCover = 1 << 11,
|
|
|
|
|
IsInCoverFacingLeft = 1 << 12,
|
|
|
|
|
IsBlindFiring = 1 << 13,
|
2022-08-22 00:23:46 +08:00
|
|
|
|
IsInvincible = 1 << 14,
|
2022-10-23 19:02:39 +08:00
|
|
|
|
IsFullSync = 1 << 15
|
2022-01-01 03:07:18 +01:00
|
|
|
|
}
|
2022-08-14 17:08:43 +08:00
|
|
|
|
|
2022-09-08 12:41:56 -07:00
|
|
|
|
internal enum ProjectileDataFlags : byte
|
2022-08-14 17:08:43 +08:00
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
Exploded = 1 << 0,
|
|
|
|
|
IsAttached = 1 << 1,
|
|
|
|
|
IsOrgin = 1 << 2,
|
2022-10-23 19:02:39 +08:00
|
|
|
|
IsShotByVehicle = 1 << 3
|
2022-08-14 17:08:43 +08:00
|
|
|
|
}
|
2022-10-23 19:02:39 +08:00
|
|
|
|
|
2022-01-01 03:07:18 +01:00
|
|
|
|
#region ===== VEHICLE DATA =====
|
2022-11-30 20:17:06 +08:00
|
|
|
|
|
2022-11-30 19:08:52 +08:00
|
|
|
|
[Flags]
|
2022-09-08 12:41:56 -07:00
|
|
|
|
internal enum VehicleDataFlags : ushort
|
2022-01-01 03:07:18 +01:00
|
|
|
|
{
|
2022-09-08 12:41:56 -07:00
|
|
|
|
None = 0,
|
2022-01-01 03:07:18 +01:00
|
|
|
|
IsEngineRunning = 1 << 0,
|
|
|
|
|
AreLightsOn = 1 << 1,
|
2022-01-01 17:24:55 +01:00
|
|
|
|
AreBrakeLightsOn = 1 << 2,
|
|
|
|
|
AreHighBeamsOn = 1 << 3,
|
|
|
|
|
IsSirenActive = 1 << 4,
|
|
|
|
|
IsDead = 1 << 5,
|
|
|
|
|
IsHornActive = 1 << 6,
|
|
|
|
|
IsTransformed = 1 << 7,
|
2022-08-18 08:25:15 +08:00
|
|
|
|
IsParachuteActive = 1 << 8,
|
2022-08-17 23:18:06 +08:00
|
|
|
|
IsRocketBoostActive = 1 << 9,
|
2022-05-22 15:55:26 +08:00
|
|
|
|
IsAircraft = 1 << 10,
|
2022-09-08 12:41:56 -07:00
|
|
|
|
IsDeluxoHovering = 1 << 11,
|
|
|
|
|
HasRoof = 1 << 12,
|
|
|
|
|
IsFullSync = 1 << 13,
|
|
|
|
|
IsOnFire = 1 << 14,
|
2022-10-23 19:02:39 +08:00
|
|
|
|
Repaired = 1 << 15
|
2022-01-01 03:07:18 +01:00
|
|
|
|
}
|
2022-06-22 14:18:20 +08:00
|
|
|
|
|
2022-07-01 14:39:43 +08:00
|
|
|
|
internal enum PlayerConfigFlags : byte
|
2022-06-22 14:18:20 +08:00
|
|
|
|
{
|
|
|
|
|
None = 0,
|
2022-09-08 12:41:56 -07:00
|
|
|
|
ShowBlip = 1 << 0,
|
|
|
|
|
ShowNameTag = 1 << 1
|
2022-06-22 14:18:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-01 14:39:43 +08:00
|
|
|
|
internal struct VehicleDamageModel
|
2022-01-01 03:07:18 +01:00
|
|
|
|
{
|
|
|
|
|
public byte BrokenDoors { get; set; }
|
2022-05-22 15:55:26 +08:00
|
|
|
|
public byte OpenedDoors { get; set; }
|
|
|
|
|
public byte BrokenWindows { get; set; }
|
2022-04-14 02:08:13 +02:00
|
|
|
|
public short BurstedTires { get; set; }
|
2022-04-12 03:07:41 +02:00
|
|
|
|
public byte LeftHeadLightBroken { get; set; }
|
|
|
|
|
public byte RightHeadLightBroken { get; set; }
|
2022-01-01 03:07:18 +01:00
|
|
|
|
}
|
2022-10-23 19:02:39 +08:00
|
|
|
|
|
2022-01-01 03:07:18 +01:00
|
|
|
|
#endregion
|
|
|
|
|
|
2022-08-06 10:43:24 +08:00
|
|
|
|
internal interface IPacket
|
2022-01-01 03:07:18 +01:00
|
|
|
|
{
|
2022-08-06 10:43:24 +08:00
|
|
|
|
PacketType Type { get; }
|
|
|
|
|
|
2022-09-08 12:37:06 -07:00
|
|
|
|
void Deserialize(NetIncomingMessage m);
|
2022-01-01 03:07:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-15 11:09:17 +08:00
|
|
|
|
internal abstract class Packet : IPacket
|
2022-01-01 03:07:18 +01:00
|
|
|
|
{
|
2022-08-06 10:43:24 +08:00
|
|
|
|
public abstract PacketType Type { get; }
|
2022-10-23 19:02:39 +08:00
|
|
|
|
|
|
|
|
|
public virtual void Deserialize(NetIncomingMessage m)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-08 12:37:06 -07:00
|
|
|
|
public void Pack(NetOutgoingMessage m)
|
2022-01-01 03:07:18 +01:00
|
|
|
|
{
|
2022-09-08 12:37:06 -07:00
|
|
|
|
m.Write((byte)Type);
|
|
|
|
|
Serialize(m);
|
2022-01-01 03:07:18 +01:00
|
|
|
|
}
|
2022-10-23 19:02:39 +08:00
|
|
|
|
|
|
|
|
|
protected virtual void Serialize(NetOutgoingMessage m)
|
|
|
|
|
{
|
|
|
|
|
}
|
2022-01-01 03:07:18 +01:00
|
|
|
|
}
|
2022-10-23 19:02:39 +08:00
|
|
|
|
}
|