Future methods for loading/unloading sessions.
Fix reflected manager to work with instance methods on internal types.
This commit is contained in:
@@ -237,8 +237,12 @@ namespace Torch.Utils
|
|||||||
argExp[i] = Expression.Convert(paramExp[i + 1], invokeTypes[i]);
|
argExp[i] = Expression.Convert(paramExp[i + 1], invokeTypes[i]);
|
||||||
else
|
else
|
||||||
argExp[i] = paramExp[i + 1];
|
argExp[i] = paramExp[i + 1];
|
||||||
|
Debug.Assert(methodInstance.DeclaringType != null);
|
||||||
|
Expression instanceExp = paramExp[0].Type != methodInstance.DeclaringType
|
||||||
|
? Expression.Convert(paramExp[0], methodInstance.DeclaringType)
|
||||||
|
: (Expression) paramExp[0];
|
||||||
field.SetValue(null,
|
field.SetValue(null,
|
||||||
Expression.Lambda(Expression.Call(paramExp[0], methodInstance, argExp), paramExp)
|
Expression.Lambda(Expression.Call(instanceExp, methodInstance, argExp), paramExp)
|
||||||
.Compile());
|
.Compile());
|
||||||
_log.Trace($"Reflecting field {field.DeclaringType?.FullName}#{field.Name} with {methodInstance.DeclaringType?.FullName}#{methodInstance.Name}");
|
_log.Trace($"Reflecting field {field.DeclaringType?.FullName}#{field.Name} with {methodInstance.DeclaringType?.FullName}#{methodInstance.Name}");
|
||||||
}
|
}
|
||||||
|
@@ -10,13 +10,16 @@ using Havok;
|
|||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Fluent;
|
using NLog.Fluent;
|
||||||
using Sandbox;
|
using Sandbox;
|
||||||
|
using Sandbox.Engine.Multiplayer;
|
||||||
using Sandbox.Engine.Networking;
|
using Sandbox.Engine.Networking;
|
||||||
using Sandbox.Engine.Platform.VideoMode;
|
using Sandbox.Engine.Platform.VideoMode;
|
||||||
using Sandbox.Game;
|
using Sandbox.Game;
|
||||||
|
using Sandbox.Game.World;
|
||||||
using SpaceEngineers.Game;
|
using SpaceEngineers.Game;
|
||||||
using SpaceEngineers.Game.GUI;
|
using SpaceEngineers.Game.GUI;
|
||||||
using Torch.Utils;
|
using Torch.Utils;
|
||||||
using VRage;
|
using VRage;
|
||||||
|
using VRage.Audio;
|
||||||
using VRage.FileSystem;
|
using VRage.FileSystem;
|
||||||
using VRage.Game;
|
using VRage.Game;
|
||||||
using VRage.Game.SessionComponents;
|
using VRage.Game.SessionComponents;
|
||||||
@@ -35,6 +38,17 @@ namespace Torch
|
|||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[ReflectedGetter(Name = "m_plugins", Type = typeof(MyPlugins))]
|
[ReflectedGetter(Name = "m_plugins", Type = typeof(MyPlugins))]
|
||||||
private static readonly Func<List<IPlugin>> _getVRagePluginList;
|
private static readonly Func<List<IPlugin>> _getVRagePluginList;
|
||||||
|
|
||||||
|
[ReflectedGetter(Name = "Static", TypeName = "Sandbox.Game.Audio.MyMusicController, Sandbox.Game")]
|
||||||
|
private static readonly Func<object> _getMusicControllerStatic;
|
||||||
|
|
||||||
|
|
||||||
|
[ReflectedSetter(Name = "Static", TypeName = "Sandbox.Game.Audio.MyMusicController, Sandbox.Game")]
|
||||||
|
private static readonly Action<object> _setMusicControllerStatic;
|
||||||
|
|
||||||
|
|
||||||
|
[ReflectedMethod(Name = "Unload", TypeName = "Sandbox.Game.Audio.MyMusicController, Sandbox.Game")]
|
||||||
|
private static readonly Action<object> _musicControllerUnload;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
private readonly TorchBase _torch;
|
private readonly TorchBase _torch;
|
||||||
@@ -210,6 +224,34 @@ namespace Torch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadSession(string sessionPath)
|
||||||
|
{
|
||||||
|
// ?
|
||||||
|
MySessionLoader.LoadSingleplayerSession(sessionPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnloadSession()
|
||||||
|
{
|
||||||
|
if (MySession.Static != null)
|
||||||
|
{
|
||||||
|
MySession.Static.Unload();
|
||||||
|
MySession.Static = null;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
var musicCtl = _getMusicControllerStatic();
|
||||||
|
if (musicCtl != null)
|
||||||
|
{
|
||||||
|
_musicControllerUnload(musicCtl);
|
||||||
|
_setMusicControllerStatic(null);
|
||||||
|
MyAudio.Static.MusicAllowed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (MyMultiplayer.Static != null)
|
||||||
|
{
|
||||||
|
MyMultiplayer.Static.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DoStop()
|
private void DoStop()
|
||||||
{
|
{
|
||||||
ParallelTasks.Parallel.Scheduler.WaitForTasksToFinish(TimeSpan.FromSeconds(10.0));
|
ParallelTasks.Parallel.Scheduler.WaitForTasksToFinish(TimeSpan.FromSeconds(10.0));
|
||||||
|
Reference in New Issue
Block a user