Merge pull request #15 from Casimir255/PluginLoader

Plugin loader
This commit is contained in:
Garrett
2021-06-17 00:16:42 -05:00
committed by GitHub
4 changed files with 45 additions and 0 deletions

View File

@@ -162,6 +162,7 @@
<Compile Include="Messages\WorldRequest.cs" />
<Compile Include="SeamlessClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SeamlessTransfer\ModLoader.cs" />
<Compile Include="SeamlessTransfer\PingServer.cs" />
<Compile Include="Messages\Transfer.cs" />
<Compile Include="Utilities\Patches.cs" />

View File

@@ -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
*
*
*
*
*/
}
}

View File

@@ -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<MyProceduralWorldGenerator>();
//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()
{

View File

@@ -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);