Update for latest version of seamless
Notable feature: ModAPI
This commit is contained in:
@@ -91,7 +91,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
|
||||
private void PauseResetTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if(MySandboxGame.IsPaused)
|
||||
if (MySandboxGame.IsPaused)
|
||||
{
|
||||
Seamless.TryShow("Game is still paused... Attempting to unpause!");
|
||||
MySandboxGame.PausePop();
|
||||
@@ -164,7 +164,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//SendPlayerData
|
||||
|
||||
|
||||
@@ -179,6 +179,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
MySandboxGame.PausePop();
|
||||
}
|
||||
|
||||
ModAPI.ServerSwitched();
|
||||
SendPlayerData.Invoke(MyMultiplayer.Static, new object[] { MyGameService.OnlineName });
|
||||
isSwitch = false;
|
||||
}
|
||||
@@ -186,19 +187,19 @@ namespace SeamlessClient.ServerSwitching
|
||||
|
||||
public static bool LoadClientsFromWorld(ref List<MyObjectBuilder_Client> clients)
|
||||
{
|
||||
if(!isSwitch || clients == null || clients.Count == 0)
|
||||
if (!isSwitch || clients == null || clients.Count == 0)
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
//Dictionary<ulong, MyConnectedClientData>
|
||||
|
||||
IDictionary m_memberData = (IDictionary)PatchUtils.GetField(PatchUtils.ClientType, "m_memberData").GetValue(MyMultiplayer.Static);
|
||||
|
||||
|
||||
Seamless.TryShow($"{m_memberData.Count} members from clients");
|
||||
|
||||
var keys = m_memberData.Keys.Cast<ulong>();
|
||||
|
||||
for(int i = clients.Count - 1; i >= 0; i-- )
|
||||
for (int i = clients.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Seamless.TryShow($"Client {clients[i].SteamId}");
|
||||
if (keys.Contains(clients[i].SteamId))
|
||||
@@ -206,8 +207,8 @@ namespace SeamlessClient.ServerSwitching
|
||||
Seamless.TryShow($"Remove {clients[i].SteamId}");
|
||||
clients.RemoveAt(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -217,7 +218,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
|
||||
private static bool ProcessAllMembersData(ref AllMembersDataMsg msg)
|
||||
{
|
||||
if(!isSwitch)
|
||||
if (!isSwitch)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -245,7 +246,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
private static bool RemovePlayerFromDict(MyPlayer.PlayerId playerId)
|
||||
{
|
||||
//Seamless.TryShow($"Removing player {playerId.SteamId} from dictionariy! \n {Environment.StackTrace.ToString()} - Sender: {MyEventContext.Current.Sender}");
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
@@ -272,7 +273,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
{
|
||||
if (steamId != Sync.MyId)
|
||||
return;
|
||||
|
||||
|
||||
//Seamless.TryShow(Environment.StackTrace.ToString());
|
||||
}
|
||||
|
||||
@@ -307,13 +308,13 @@ namespace SeamlessClient.ServerSwitching
|
||||
originalLocalCharacter = MySession.Static.LocalCharacter;
|
||||
//originalControlledEntity = MySession.Static.ControlledEntity;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
player = MySession.Static.LocalHumanPlayer.GetObjectBuilder();
|
||||
player.Connected = false;
|
||||
|
||||
AsyncInvoke.InvokeAsync(() =>
|
||||
AsyncInvoke.InvokeAsync(() =>
|
||||
{
|
||||
Seamless.TryShow($"Needs entity Unload: {needsEntityUnload}");
|
||||
|
||||
@@ -326,7 +327,8 @@ namespace SeamlessClient.ServerSwitching
|
||||
UnloadServer();
|
||||
SetNewMultiplayerClient();
|
||||
|
||||
}catch(Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Seamless.TryShow(ex.ToString());
|
||||
}
|
||||
@@ -390,7 +392,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
//client.Disconnect();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MyGameService.Peer2Peer.CloseSession(Sync.ServerId);
|
||||
@@ -422,7 +424,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
Seamless.TryShow($"2 NexusMajor: {Seamless.NexusVersion.Major} - ConrolledEntity {MySession.Static.ControlledEntity == null} - HumanPlayer {MySession.Static.LocalHumanPlayer == null} - Character {MySession.Static.LocalCharacter == null}");
|
||||
|
||||
|
||||
|
||||
ModAPI.StartModSwitching();
|
||||
|
||||
//MyMultiplayer.Static.ReplicationLayer.Disconnect();
|
||||
//MyMultiplayer.Static.ReplicationLayer.Dispose();
|
||||
@@ -464,7 +466,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
Seamless.TryShow($"3 Streaming: {clienta.HasPendingStreamingReplicables} - LastMessage: {clienta.LastMessageFromServer}");
|
||||
Seamless.TryShow($"3 NexusMajor: {Seamless.NexusVersion.Major} - ConrolledEntity {MySession.Static.ControlledEntity == null} - HumanPlayer {MySession.Static.LocalHumanPlayer == null} - Character {MySession.Static.LocalCharacter == null}");
|
||||
|
||||
|
||||
|
||||
|
||||
MySandboxGame.Static.SessionCompatHelper.FixSessionComponentObjectBuilders(TargetWorld.Checkpoint, TargetWorld.Sector);
|
||||
|
||||
@@ -473,7 +475,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
|
||||
PatchUtils.ClientType.GetProperty("Server", BindingFlags.Public | BindingFlags.Instance).SetValue(MyMultiplayer.Static, TargetServer);
|
||||
typeof(MyMultiplayerBase).GetProperty("ServerId", BindingFlags.Public | BindingFlags.Instance).SetValue(MyMultiplayer.Static, TargetServer.SteamID);
|
||||
|
||||
|
||||
|
||||
MyGameService.ConnectToServer(TargetServer, delegate (JoinResult joinResult)
|
||||
{
|
||||
@@ -503,7 +505,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
MyMultiplayer.Static = UtilExtensions.CastToReflected(instance, PatchUtils.ClientType);
|
||||
MyMultiplayer.Static.ExperimentalMode = true;
|
||||
|
||||
|
||||
|
||||
|
||||
// Set the new SyncLayer to the MySession.Static.SyncLayer
|
||||
MySessionLayer.SetValue(MySession.Static, MyMultiplayer.Static.SyncLayer);
|
||||
@@ -521,7 +523,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
|
||||
private void StartSwitch()
|
||||
{
|
||||
|
||||
|
||||
MyReplicationClient clienta = (MyReplicationClient)MyMultiplayer.Static.ReplicationLayer;
|
||||
Seamless.TryShow($"5 Streaming: {clienta.HasPendingStreamingReplicables} - LastMessage: {clienta.LastMessageFromServer}");
|
||||
Seamless.TryShow($"5 NexusMajor: {Seamless.NexusVersion.Major} - ConrolledEntity {MySession.Static.ControlledEntity == null} - HumanPlayer {MySession.Static.LocalHumanPlayer == null} - Character {MySession.Static.LocalCharacter == null}");
|
||||
@@ -534,14 +536,14 @@ namespace SeamlessClient.ServerSwitching
|
||||
|
||||
|
||||
|
||||
List<ulong> clients = new List<ulong>();
|
||||
foreach(var client in Sync.Clients.GetClients())
|
||||
List<ulong> clients = new List<ulong>();
|
||||
foreach (var client in Sync.Clients.GetClients())
|
||||
{
|
||||
clients.Add(client.SteamUserId);
|
||||
Seamless.TryShow($"ADDING {client.SteamUserId} - {Sync.MyId}");
|
||||
}
|
||||
|
||||
foreach(var client in clients)
|
||||
foreach (var client in clients)
|
||||
{
|
||||
if (client == TargetServer.SteamID || client == Sync.MyId)
|
||||
continue;
|
||||
@@ -573,7 +575,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
typeof(MySandboxGame).GetField("m_pauseStackCount", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
MyHud.Chat.RegisterChat(MyMultiplayer.Static);
|
||||
//GpsRegisterChat.Invoke(MySession.Static.Gpss, new object[] { MyMultiplayer.Static });
|
||||
|
||||
@@ -582,12 +584,12 @@ namespace SeamlessClient.ServerSwitching
|
||||
//Recreate all controls... Will fix weird gui/paint/crap
|
||||
//MyGuiScreenHudSpace.Static?.RecreateControls(true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Seamless.TryShow($"6 NexusMajor: {Seamless.NexusVersion.Major} - ConrolledEntity {MySession.Static.ControlledEntity == null} - HumanPlayer {MySession.Static.LocalHumanPlayer == null} - Character {MySession.Static.LocalCharacter == null}");
|
||||
Seamless.TryShow($"6 Streaming: {clienta.HasPendingStreamingReplicables} - LastMessage: {clienta.LastMessageFromServer}");
|
||||
|
||||
|
||||
originalLocalCharacter?.Close();
|
||||
ResetReplicationTime(true);
|
||||
|
||||
@@ -764,7 +766,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
}
|
||||
}
|
||||
|
||||
private void StartEntitySync()
|
||||
private void StartEntitySync()
|
||||
{
|
||||
Seamless.TryShow("Requesting Player From Server");
|
||||
|
||||
@@ -772,7 +774,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
if (!Sandbox.Engine.Platform.Game.IsDedicated && MySession.Static.LocalHumanPlayer == null)
|
||||
{
|
||||
Seamless.TryShow("RequestNewPlayer");
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (MySession.Static.ControlledEntity == null && Sync.IsServer && !Sandbox.Engine.Platform.Game.IsDedicated)
|
||||
@@ -782,7 +784,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
MyPlayerCollection.RequestLocalRespawn();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Request client state batch
|
||||
(MyMultiplayer.Static as MyMultiplayerClientBase).RequestBatchConfirmation();
|
||||
@@ -832,7 +834,7 @@ namespace SeamlessClient.ServerSwitching
|
||||
|
||||
player.IsWildlifeAgent = true;
|
||||
CreateNewPlayerInternal.Invoke(MySession.Static.Players, new object[] { Sync.Clients.LocalClient, savingPlayerId.Value, player });
|
||||
typeof(MyPlayerCollection).GetMethod("LoadPlayerInternal", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(MySession.Static.Players, new object[] { savingPlayerId.Value, player, false });
|
||||
typeof(MyPlayerCollection).GetMethod("LoadPlayerInternal", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(MySession.Static.Players, new object[] { savingPlayerId.Value, player, false });
|
||||
|
||||
Seamless.TryShow("Saving PlayerID: " + savingPlayerId.ToString());
|
||||
|
||||
|
Reference in New Issue
Block a user