diff --git a/SeamlessClientPlugin.csproj b/SeamlessClientPlugin.csproj index 1a3d93f..936fa49 100644 --- a/SeamlessClientPlugin.csproj +++ b/SeamlessClientPlugin.csproj @@ -162,6 +162,7 @@ + diff --git a/SeamlessTransfer/ModLoader.cs b/SeamlessTransfer/ModLoader.cs new file mode 100644 index 0000000..2c495b1 --- /dev/null +++ b/SeamlessTransfer/ModLoader.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SeamlessClientPlugin.SeamlessTransfer +{ + public class ModLoader + { + /* Mod loader should download and load missing mods for target server, and unload ones that arent needed + * + * + * + * + */ + + } +} diff --git a/SeamlessTransfer/SwitchServers.cs b/SeamlessTransfer/SwitchServers.cs index 7c96e3e..eb88313 100644 --- a/SeamlessTransfer/SwitchServers.cs +++ b/SeamlessTransfer/SwitchServers.cs @@ -7,6 +7,7 @@ using Sandbox.Game.Gui; using Sandbox.Game.GUI; using Sandbox.Game.Multiplayer; using Sandbox.Game.World; +using Sandbox.Game.World.Generator; using Sandbox.ModAPI; using SeamlessClientPlugin.Utilities; using System; @@ -111,6 +112,9 @@ namespace SeamlessClientPlugin.SeamlessTransfer LoadOnlinePlayers(); SetWorldSettings(); RemoveOldEntities(); + UpdateWorldGenerator(); + + StartEntitySync(); MyModAPIHelper.Initialize(); @@ -321,6 +325,21 @@ namespace SeamlessClientPlugin.SeamlessTransfer + private void UpdateWorldGenerator() + { + //This will re-init the MyProceduralWorldGenerator. (Not doing this will result in asteroids not rendering in properly) + + //This shoud never be null + var Generator = MySession.Static.GetComponent(); + + //Force component to unload + Patches.UnloadProceduralWorldGenerator.Invoke(Generator, null); + + //Force component to reload, re-syncing settings and seeds to the destination server + Generator.LoadData(); + + + } private void UnloadCurrentServer() { diff --git a/Utilities/Patches.cs b/Utilities/Patches.cs index c837e00..3abb77b 100644 --- a/Utilities/Patches.cs +++ b/Utilities/Patches.cs @@ -3,6 +3,7 @@ using Sandbox.Engine.Multiplayer; using Sandbox.Engine.Networking; using Sandbox.Game.Multiplayer; using Sandbox.Game.World; +using Sandbox.Game.World.Generator; using Sandbox.Graphics.GUI; using System; using System.Collections.Generic; @@ -66,6 +67,9 @@ namespace SeamlessClientPlugin.SeamlessTransfer + /* WorldGenerator */ + public static MethodInfo UnloadProceduralWorldGenerator; + public static void GetPatches() @@ -101,6 +105,8 @@ namespace SeamlessClientPlugin.SeamlessTransfer LoadMembersFromWorld = GetMethod(typeof(MySession), "LoadMembersFromWorld", BindingFlags.NonPublic | BindingFlags.Instance); LoadMultiplayer = GetMethod(typeof(MySession), "LoadMultiplayer", BindingFlags.Static | BindingFlags.NonPublic); SendPlayerData = GetMethod(ClientType, "SendPlayerData", BindingFlags.Instance | BindingFlags.NonPublic); + UnloadProceduralWorldGenerator = GetMethod(typeof(MyProceduralWorldGenerator), "UnloadData", BindingFlags.Instance | BindingFlags.NonPublic); + MethodInfo ConnectToServer = GetMethod(typeof(MyGameService), "ConnectToServer", BindingFlags.Static | BindingFlags.Public);