Added Mod Loading & Unloading

This commit is contained in:
Bob Da Ross
2021-11-06 11:24:38 -05:00
parent 1f888260f2
commit cf51b5f0e7
4 changed files with 21 additions and 8 deletions

View File

@@ -108,7 +108,7 @@ namespace SeamlessClientPlugin
public static string Version = "1.3.04"; public static string Version = "1.3.04";
public static bool Debug = false; public static bool Debug = true;
private static bool Initilized = false; private static bool Initilized = false;

View File

@@ -91,11 +91,12 @@ namespace SeamlessClientPlugin.SeamlessTransfer
if (!DownloadSuccess) if (!DownloadSuccess)
return; return;
/*
MySession.Static.ScriptManager.LoadData(); MySession.Static.ScriptManager.LoadData();
MyDefinitionManager.Static.LoadData(TargetServerMods); MyDefinitionManager.Static.LoadData(TargetServerMods);
MyLocalCache.PreloadLocalInventoryConfig(); MyLocalCache.PreloadLocalInventoryConfig();
SeamlessClient.TryShow("Finished transfering!"); SeamlessClient.TryShow("Finished transfering!");
*/
} }

View File

@@ -10,8 +10,10 @@ using Sandbox.Game.Multiplayer;
using Sandbox.Game.SessionComponents; using Sandbox.Game.SessionComponents;
using Sandbox.Game.World; using Sandbox.Game.World;
using Sandbox.Game.World.Generator; using Sandbox.Game.World.Generator;
using Sandbox.Graphics.GUI;
using Sandbox.ModAPI; using Sandbox.ModAPI;
using SeamlessClientPlugin.Utilities; using SeamlessClientPlugin.Utilities;
using SpaceEngineers.Game.GUI;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@@ -134,11 +136,11 @@ namespace SeamlessClientPlugin.SeamlessTransfer
string text = ((!string.IsNullOrEmpty(TargetWorld.Checkpoint.CustomSkybox)) ? TargetWorld.Checkpoint.CustomSkybox : MySector.EnvironmentDefinition.EnvironmentTexture); string text = ((!string.IsNullOrEmpty(TargetWorld.Checkpoint.CustomSkybox)) ? TargetWorld.Checkpoint.CustomSkybox : MySector.EnvironmentDefinition.EnvironmentTexture);
MyRenderProxy.PreloadTextures(new string[1] { text }, TextureType.CubeMap); MyRenderProxy.PreloadTextures(new string[1] { text }, TextureType.CubeMap);
MySession.Static.LoadDataComponents(); MySession.Static.LoadDataComponents();
MySession.Static.LoadObjectBuildersComponents(TargetWorld.Checkpoint.SessionComponents); // MySession.Static.LoadObjectBuildersComponents(TargetWorld.Checkpoint.SessionComponents);
MethodInfo A = typeof(MySession).GetMethod("LoadGameDefinition", BindingFlags.Instance | BindingFlags.NonPublic); //MethodInfo A = typeof(MySession).GetMethod("LoadGameDefinition", BindingFlags.Instance | BindingFlags.NonPublic);
A.Invoke(MySession.Static, new object[] { TargetWorld.Checkpoint }); // A.Invoke(MySession.Static, new object[] { TargetWorld.Checkpoint });
@@ -426,6 +428,10 @@ namespace SeamlessClientPlugin.SeamlessTransfer
MyMultiplayer.Static.ReplicationLayer.Dispose(); MyMultiplayer.Static.ReplicationLayer.Dispose();
MyMultiplayer.Static.Dispose(); MyMultiplayer.Static.Dispose();
MyMultiplayer.Static = null; MyMultiplayer.Static = null;
//Close any respawn screens that are open
MyGuiScreenMedicals.Close();
} }
private void RemoveOldEntities() private void RemoveOldEntities()

View File

@@ -121,13 +121,16 @@ namespace SeamlessClientPlugin.SeamlessTransfer
MethodInfo LoadingScreenDraw = GetMethod(typeof(MyGuiScreenLoading), "DrawInternal", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo LoadingScreenDraw = GetMethod(typeof(MyGuiScreenLoading), "DrawInternal", BindingFlags.Instance | BindingFlags.NonPublic);
Patcher.Patch(LoadingScreenDraw, prefix: new HarmonyMethod(GetPatchMethod(nameof(DrawInternal)))); Patcher.Patch(LoadingScreenDraw, prefix: new HarmonyMethod(GetPatchMethod(nameof(DrawInternal))));
Patcher.Patch(OnJoin, postfix: new HarmonyMethod(GetPatchMethod(nameof(OnUserJoined)))); Patcher.Patch(OnJoin, postfix: new HarmonyMethod(GetPatchMethod(nameof(OnUserJoined))));
Patcher.Patch(LoadingAction, prefix: new HarmonyMethod(GetPatchMethod(nameof(LoadMultiplayerSession)))); Patcher.Patch(LoadingAction, prefix: new HarmonyMethod(GetPatchMethod(nameof(LoadMultiplayerSession))));
} }
@@ -152,8 +155,8 @@ namespace SeamlessClientPlugin.SeamlessTransfer
private static bool LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession) private static bool LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
{ {
if (SeamlessClient.IsSwitching) //
return true;
MyLog.Default.WriteLine("LoadSession() - Start"); MyLog.Default.WriteLine("LoadSession() - Start");
@@ -164,6 +167,9 @@ namespace SeamlessClientPlugin.SeamlessTransfer
return false; return false;
} }
MyLog.Default.WriteLine("Seamless Downloading mods!");
MyWorkshop.DownloadModsAsync(world.Checkpoint.Mods, delegate (bool success) MyWorkshop.DownloadModsAsync(world.Checkpoint.Mods, delegate (bool success)
{ {