Files
RAGECOOP-V/Client/Interface.cs
Makinolo 7b467aec18 Creates interface to communicate with other mods and menus optional
The interface static class will be used from 3rd party mods to
initiate, close and configure the connection. The project can be
compiled with the NON_INTERACTIVE copiler flag to remove the menus
and leave only the interface as a controller.
This is an initial implementation, future additions will support
more operations.
2021-09-26 21:31:40 -06:00

45 lines
1.3 KiB
C#

using Lidgren.Network;
namespace CoopClient
{
public static class Interface
{
public delegate void ConnectEvent(bool connected, string bye_message);
public static event ConnectEvent OnConnect;
public static event ConnectEvent OnDisconnect;
public delegate void MessageEvent(NetIncomingMessage message);
public static event MessageEvent OnMessage;
public static void Connect(string serverAddress)
{
Main.MainNetworking.DisConnectFromServer(serverAddress);
}
public static void Configure(string playerName, bool shareNpcsWithPlayers, int streamedNpcs, bool debug = false)
{
Main.MainSettings.Username = playerName;
Main.ShareNpcsWithPlayers = shareNpcsWithPlayers;
Main.MainSettings.StreamedNpc = streamedNpcs;
#if DEBUG
Main.UseDebug = debug;
#endif
}
public static void Disconnected( string bye_message)
{
OnDisconnect?.Invoke(false, bye_message);
}
public static void Connected()
{
OnConnect?.Invoke(true, "");
}
public static void MessageReceived(NetIncomingMessage message)
{
OnMessage?.Invoke(message);
}
}
}