diff --git a/SeamlessClient.cs b/SeamlessClient.cs index 16d181f..1214aec 100644 --- a/SeamlessClient.cs +++ b/SeamlessClient.cs @@ -106,7 +106,7 @@ namespace SeamlessClientPlugin - public static string Version = "1.3.00"; + public static string Version = "1.3.01"; public static bool Debug = false; private static bool Initilized = false; diff --git a/SeamlessTransfer/SwitchServers.cs b/SeamlessTransfer/SwitchServers.cs index 56ce61b..7cd7a56 100644 --- a/SeamlessTransfer/SwitchServers.cs +++ b/SeamlessTransfer/SwitchServers.cs @@ -14,10 +14,12 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using VRage; using VRage.Game; +using VRage.Game.Components; using VRage.Game.ModAPI; using VRage.GameServices; using VRage.Steam; @@ -337,16 +339,37 @@ namespace SeamlessClientPlugin.SeamlessTransfer { //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(); + + //This shoud never be null + var Generator = MySession.Static.GetComponent(); //Force component to unload Patches.UnloadProceduralWorldGenerator.Invoke(Generator, null); + //Re-call the generator init + MyObjectBuilder_WorldGenerator GeneratorSettings = (MyObjectBuilder_WorldGenerator)TargetWorld.Checkpoint.SessionComponents.FirstOrDefault(x => x.GetType() == typeof(MyObjectBuilder_WorldGenerator)); + if (GeneratorSettings != null) + { + //Re-initilized this component (forces to update asteroid areas like not in planets etc) + Generator.Init(GeneratorSettings); + } + + + //Force component to reload, re-syncing settings and seeds to the destination server Generator.LoadData(); - + + //We need to go in and force planets to be empty areas in the generator. This is originially done on planet init. + FieldInfo PlanetInitArgs = typeof(MyPlanet).GetField("m_planetInitValues", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + foreach (var Planet in MyEntities.GetEntities().OfType()) + { + MyPlanetInitArguments args = (MyPlanetInitArguments)PlanetInitArgs.GetValue(Planet); + + float MaxRadius = args.MaxRadius; + + Generator.MarkEmptyArea(Planet.PositionComp.GetPosition(), MaxRadius); + } } private void UnloadCurrentServer()