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;
|
||||
|
Reference in New Issue
Block a user