XML documentation added (not finished yet)

This commit is contained in:
EntenKoeniq
2021-11-28 23:35:37 +01:00
parent 12a2ddf625
commit 33cda5dcfb
15 changed files with 271 additions and 20 deletions

View File

@ -4,17 +4,38 @@ using System.Linq;
namespace CoopClient namespace CoopClient
{ {
/// <summary>
/// ?
/// </summary>
public static class COOPAPI public static class COOPAPI
{ {
#region DELEGATES #region DELEGATES
/// <summary>
/// ?
/// </summary>
public delegate void ConnectEvent(bool connected, long fromId, string reason = null); public delegate void ConnectEvent(bool connected, long fromId, string reason = null);
/// <summary>
/// ?
/// </summary>
public delegate void ChatMessage(string from, string message, CancelEventArgs args); public delegate void ChatMessage(string from, string message, CancelEventArgs args);
/// <summary>
/// ?
/// </summary>
public delegate void ModEvent(long from, string mod, byte customID, byte[] bytes); public delegate void ModEvent(long from, string mod, byte customID, byte[] bytes);
#endregion #endregion
#region EVENTS #region EVENTS
/// <summary>
/// ?
/// </summary>
public static event ConnectEvent OnConnection; public static event ConnectEvent OnConnection;
/// <summary>
/// ?
/// </summary>
public static event ChatMessage OnChatMessage; public static event ChatMessage OnChatMessage;
/// <summary>
/// ?
/// </summary>
public static event ModEvent OnModPacketReceived; public static event ModEvent OnModPacketReceived;
internal static void Connected() internal static void Connected()
@ -50,31 +71,55 @@ namespace CoopClient
} }
#endregion #endregion
/// <summary>
/// Send a local chat message to this player
/// </summary>
/// <param name="from">Username of the player who sent this message</param>
/// <param name="message">The player's message</param>
public static void LocalChatMessage(string from, string message) public static void LocalChatMessage(string from, string message)
{ {
Main.MainChat.AddMessage(from, message); Main.MainChat.AddMessage(from, message);
} }
/// <summary>
/// ?
/// </summary>
public static void Connect(string serverAddress) public static void Connect(string serverAddress)
{ {
Main.MainNetworking.DisConnectFromServer(serverAddress); Main.MainNetworking.DisConnectFromServer(serverAddress);
} }
/// <summary>
/// ?
/// </summary>
public static void Disconnect() public static void Disconnect()
{ {
Main.MainNetworking.DisConnectFromServer(null); Main.MainNetworking.DisConnectFromServer(null);
} }
/// <summary>
/// ?
/// </summary>
public static bool IsOnServer() public static bool IsOnServer()
{ {
return Main.MainNetworking.IsOnServer(); return Main.MainNetworking.IsOnServer();
} }
/// <summary>
/// Get the local ID from this Lidgren network client when connected to a server
/// </summary>
/// <returns>long</returns>
public static long GetLocalID() public static long GetLocalID()
{ {
return Main.LocalClientID; return Main.LocalClientID;
} }
/// <summary>
/// Get all connected player's as a Dictionary.
/// Key = Lidgren-Network client ID
/// Value = Character handle or null
/// </summary>
/// <returns>Dictionary(long, int)</returns>
public static Dictionary<long, int?> GetAllPlayers() public static Dictionary<long, int?> GetAllPlayers()
{ {
Dictionary<long, int?> result = new Dictionary<long, int?>(); Dictionary<long, int?> result = new Dictionary<long, int?>();
@ -88,14 +133,22 @@ namespace CoopClient
return result; return result;
} }
public static Entities.EntitiesPlayer GetPlayer(long playerId) /// <summary>
/// Get a player using their Lidgren Network Client ID
/// </summary>
/// <param name="lnID">Lidgren-Network client ID</param>
/// <returns>Entities.EntitiesPlayer</returns>
public static Entities.EntitiesPlayer GetPlayer(long lnID)
{ {
lock (Main.Players) lock (Main.Players)
{ {
return Main.Players.ContainsKey(playerId) ? Main.Players[playerId] : null; return Main.Players.ContainsKey(lnID) ? Main.Players[lnID] : null;
} }
} }
/// <summary>
/// ?
/// </summary>
public static bool IsMenuVisible() public static bool IsMenuVisible()
{ {
#if NON_INTERACTIVE #if NON_INTERACTIVE
@ -105,44 +158,76 @@ namespace CoopClient
#endif #endif
} }
/// <summary>
/// ?
/// </summary>
public static bool IsChatFocused() public static bool IsChatFocused()
{ {
return Main.MainChat.Focused; return Main.MainChat.Focused;
} }
/// <summary>
/// ?
/// </summary>
public static bool IsPlayerListVisible() public static bool IsPlayerListVisible()
{ {
return Util.GetTickCount64() - PlayerList.Pressed < 5000; return Util.GetTickCount64() - PlayerList.Pressed < 5000;
} }
/// <summary>
/// ?
/// </summary>
public static string GetCurrentVersion() public static string GetCurrentVersion()
{ {
return Main.CurrentVersion; return Main.CurrentVersion;
} }
// Send bytes to server /// <summary>
/// Send any data (bytes) to the server
/// </summary>
/// <param name="mod">The name of this modification (script)</param>
/// <param name="customID">The ID to know what the data is</param>
/// <param name="bytes">Your class, structure or whatever in bytes</param>
public static void SendDataToServer(string mod, byte customID, byte[] bytes) public static void SendDataToServer(string mod, byte customID, byte[] bytes)
{ {
Main.MainNetworking.SendModData(-1, mod, customID, bytes); Main.MainNetworking.SendModData(-1, mod, customID, bytes);
} }
// Send bytes to all players /// <summary>
/// Send any data (bytes) to the all player
/// </summary>
/// <param name="mod">The name of this modification (script)</param>
/// <param name="customID">The ID to know what the data is</param>
/// <param name="bytes">Your class, structure or whatever in bytes</param>
public static void SendDataToAll(string mod, byte customID, byte[] bytes) public static void SendDataToAll(string mod, byte customID, byte[] bytes)
{ {
Main.MainNetworking.SendModData(0, mod, customID, bytes); Main.MainNetworking.SendModData(0, mod, customID, bytes);
} }
// Send bytes to target /// <summary>
public static void SendDataToPlayer(long target, string mod, byte customID, byte[] bytes) /// Send any data (bytes) to a player
/// </summary>
/// <param name="lnID">The Lidgren Network Client ID that receives the data</param>
/// <param name="mod">The name of this modification (script)</param>
/// <param name="customID">The ID to know what the data is</param>
/// <param name="bytes">Your class, structure or whatever in bytes</param>
public static void SendDataToPlayer(long lnID, string mod, byte customID, byte[] bytes)
{ {
Main.MainNetworking.SendModData(target, mod, customID, bytes); Main.MainNetworking.SendModData(lnID, mod, customID, bytes);
} }
/// <summary>
/// Get that player's local username that has been set
/// </summary>
/// <returns>string</returns>
public static string GetLocalUsername() public static string GetLocalUsername()
{ {
return Main.MainSettings.Username; return Main.MainSettings.Username;
} }
/// <summary>
/// ?
/// </summary>
public static void Configure(string playerName, bool shareNpcsWithPlayers, int streamedNpcs, bool debug = false) public static void Configure(string playerName, bool shareNpcsWithPlayers, int streamedNpcs, bool debug = false)
{ {
Main.MainSettings.Username = playerName; Main.MainSettings.Username = playerName;

View File

@ -8,7 +8,7 @@ using GTA.Native;
namespace CoopClient namespace CoopClient
{ {
public class Chat internal class Chat
{ {
private readonly Scaleform MainScaleForm; private readonly Scaleform MainScaleForm;

View File

@ -24,6 +24,8 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<DocumentationFile>bin\Debug\CoopClient.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -33,6 +35,8 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<DocumentationFile>bin\Release\CoopClient.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="LemonUI.SHVDN3"> <Reference Include="LemonUI.SHVDN3">

View File

@ -1,5 +1,8 @@
namespace CoopClient.Entities namespace CoopClient.Entities
{ {
/// <summary>
/// ?
/// </summary>
public class EntitiesNpc : EntitiesPed public class EntitiesNpc : EntitiesPed
{ {
//public int LastUpdateReceived { get; set; } //public int LastUpdateReceived { get; set; }

View File

@ -9,58 +9,157 @@ using GTA.Math;
using LemonUI.Elements; using LemonUI.Elements;
namespace CoopClient namespace CoopClient.Entities
{ {
/// <summary>
/// ?
/// </summary>
public class EntitiesPed public class EntitiesPed
{ {
private bool AllDataAvailable = false; private bool AllDataAvailable = false;
/// <summary>
/// ?
/// </summary>
public bool LastSyncWasFull { get; set; } = false; public bool LastSyncWasFull { get; set; } = false;
/// <summary>
/// ?
/// </summary>
public ulong LastUpdateReceived { get; set; } public ulong LastUpdateReceived { get; set; }
/// <summary>
/// ?
/// </summary>
public float Latency { get; set; } public float Latency { get; set; }
/// <summary>
/// ?
/// </summary>
public Ped Character { get; set; } public Ped Character { get; set; }
/// <summary>
/// ?
/// </summary>
public int Health { get; set; } public int Health { get; set; }
private int LastModelHash = 0; private int LastModelHash = 0;
/// <summary>
/// ?
/// </summary>
public int ModelHash { get; set; } public int ModelHash { get; set; }
private Dictionary<int, int> LastProps = new Dictionary<int, int>(); private Dictionary<int, int> LastProps = new Dictionary<int, int>();
/// <summary>
/// ?
/// </summary>
public Dictionary<int, int> Props { get; set; } public Dictionary<int, int> Props { get; set; }
/// <summary>
/// ?
/// </summary>
public Vector3 Position { get; set; } public Vector3 Position { get; set; }
#region -- ON FOOT -- #region -- ON FOOT --
/// <summary>
/// ?
/// </summary>
public Vector3 Rotation { get; set; } public Vector3 Rotation { get; set; }
/// <summary>
/// ?
/// </summary>
public Vector3 Velocity { get; set; } public Vector3 Velocity { get; set; }
/// <summary>
/// ?
/// </summary>
public byte Speed { get; set; } public byte Speed { get; set; }
private bool LastIsJumping = false; private bool LastIsJumping = false;
/// <summary>
/// ?
/// </summary>
public bool IsJumping { get; set; } public bool IsJumping { get; set; }
/// <summary>
/// ?
/// </summary>
public bool IsRagdoll { get; set; } public bool IsRagdoll { get; set; }
/// <summary>
/// ?
/// </summary>
public bool IsOnFire { get; set; } public bool IsOnFire { get; set; }
/// <summary>
/// ?
/// </summary>
public Vector3 AimCoords { get; set; } public Vector3 AimCoords { get; set; }
/// <summary>
/// ?
/// </summary>
public bool IsAiming { get; set; } public bool IsAiming { get; set; }
/// <summary>
/// ?
/// </summary>
public bool IsShooting { get; set; } public bool IsShooting { get; set; }
/// <summary>
/// ?
/// </summary>
public bool IsReloading { get; set; } public bool IsReloading { get; set; }
/// <summary>
/// ?
/// </summary>
public int CurrentWeaponHash { get; set; } public int CurrentWeaponHash { get; set; }
#endregion #endregion
/// <summary>
/// ?
/// </summary>
public Blip PedBlip; public Blip PedBlip;
#region -- IN VEHICLE -- #region -- IN VEHICLE --
private ulong VehicleStopTime { get; set; } private ulong VehicleStopTime { get; set; }
/// <summary>
/// ?
/// </summary>
public bool IsInVehicle { get; set; } public bool IsInVehicle { get; set; }
/// <summary>
/// ?
/// </summary>
public int VehicleModelHash { get; set; } public int VehicleModelHash { get; set; }
private int[] LastVehicleColors = new int[] { 0, 0 }; private int[] LastVehicleColors = new int[] { 0, 0 };
/// <summary>
/// ?
/// </summary>
public int[] VehicleColors { get; set; } public int[] VehicleColors { get; set; }
private Dictionary<int, int> LastVehicleMods = new Dictionary<int, int>(); private Dictionary<int, int> LastVehicleMods = new Dictionary<int, int>();
/// <summary>
/// ?
/// </summary>
public Dictionary<int, int> VehicleMods { get; set; } public Dictionary<int, int> VehicleMods { get; set; }
/// <summary>
/// ?
/// </summary>
public bool VehicleDead { get; set; } public bool VehicleDead { get; set; }
/// <summary>
/// ?
/// </summary>
public float VehicleEngineHealth { get; set; } public float VehicleEngineHealth { get; set; }
/// <summary>
/// ?
/// </summary>
public int VehicleSeatIndex { get; set; } public int VehicleSeatIndex { get; set; }
/// <summary>
/// ?
/// </summary>
public Vehicle MainVehicle { get; set; } public Vehicle MainVehicle { get; set; }
/// <summary>
/// ?
/// </summary>
public Vector3 VehiclePosition { get; set; } public Vector3 VehiclePosition { get; set; }
/// <summary>
/// ?
/// </summary>
public Quaternion VehicleRotation { get; set; } public Quaternion VehicleRotation { get; set; }
/// <summary>
/// ?
/// </summary>
public Vector3 VehicleVelocity { get; set; } public Vector3 VehicleVelocity { get; set; }
private float LastVehicleSpeed { get; set; } private float LastVehicleSpeed { get; set; }
private float CurrentVehicleSpeed { get; set; } private float CurrentVehicleSpeed { get; set; }
/// <summary>
/// ?
/// </summary>
public float VehicleSpeed public float VehicleSpeed
{ {
set set
@ -69,19 +168,43 @@ namespace CoopClient
CurrentVehicleSpeed = value; CurrentVehicleSpeed = value;
} }
} }
/// <summary>
/// ?
/// </summary>
public float VehicleSteeringAngle { get; set; } public float VehicleSteeringAngle { get; set; }
/// <summary>
/// ?
/// </summary>
public bool VehIsEngineRunning { get; set; } public bool VehIsEngineRunning { get; set; }
/// <summary>
/// ?
/// </summary>
public float VehRPM { get; set; } public float VehRPM { get; set; }
/// <summary>
/// ?
/// </summary>
public bool VehAreLightsOn { get; set; } public bool VehAreLightsOn { get; set; }
/// <summary>
/// ?
/// </summary>
public bool VehAreHighBeamsOn { get; set; } public bool VehAreHighBeamsOn { get; set; }
/// <summary>
/// ?
/// </summary>
public bool VehIsSireneActive { get; set; } public bool VehIsSireneActive { get; set; }
private VehicleDoors[] LastVehDoors; private VehicleDoors[] LastVehDoors;
/// <summary>
/// ?
/// </summary>
public VehicleDoors[] VehDoors { get; set; } public VehicleDoors[] VehDoors { get; set; }
private int LastVehTires; private int LastVehTires;
/// <summary>
/// ?
/// </summary>
public int VehTires { get; set; } public int VehTires { get; set; }
#endregion #endregion
public void DisplayLocally(string username) internal void DisplayLocally(string username)
{ {
/* /*
* username: string * username: string

View File

@ -1,8 +1,17 @@
namespace CoopClient.Entities namespace CoopClient.Entities
{ {
/// <summary>
/// ?
/// </summary>
public class EntitiesPlayer : EntitiesPed public class EntitiesPlayer : EntitiesPed
{ {
/// <summary>
/// ?
/// </summary>
public string SocialClubName { get; set; } public string SocialClubName { get; set; }
/// <summary>
/// ?
/// </summary>
public string Username { get; set; } = "Player"; public string Username { get; set; } = "Player";
} }
} }

View File

@ -6,7 +6,7 @@ using GTA;
namespace CoopClient.Entities namespace CoopClient.Entities
{ {
public class EntitiesThread : Script internal class EntitiesThread : Script
{ {
public EntitiesThread() public EntitiesThread()
{ {

View File

@ -12,7 +12,7 @@ using GTA.Native;
namespace CoopClient namespace CoopClient
{ {
public class Main : Script internal class Main : Script
{ {
public static RelationshipGroup RelationshipGroup; public static RelationshipGroup RelationshipGroup;

View File

@ -5,7 +5,7 @@ using LemonUI.Menus;
namespace CoopClient.Menus namespace CoopClient.Menus
{ {
public class MenusMain internal class MenusMain
{ {
public ObjectPool MenuPool = new ObjectPool(); public ObjectPool MenuPool = new ObjectPool();

View File

@ -2,7 +2,7 @@
namespace CoopClient.Menus.Sub namespace CoopClient.Menus.Sub
{ {
public class Settings internal class Settings
{ {
public NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "Settings", "Go to the settings") public NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "Settings", "Go to the settings")
{ {

View File

@ -10,7 +10,7 @@ using GTA.Native;
namespace CoopClient namespace CoopClient
{ {
public class Networking internal class Networking
{ {
public NetClient Client; public NetClient Client;
public float Latency; public float Latency;

View File

@ -156,10 +156,16 @@ namespace CoopClient
IsDead = 1 << 5 IsDead = 1 << 5
} }
/// <summary>
/// ?
/// </summary>
[ProtoContract] [ProtoContract]
public struct VehicleDoors public struct VehicleDoors
{ {
#region CLIENT-ONLY #region CLIENT-ONLY
/// <summary>
/// ?
/// </summary>
public VehicleDoors(float angleRatio = 0f, bool broken = false, bool open = false, bool fullyOpen = false) public VehicleDoors(float angleRatio = 0f, bool broken = false, bool open = false, bool fullyOpen = false)
{ {
AngleRatio = angleRatio; AngleRatio = angleRatio;
@ -169,27 +175,39 @@ namespace CoopClient
} }
#endregion #endregion
/// <summary>
/// ?
/// </summary>
[ProtoMember(1)] [ProtoMember(1)]
public float AngleRatio { get; set; } public float AngleRatio { get; set; }
/// <summary>
/// ?
/// </summary>
[ProtoMember(2)] [ProtoMember(2)]
public bool Broken { get; set; } public bool Broken { get; set; }
/// <summary>
/// ?
/// </summary>
[ProtoMember(3)] [ProtoMember(3)]
public bool Open { get; set; } public bool Open { get; set; }
/// <summary>
/// ?
/// </summary>
[ProtoMember(4)] [ProtoMember(4)]
public bool FullyOpen { get; set; } public bool FullyOpen { get; set; }
} }
#endregion #endregion
public interface IPacket interface IPacket
{ {
void PacketToNetOutGoingMessage(NetOutgoingMessage message); void PacketToNetOutGoingMessage(NetOutgoingMessage message);
void NetIncomingMessageToPacket(NetIncomingMessage message); void NetIncomingMessageToPacket(NetIncomingMessage message);
} }
public abstract class Packet : IPacket abstract class Packet : IPacket
{ {
public abstract void PacketToNetOutGoingMessage(NetOutgoingMessage message); public abstract void PacketToNetOutGoingMessage(NetOutgoingMessage message);
public abstract void NetIncomingMessageToPacket(NetIncomingMessage message); public abstract void NetIncomingMessageToPacket(NetIncomingMessage message);
@ -910,8 +928,14 @@ namespace CoopClient
} }
#endregion #endregion
/// <summary>
/// ?
/// </summary>
public static class CoopSerializer public static class CoopSerializer
{ {
/// <summary>
/// ?
/// </summary>
public static byte[] CSerialize(this object obj) public static byte[] CSerialize(this object obj)
{ {
if (obj == null) if (obj == null)
@ -923,6 +947,9 @@ namespace CoopClient
return System.Text.Encoding.ASCII.GetBytes(jsonString); return System.Text.Encoding.ASCII.GetBytes(jsonString);
} }
/// <summary>
/// ?
/// </summary>
public static T CDeserialize<T>(this byte[] bytes) where T : class public static T CDeserialize<T>(this byte[] bytes) where T : class
{ {
if (bytes == null) if (bytes == null)

View File

@ -8,7 +8,7 @@ using GTA.Native;
namespace CoopClient namespace CoopClient
{ {
public class PlayerList : Script internal class PlayerList : Script
{ {
private readonly Scaleform MainScaleform = new Scaleform("mp_mm_card_freemode"); private readonly Scaleform MainScaleform = new Scaleform("mp_mm_card_freemode");
private ulong LastUpdate = Util.GetTickCount64(); private ulong LastUpdate = Util.GetTickCount64();

View File

@ -1,6 +1,6 @@
namespace CoopClient namespace CoopClient
{ {
public class Settings internal class Settings
{ {
public string Username { get; set; } = "Player"; public string Username { get; set; } = "Player";
public string LastServerAddress { get; set; } = "127.0.0.1:4499"; public string LastServerAddress { get; set; } = "127.0.0.1:4499";

View File

@ -6,7 +6,7 @@ using GTA.Native;
namespace CoopClient namespace CoopClient
{ {
public class WorldThread : Script internal class WorldThread : Script
{ {
private static bool LastDisableTraffic = false; private static bool LastDisableTraffic = false;