XML documentation added (not finished yet)
This commit is contained in:
@ -4,17 +4,38 @@ using System.Linq;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static class COOPAPI
|
||||
{
|
||||
#region DELEGATES
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public delegate void ConnectEvent(bool connected, long fromId, string reason = null);
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public delegate void ChatMessage(string from, string message, CancelEventArgs args);
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public delegate void ModEvent(long from, string mod, byte customID, byte[] bytes);
|
||||
#endregion
|
||||
|
||||
#region EVENTS
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static event ConnectEvent OnConnection;
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static event ChatMessage OnChatMessage;
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static event ModEvent OnModPacketReceived;
|
||||
|
||||
internal static void Connected()
|
||||
@ -50,31 +71,55 @@ namespace CoopClient
|
||||
}
|
||||
#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)
|
||||
{
|
||||
Main.MainChat.AddMessage(from, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static void Connect(string serverAddress)
|
||||
{
|
||||
Main.MainNetworking.DisConnectFromServer(serverAddress);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static void Disconnect()
|
||||
{
|
||||
Main.MainNetworking.DisConnectFromServer(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static bool 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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
Dictionary<long, int?> result = new Dictionary<long, int?>();
|
||||
@ -88,14 +133,22 @@ namespace CoopClient
|
||||
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)
|
||||
{
|
||||
return Main.Players.ContainsKey(playerId) ? Main.Players[playerId] : null;
|
||||
return Main.Players.ContainsKey(lnID) ? Main.Players[lnID] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static bool IsMenuVisible()
|
||||
{
|
||||
#if NON_INTERACTIVE
|
||||
@ -105,44 +158,76 @@ namespace CoopClient
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static bool IsChatFocused()
|
||||
{
|
||||
return Main.MainChat.Focused;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static bool IsPlayerListVisible()
|
||||
{
|
||||
return Util.GetTickCount64() - PlayerList.Pressed < 5000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static string GetCurrentVersion()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Main.MainNetworking.SendModData(0, mod, customID, bytes);
|
||||
}
|
||||
|
||||
// Send bytes to target
|
||||
public static void SendDataToPlayer(long target, string mod, byte customID, byte[] bytes)
|
||||
/// <summary>
|
||||
/// 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()
|
||||
{
|
||||
return Main.MainSettings.Username;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static void Configure(string playerName, bool shareNpcsWithPlayers, int streamedNpcs, bool debug = false)
|
||||
{
|
||||
Main.MainSettings.Username = playerName;
|
||||
|
@ -8,7 +8,7 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
public class Chat
|
||||
internal class Chat
|
||||
{
|
||||
private readonly Scaleform MainScaleForm;
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<DocumentationFile>bin\Debug\CoopClient.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -33,6 +35,8 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<DocumentationFile>bin\Release\CoopClient.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="LemonUI.SHVDN3">
|
||||
|
@ -1,5 +1,8 @@
|
||||
namespace CoopClient.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public class EntitiesNpc : EntitiesPed
|
||||
{
|
||||
//public int LastUpdateReceived { get; set; }
|
||||
|
@ -9,58 +9,157 @@ using GTA.Math;
|
||||
|
||||
using LemonUI.Elements;
|
||||
|
||||
namespace CoopClient
|
||||
namespace CoopClient.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public class EntitiesPed
|
||||
{
|
||||
private bool AllDataAvailable = false;
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool LastSyncWasFull { get; set; } = false;
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public ulong LastUpdateReceived { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public float Latency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Ped Character { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public int Health { get; set; }
|
||||
private int LastModelHash = 0;
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public int ModelHash { get; set; }
|
||||
private Dictionary<int, int> LastProps = new Dictionary<int, int>();
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Dictionary<int, int> Props { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Vector3 Position { get; set; }
|
||||
|
||||
#region -- ON FOOT --
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Vector3 Rotation { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Vector3 Velocity { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public byte Speed { get; set; }
|
||||
private bool LastIsJumping = false;
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool IsJumping { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool IsRagdoll { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool IsOnFire { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Vector3 AimCoords { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool IsAiming { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool IsShooting { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool IsReloading { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public int CurrentWeaponHash { get; set; }
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Blip PedBlip;
|
||||
|
||||
#region -- IN VEHICLE --
|
||||
private ulong VehicleStopTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool IsInVehicle { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public int VehicleModelHash { get; set; }
|
||||
private int[] LastVehicleColors = new int[] { 0, 0 };
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public int[] VehicleColors { get; set; }
|
||||
private Dictionary<int, int> LastVehicleMods = new Dictionary<int, int>();
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Dictionary<int, int> VehicleMods { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool VehicleDead { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public float VehicleEngineHealth { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public int VehicleSeatIndex { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Vehicle MainVehicle { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Vector3 VehiclePosition { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Quaternion VehicleRotation { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public Vector3 VehicleVelocity { get; set; }
|
||||
private float LastVehicleSpeed { get; set; }
|
||||
private float CurrentVehicleSpeed { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public float VehicleSpeed
|
||||
{
|
||||
set
|
||||
@ -69,19 +168,43 @@ namespace CoopClient
|
||||
CurrentVehicleSpeed = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public float VehicleSteeringAngle { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool VehIsEngineRunning { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public float VehRPM { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool VehAreLightsOn { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool VehAreHighBeamsOn { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public bool VehIsSireneActive { get; set; }
|
||||
private VehicleDoors[] LastVehDoors;
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public VehicleDoors[] VehDoors { get; set; }
|
||||
private int LastVehTires;
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public int VehTires { get; set; }
|
||||
#endregion
|
||||
|
||||
public void DisplayLocally(string username)
|
||||
internal void DisplayLocally(string username)
|
||||
{
|
||||
/*
|
||||
* username: string
|
||||
|
@ -1,8 +1,17 @@
|
||||
namespace CoopClient.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public class EntitiesPlayer : EntitiesPed
|
||||
{
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public string SocialClubName { get; set; }
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public string Username { get; set; } = "Player";
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using GTA;
|
||||
|
||||
namespace CoopClient.Entities
|
||||
{
|
||||
public class EntitiesThread : Script
|
||||
internal class EntitiesThread : Script
|
||||
{
|
||||
public EntitiesThread()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
public class Main : Script
|
||||
internal class Main : Script
|
||||
{
|
||||
public static RelationshipGroup RelationshipGroup;
|
||||
|
||||
|
@ -5,7 +5,7 @@ using LemonUI.Menus;
|
||||
|
||||
namespace CoopClient.Menus
|
||||
{
|
||||
public class MenusMain
|
||||
internal class MenusMain
|
||||
{
|
||||
public ObjectPool MenuPool = new ObjectPool();
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace CoopClient.Menus.Sub
|
||||
{
|
||||
public class Settings
|
||||
internal class Settings
|
||||
{
|
||||
public NativeMenu MainMenu = new NativeMenu("GTACOOP:R", "Settings", "Go to the settings")
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
public class Networking
|
||||
internal class Networking
|
||||
{
|
||||
public NetClient Client;
|
||||
public float Latency;
|
||||
|
@ -156,10 +156,16 @@ namespace CoopClient
|
||||
IsDead = 1 << 5
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public struct VehicleDoors
|
||||
{
|
||||
#region CLIENT-ONLY
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public VehicleDoors(float angleRatio = 0f, bool broken = false, bool open = false, bool fullyOpen = false)
|
||||
{
|
||||
AngleRatio = angleRatio;
|
||||
@ -169,27 +175,39 @@ namespace CoopClient
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
[ProtoMember(1)]
|
||||
public float AngleRatio { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
[ProtoMember(2)]
|
||||
public bool Broken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
[ProtoMember(3)]
|
||||
public bool Open { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
[ProtoMember(4)]
|
||||
public bool FullyOpen { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public interface IPacket
|
||||
interface IPacket
|
||||
{
|
||||
void PacketToNetOutGoingMessage(NetOutgoingMessage message);
|
||||
void NetIncomingMessageToPacket(NetIncomingMessage message);
|
||||
}
|
||||
|
||||
public abstract class Packet : IPacket
|
||||
abstract class Packet : IPacket
|
||||
{
|
||||
public abstract void PacketToNetOutGoingMessage(NetOutgoingMessage message);
|
||||
public abstract void NetIncomingMessageToPacket(NetIncomingMessage message);
|
||||
@ -910,8 +928,14 @@ namespace CoopClient
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static class CoopSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static byte[] CSerialize(this object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
@ -923,6 +947,9 @@ namespace CoopClient
|
||||
return System.Text.Encoding.ASCII.GetBytes(jsonString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ?
|
||||
/// </summary>
|
||||
public static T CDeserialize<T>(this byte[] bytes) where T : class
|
||||
{
|
||||
if (bytes == null)
|
||||
|
@ -8,7 +8,7 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
public class PlayerList : Script
|
||||
internal class PlayerList : Script
|
||||
{
|
||||
private readonly Scaleform MainScaleform = new Scaleform("mp_mm_card_freemode");
|
||||
private ulong LastUpdate = Util.GetTickCount64();
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace CoopClient
|
||||
{
|
||||
public class Settings
|
||||
internal class Settings
|
||||
{
|
||||
public string Username { get; set; } = "Player";
|
||||
public string LastServerAddress { get; set; } = "127.0.0.1:4499";
|
||||
|
@ -6,7 +6,7 @@ using GTA.Native;
|
||||
|
||||
namespace CoopClient
|
||||
{
|
||||
public class WorldThread : Script
|
||||
internal class WorldThread : Script
|
||||
{
|
||||
private static bool LastDisableTraffic = false;
|
||||
|
||||
|
Reference in New Issue
Block a user