Update for latest version of seamless
Notable feature: ModAPI
This commit is contained in:
29
Seamless.cs
29
Seamless.cs
@@ -2,6 +2,7 @@
|
||||
using HarmonyLib;
|
||||
using NLog.Fluent;
|
||||
using Sandbox;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Sandbox.Game.Localization;
|
||||
using Sandbox.Game.World;
|
||||
using Sandbox.ModAPI;
|
||||
@@ -39,7 +40,7 @@ namespace SeamlessClient
|
||||
public static bool isSeamlessServer { get; private set; } = false;
|
||||
public static bool isDebug = false;
|
||||
public static bool UseNewVersion = false;
|
||||
|
||||
|
||||
|
||||
|
||||
public void Init(object gameInstance)
|
||||
@@ -49,10 +50,15 @@ namespace SeamlessClient
|
||||
GetComponents();
|
||||
|
||||
PatchComponents(SeamlessPatcher);
|
||||
MySession.LoadingStep += SessionLoaded;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SessionLoaded(LoadingProgress progress)
|
||||
{
|
||||
if (progress >= LoadingProgress.PROGRESS_STEP8)
|
||||
SendSeamlessVersion();
|
||||
}
|
||||
|
||||
private void GetComponents()
|
||||
{
|
||||
@@ -93,16 +99,19 @@ namespace SeamlessClient
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void InitilizeComponents()
|
||||
{
|
||||
foreach(ComponentBase component in allComps)
|
||||
foreach (ComponentBase component in allComps)
|
||||
{
|
||||
try
|
||||
{
|
||||
component.Initilized();
|
||||
TryShow($"Initilized {component.GetType()}");
|
||||
|
||||
}catch(Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TryShow(ex, $"Failed to initialize {component.GetType()}");
|
||||
}
|
||||
@@ -126,24 +135,18 @@ namespace SeamlessClient
|
||||
isSeamlessServer = true;
|
||||
switch (msg.MessageType)
|
||||
{
|
||||
case ClientMessageType.FirstJoin:
|
||||
Seamless.TryShow("Sending First Join!");
|
||||
SendSeamlessVersion();
|
||||
break;
|
||||
|
||||
case ClientMessageType.TransferServer:
|
||||
StartSwitch(msg.GetTransferData());
|
||||
break;
|
||||
|
||||
case ClientMessageType.OnlinePlayers:
|
||||
//Not implemented yet
|
||||
var playerData = msg.GetOnlinePlayers();
|
||||
PlayersWindowComponent.ApplyRecievedPlayers(playerData.OnlineServers, playerData.currentServerID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void SendSeamlessVersion()
|
||||
@@ -151,13 +154,15 @@ namespace SeamlessClient
|
||||
ClientMessage response = new ClientMessage(SeamlessVersion.ToString());
|
||||
MyAPIGateway.Multiplayer?.SendMessageToServer(SeamlessClientNetId, MessageUtils.Serialize(response));
|
||||
Seamless.TryShow("Sending Seamless request...");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
|
Reference in New Issue
Block a user