2021-09-26 20:52:23 -06:00
|
|
|
|
using Lidgren.Network;
|
|
|
|
|
|
|
|
|
|
namespace CoopClient
|
|
|
|
|
{
|
|
|
|
|
public static class Interface
|
|
|
|
|
{
|
2021-09-27 19:10:51 +02:00
|
|
|
|
#region DELEGATES
|
|
|
|
|
public delegate void ConnectEvent(bool connected, string bye_message = null);
|
2021-09-26 20:52:23 -06:00
|
|
|
|
public delegate void MessageEvent(NetIncomingMessage message);
|
2021-09-27 19:10:51 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region EVENTS
|
|
|
|
|
public static event ConnectEvent OnConnected;
|
|
|
|
|
public static event ConnectEvent OnDisconnected;
|
2021-09-26 20:52:23 -06:00
|
|
|
|
public static event MessageEvent OnMessage;
|
|
|
|
|
|
2021-09-27 19:10:51 +02:00
|
|
|
|
public static void Connected()
|
2021-09-26 20:52:23 -06:00
|
|
|
|
{
|
2021-09-27 19:10:51 +02:00
|
|
|
|
OnConnected?.Invoke(true);
|
2021-09-26 20:52:23 -06:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-27 19:10:51 +02:00
|
|
|
|
public static void Disconnected(string bye_message)
|
2021-09-26 20:52:23 -06:00
|
|
|
|
{
|
2021-09-27 19:10:51 +02:00
|
|
|
|
OnDisconnected?.Invoke(false, bye_message);
|
2021-09-26 20:52:23 -06:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-27 19:10:51 +02:00
|
|
|
|
public static void MessageReceived(NetIncomingMessage message)
|
2021-09-26 20:52:23 -06:00
|
|
|
|
{
|
2021-09-27 19:10:51 +02:00
|
|
|
|
OnMessage?.Invoke(message);
|
2021-09-26 20:52:23 -06:00
|
|
|
|
}
|
2021-09-27 19:10:51 +02:00
|
|
|
|
#endregion
|
2021-09-26 20:52:23 -06:00
|
|
|
|
|
2021-09-27 19:10:51 +02:00
|
|
|
|
public static void Connect(string serverAddress)
|
2021-09-26 20:52:23 -06:00
|
|
|
|
{
|
2021-09-27 19:10:51 +02:00
|
|
|
|
Main.MainNetworking.DisConnectFromServer(serverAddress);
|
2021-09-26 20:52:23 -06:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-27 19:10:51 +02:00
|
|
|
|
public static void Configure(string playerName, bool shareNpcsWithPlayers, int streamedNpcs, bool debug = false)
|
2021-09-26 20:52:23 -06:00
|
|
|
|
{
|
2021-09-27 19:10:51 +02:00
|
|
|
|
Main.MainSettings.Username = playerName;
|
|
|
|
|
Main.ShareNpcsWithPlayers = shareNpcsWithPlayers;
|
|
|
|
|
Main.MainSettings.StreamedNpc = streamedNpcs;
|
|
|
|
|
#if DEBUG
|
|
|
|
|
Main.UseDebug = debug;
|
|
|
|
|
#endif
|
2021-09-26 20:52:23 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|