Tweaked initializer to keep the SpaceEngineersGame instance around.

This commit is contained in:
Westin Miller
2017-11-25 15:52:53 -08:00
parent 1b0dcc9808
commit e709b6c321
13 changed files with 452 additions and 377 deletions

View File

@@ -101,10 +101,15 @@ namespace Torch.API
Task Save(long callerId); Task Save(long callerId);
/// <summary> /// <summary>
/// Initialize the Torch instance. /// Initialize the Torch instance. Before this <see cref="Start"/> is invalid.
/// </summary> /// </summary>
void Init(); void Init();
/// <summary>
/// Disposes the Torch instance. After this <see cref="Start"/> is invalid.
/// </summary>
void Dispose();
/// <summary> /// <summary>
/// The current state of the game this instance of torch is controlling. /// The current state of the game this instance of torch is controlling.
/// </summary> /// </summary>

View File

@@ -127,7 +127,6 @@
<Compile Include="TorchClient.cs" /> <Compile Include="TorchClient.cs" />
<Compile Include="TorchClientConfig.cs" /> <Compile Include="TorchClientConfig.cs" />
<Compile Include="TorchConsoleScreen.cs" /> <Compile Include="TorchConsoleScreen.cs" />
<Compile Include="TorchMainMenuScreen.cs" />
<Compile Include="TorchSettingsScreen.cs" /> <Compile Include="TorchSettingsScreen.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
@@ -140,6 +139,9 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="UI\TorchMainMenuScreen.cs" />
<Compile Include="UI\TorchNavScreen.cs" />
<Compile Include="UI\TorchSettingsScreen.cs" />
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>

View File

@@ -14,6 +14,7 @@ using Torch.API;
using Torch.API.Managers; using Torch.API.Managers;
using Torch.API.Session; using Torch.API.Session;
using Torch.Client.Manager; using Torch.Client.Manager;
using Torch.Client.UI;
using Torch.Session; using Torch.Session;
using VRage; using VRage;
using VRage.FileSystem; using VRage.FileSystem;
@@ -27,7 +28,9 @@ namespace Torch.Client
{ {
private MyCommonProgramStartup _startup; private MyCommonProgramStartup _startup;
private IMyRender _renderer; private IMyRender _renderer;
private const uint APP_ID = 244850;
protected override uint SteamAppId => 244850;
protected override string SteamAppName => "Space Engineers";
public TorchClient() public TorchClient()
{ {
@@ -46,10 +49,9 @@ namespace Torch.Client
Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias); Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias);
MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries); MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries);
Log.Info("Initializing Torch Client"); Log.Info("Initializing Torch Client");
base.Init();
SpaceEngineersGame.SetupBasicGameInfo();
_startup = new MyCommonProgramStartup(RunArgs); _startup = new MyCommonProgramStartup(RunArgs);
SpaceEngineersGame.SetupBasicGameInfo();
SpaceEngineersGame.SetupPerGameSettings();
if (_startup.PerformReporting()) if (_startup.PerformReporting())
throw new InvalidOperationException("Torch client won't launch when started in error reporting mode"); throw new InvalidOperationException("Torch client won't launch when started in error reporting mode");
@@ -58,27 +60,16 @@ namespace Torch.Client
throw new InvalidOperationException("Only one instance of Space Engineers can be running at a time."); throw new InvalidOperationException("Only one instance of Space Engineers can be running at a time.");
var appDataPath = _startup.GetAppDataPath(); var appDataPath = _startup.GetAppDataPath();
MyInitializer.InvokeBeforeRun(APP_ID, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath); Config.InstancePath = appDataPath;
MyInitializer.InitCheckSum(); base.Init();
_startup.InitSplashScreen(); OverrideMenus();
if (!_startup.Check64Bit()) SetRenderWindowTitle($"Space Engineers v{GameVersion} with Torch v{TorchVersion}");
throw new InvalidOperationException("Torch requires a 64bit operating system"); }
_startup.DetectSharpDxLeaksBeforeRun(); public override void Dispose()
var steamService = new SteamService(Game.IsDedicated, APP_ID); {
MyServiceManager.Instance.AddService<IMyGameService>(steamService); base.Dispose();
_renderer = null; _startup.DetectSharpDxLeaksAfterRun();
SpaceEngineersGame.SetupPerGameSettings();
// I'm sorry, but it's what Keen does in SpaceEngineers.MyProgram
#pragma warning disable 612
SpaceEngineersGame.SetupRender();
#pragma warning restore 612
InitializeRender();
if (!_startup.CheckSteamRunning())
throw new InvalidOperationException("Space Engineers requires steam to be running");
if (!Game.IsDedicated)
MyFileSystem.InitUserSpecific(MyGameService.UserId.ToString());
} }
private void OverrideMenus() private void OverrideMenus()
@@ -96,18 +87,6 @@ namespace Torch.Client
MyPerGameSettings.GUI.MainMenu = typeof(TorchMainMenuScreen); MyPerGameSettings.GUI.MainMenu = typeof(TorchMainMenuScreen);
} }
public override void Start()
{
using (var spaceEngineersGame = new SpaceEngineersGame(RunArgs))
{
Log.Info("Starting client");
OverrideMenus();
spaceEngineersGame.OnGameLoaded += SpaceEngineersGame_OnGameLoaded;
spaceEngineersGame.OnGameExit += Dispose;
spaceEngineersGame.Run(false, _startup.DisposeSplashScreen);
}
}
private void SetRenderWindowTitle(string title) private void SetRenderWindowTitle(string title)
{ {
MyRenderThread renderThread = MySandboxGame.Static?.GameRenderComponent?.RenderThread; MyRenderThread renderThread = MySandboxGame.Static?.GameRenderComponent?.RenderThread;
@@ -125,58 +104,9 @@ namespace Torch.Client
}); });
} }
private void SpaceEngineersGame_OnGameLoaded(object sender, EventArgs e) public override void Restart()
{ {
SetRenderWindowTitle($"Space Engineers v{GameVersion} with Torch v{TorchVersion}"); throw new NotImplementedException();
}
public override void Dispose()
{
MyGameService.ShutDown();
_startup.DetectSharpDxLeaksAfterRun();
MyInitializer.InvokeAfterRun();
}
public override void Stop()
{
MySandboxGame.ExitThreadSafe();
}
private void InitializeRender()
{
try
{
if (Game.IsDedicated)
{
_renderer = new MyNullRender();
}
else
{
var graphicsRenderer = MySandboxGame.Config.GraphicsRenderer;
if (graphicsRenderer == MySandboxGame.DirectX11RendererKey)
{
_renderer = new MyDX11Render();
if (!_renderer.IsSupported)
{
MySandboxGame.Log.WriteLine("DirectX 11 renderer not supported. No renderer to revert back to.");
_renderer = null;
}
}
if (_renderer == null)
throw new MyRenderException("The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html", MyRenderExceptionEnum.GpuNotSupported);
MySandboxGame.Config.GraphicsRenderer = graphicsRenderer;
}
MyRenderProxy.Initialize(_renderer);
MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Render Initialization Failed");
Environment.Exit(-1);
}
} }
} }
} }

View File

@@ -1,45 +0,0 @@
#pragma warning disable 618
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Game.Gui;
using Sandbox.Graphics;
using Sandbox.Graphics.GUI;
using Sandbox.Gui;
using SpaceEngineers.Game.GUI;
using VRage.Game;
using VRage.Utils;
using VRageMath;
namespace Torch.Client
{
public class TorchMainMenuScreen : MyGuiScreenMainMenu
{
public TorchMainMenuScreen()
: this(false)
{
}
public TorchMainMenuScreen(bool pauseGame)
: base(pauseGame)
{
}
/// <inheritdoc />
public override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
var buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
Vector2 leftButtonPositionOrigin = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM) + new Vector2(buttonSize.X / 2f, 0f);
var btn = MakeButton(leftButtonPositionOrigin - 9 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyStringId.GetOrCompute("Torch"), TorchButtonClicked);
Controls.Add(btn);
}
private void TorchButtonClicked(MyGuiControlButton obj)
{
MyGuiSandbox.AddScreen(new TorchSettingsScreen());
}
}
}

View File

@@ -0,0 +1,56 @@
#pragma warning disable 618
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Engine.Networking;
using Sandbox.Engine.Utils;
using Sandbox.Game;
using Sandbox.Game.Gui;
using Sandbox.Graphics;
using Sandbox.Graphics.GUI;
using Sandbox.Gui;
using SpaceEngineers.Game.GUI;
using Torch.Utils;
using VRage.Game;
using VRage.Utils;
using VRageMath;
namespace Torch.Client.UI
{
public class TorchMainMenuScreen : MyGuiScreenMainMenu
{
#pragma warning disable 169
[ReflectedGetter(Name = "m_elementGroup")]
private static Func<MyGuiScreenMainMenu, MyGuiControlElementGroup> _elementsGroup;
#pragma warning restore 169
public TorchMainMenuScreen() : this(false)
{
}
public TorchMainMenuScreen(bool pauseGame)
: base(pauseGame)
{
}
/// <inheritdoc />
public override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
Vector2 minSizeGui = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
Vector2 value = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, 54, 54) + new Vector2(minSizeGui.X / 2f, 0f) + new Vector2(15f, 0f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
MyGuiControlButton myGuiControlButton = MakeButton(value - 9 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
MyStringId.GetOrCompute("Torch"), TorchButtonClicked, MyCommonTexts.ToolTipExitToWindows);
Controls.Add(myGuiControlButton);
_elementsGroup.Invoke(this).Add(myGuiControlButton);
}
private void TorchButtonClicked(MyGuiControlButton obj)
{
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen<TorchNavScreen>());
}
}
}

View File

@@ -0,0 +1,49 @@
using Sandbox;
using Sandbox.Game.Gui;
using Sandbox.Graphics.GUI;
using VRage;
using VRage.Game;
using VRage.Utils;
using VRageMath;
namespace Torch.Client.UI
{
public class TorchNavScreen : MyGuiScreenBase
{
private MyGuiControlElementGroup _elementGroup;
public TorchNavScreen() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.35875f, 0.558333337f))
{
EnabledBackgroundFade = true;
RecreateControls(true);
}
public override void RecreateControls(bool constructor)
{
base.RecreateControls(constructor);
_elementGroup = new MyGuiControlElementGroup();
_elementGroup.HighlightChanged += ElementGroupHighlightChanged;
AddCaption(MyCommonTexts.ScreenCaptionOptions, null, null);
var value = new Vector2(0f, -m_size.Value.Y / 2f + 0.146f);
var num = 0;
var myGuiControlButton = new MyGuiControlButton(value + num++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, MyTexts.Get(MyCommonTexts.ScreenOptionsButtonGame), 0.8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, delegate(MyGuiControlButton sender)
{
MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen<TorchSettingsScreen>());
}, GuiSounds.MouseClick, 1f, null);
Controls.Add(myGuiControlButton);
_elementGroup.Add(myGuiControlButton);
CloseButtonEnabled = true;
}
private void ElementGroupHighlightChanged(MyGuiControlElementGroup obj)
{
foreach (MyGuiControlBase current in _elementGroup)
if (current.HasFocus && obj.SelectedElement != current)
FocusedControl = obj.SelectedElement;
}
public override string GetFriendlyName() => "Torch";
public void OnBackClick(MyGuiControlButton sender) => CloseScreen();
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Graphics.GUI;
using VRageMath;
namespace Torch.Client.UI
{
public class TorchSettingsScreen : MyGuiScreenBase
{
public TorchSettingsScreen() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR,
new Vector2(0.35875f, 0.558333337f))
{
EnabledBackgroundFade = true;
RecreateControls(true);
}
/// <inheritdoc />
public override string GetFriendlyName() => "Torch Settings";
public void OnBackClick(MyGuiControlButton sender) => CloseScreen();
}
}

View File

@@ -33,22 +33,12 @@ namespace Torch.Server.Managers
} }
/// <inheritdoc />
public override void Attach()
{
MyFileSystem.ExePath = Path.Combine(_filesystemManager.TorchDirectory, "DedicatedServer64");
MyFileSystem.Init("Content", Torch.Config.InstancePath);
//Initializes saves path. Why this isn't in Init() we may never know.
MyFileSystem.InitUserSpecific(null);
}
public void LoadInstance(string path, bool validate = true) public void LoadInstance(string path, bool validate = true)
{ {
if (validate) if (validate)
ValidateInstance(path); ValidateInstance(path);
MyFileSystem.Reset(); MyFileSystem.Reset();
MyFileSystem.ExePath = Path.Combine(_filesystemManager.TorchDirectory, "DedicatedServer64");
MyFileSystem.Init("Content", path); MyFileSystem.Init("Content", path);
//Initializes saves path. Why this isn't in Init() we may never know. //Initializes saves path. Why this isn't in Init() we may never know.
MyFileSystem.InitUserSpecific(null); MyFileSystem.InitUserSpecific(null);

View File

@@ -24,20 +24,9 @@ namespace Torch.Server.Managers
} }
} }
// class AdminsCanJoinExample : IEventHandler
// {
// [EventHandler(SkipCancelled = false)]
// public void Handle(ref ValidateAuthTicketEvent info)
// {
// if (MySandboxGame.ConfigDedicated.Administrators.Contains(info.SteamID.ToString())
// || (info.ServerGroup == MySandboxGame.ConfigDedicated.GroupID && info.Officer))
// info.Verdict = JoinResult.OK;
// }
// }
/// <summary> /// <summary>
/// Event that occurs when a player tries to connect to the server. /// Event that occurs when a player tries to connect to a dedicated server.
/// Use these values to choose a <see cref="ValidateAuthTicketEvent.Verdict"/>, /// Use these values to choose a <see cref="ValidateAuthTicketEvent.FutureVerdict"/>,
/// or leave it unset to allow the default logic to handle the request. /// or leave it unset to allow the default logic to handle the request.
/// </summary> /// </summary>
public struct ValidateAuthTicketEvent : IEvent public struct ValidateAuthTicketEvent : IEvent
@@ -73,7 +62,7 @@ namespace Torch.Server.Managers
public readonly bool Officer; public readonly bool Officer;
/// <summary> /// <summary>
/// A future verdict on this authorization request. If null, let the default logic choose. /// A future verdict on this authorization request. If null, let the default logic choose. If not async use <see cref="Task.FromResult{TResult}(TResult)"/>
/// </summary> /// </summary>
public Task<JoinResult> FutureVerdict; public Task<JoinResult> FutureVerdict;

View File

@@ -44,19 +44,58 @@ namespace Torch.Server
{ {
//public MyConfigDedicated<MyObjectBuilder_SessionSettings> DedicatedConfig { get; set; } //public MyConfigDedicated<MyObjectBuilder_SessionSettings> DedicatedConfig { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public float SimulationRatio { get => _simRatio; set { _simRatio = value; OnPropertyChanged(); } } public float SimulationRatio
{
get => _simRatio;
set
{
_simRatio = value;
OnPropertyChanged();
}
}
/// <inheritdoc /> /// <inheritdoc />
public TimeSpan ElapsedPlayTime { get => _elapsedPlayTime; set { _elapsedPlayTime = value; OnPropertyChanged(); } } public TimeSpan ElapsedPlayTime
{
get => _elapsedPlayTime;
set
{
_elapsedPlayTime = value;
OnPropertyChanged();
}
}
/// <inheritdoc /> /// <inheritdoc />
public Thread GameThread { get; private set; } public Thread GameThread { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public ServerState State { get => _state; private set { _state = value; OnPropertyChanged(); } } public ServerState State
{
get => _state;
private set
{
_state = value;
OnPropertyChanged();
}
}
/// <inheritdoc /> /// <inheritdoc />
public bool IsRunning { get => _isRunning; set { _isRunning = value; OnPropertyChanged(); } } public bool IsRunning
{
get => _isRunning;
set
{
_isRunning = value;
OnPropertyChanged();
}
}
/// <inheritdoc /> /// <inheritdoc />
public InstanceManager DedicatedInstance { get; } public InstanceManager DedicatedInstance { get; }
/// <inheritdoc /> /// <inheritdoc />
public string InstanceName => Config?.InstanceName; public string InstanceName => Config?.InstanceName;
/// <inheritdoc /> /// <inheritdoc />
public string InstancePath => Config?.InstancePath; public string InstancePath => Config?.InstancePath;
@@ -80,30 +119,20 @@ namespace Torch.Server
sessionManager.AddFactory((x) => new MultiplayerManagerDedicated(this)); sessionManager.AddFactory((x) => new MultiplayerManagerDedicated(this));
} }
/// <inheritdoc/>
protected override uint SteamAppId => 244850;
/// <inheritdoc/>
protected override string SteamAppName => "SpaceEngineersDedicated";
/// <inheritdoc /> /// <inheritdoc />
public override void Init() public override void Init()
{ {
Log.Info($"Init server '{Config.InstanceName}' at '{Config.InstancePath}'"); Log.Info($"Init server '{Config.InstanceName}' at '{Config.InstancePath}'");
Sandbox.Engine.Platform.Game.IsDedicated = true;
base.Init(); base.Init();
MyPerGameSettings.SendLogToKeen = false;
MyPerServerSettings.GameName = MyPerGameSettings.GameName;
MyPerServerSettings.GameNameSafe = MyPerGameSettings.GameNameSafe;
MyPerServerSettings.GameDSName = MyPerServerSettings.GameNameSafe + "Dedicated";
MyPerServerSettings.GameDSDescription = "Your place for space engineering, destruction and exploring.";
MySessionComponentExtDebug.ForceDisable = true;
MyPerServerSettings.AppId = 244850;
MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion;
InvokeBeforeRun();
//MyObjectBuilderSerializer.RegisterFromAssembly(typeof(MyObjectBuilder_CheckpointSerializer).Assembly);
MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly);
MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly);
MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly);
MyPlugins.RegisterSandboxGameAssemblyFile(MyPerGameSettings.SandboxGameAssembly);
MyPlugins.Load();
MyGlobalTypeMetadata.Static.Init();
Managers.GetManager<ITorchSessionManager>().SessionStateChanged += OnSessionStateChanged; Managers.GetManager<ITorchSessionManager>().SessionStateChanged += OnSessionStateChanged;
GetManager<InstanceManager>().LoadInstance(Config.InstancePath); GetManager<InstanceManager>().LoadInstance(Config.InstancePath);
} }
@@ -117,81 +146,64 @@ namespace Torch.Server
} }
} }
private void InvokeBeforeRun()
{
MySandboxGame.Log.Init("SpaceEngineers-Dedicated.log", MyFinalBuildConstants.APP_VERSION_STRING);
MySandboxGame.Log.WriteLine("Steam build: Always true");
MySandboxGame.Log.WriteLine("Environment.ProcessorCount: " + MyEnvironment.ProcessorCount);
//MySandboxGame.Log.WriteLine("Environment.OSVersion: " + GetOsName());
MySandboxGame.Log.WriteLine("Environment.CommandLine: " + Environment.CommandLine);
MySandboxGame.Log.WriteLine("Environment.Is64BitProcess: " + MyEnvironment.Is64BitProcess);
MySandboxGame.Log.WriteLine("Environment.Is64BitOperatingSystem: " + Environment.Is64BitOperatingSystem);
//MySandboxGame.Log.WriteLine("Environment.Version: " + GetNETFromRegistry());
MySandboxGame.Log.WriteLine("Environment.CurrentDirectory: " + Environment.CurrentDirectory);
MySandboxGame.Log.WriteLine("MainAssembly.ProcessorArchitecture: " + Assembly.GetExecutingAssembly().GetArchitecture());
MySandboxGame.Log.WriteLine("ExecutingAssembly.ProcessorArchitecture: " + MyFileSystem.MainAssembly.GetArchitecture());
MySandboxGame.Log.WriteLine("IntPtr.Size: " + IntPtr.Size);
MySandboxGame.Log.WriteLine("Default Culture: " + CultureInfo.CurrentCulture.Name);
MySandboxGame.Log.WriteLine("Default UI Culture: " + CultureInfo.CurrentUICulture.Name);
MySandboxGame.Log.WriteLine("IsAdmin: " + new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator));
MyLog.Default = MySandboxGame.Log;
Thread.CurrentThread.Name = "Main thread";
//Because we want exceptions from users to be in english
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
MySandboxGame.Config = new MyConfig("SpaceEngineers-Dedicated.cfg");
MySandboxGame.Config.Load();
}
[ReflectedStaticMethod(Type = typeof(DedicatedServer), Name = "RunInternal")]
private static Action _dsRunInternal;
/// <inheritdoc />
public override void Start() public override void Start()
{ {
if (State != ServerState.Stopped) if (State != ServerState.Stopped)
return; return;
State = ServerState.Starting;
IsRunning = true;
Log.Info("Starting server.");
MySandboxGame.ConfigDedicated = DedicatedInstance.DedicatedConfig.Model;
DedicatedInstance.SaveConfig(); DedicatedInstance.SaveConfig();
_uptime = Stopwatch.StartNew(); _uptime = Stopwatch.StartNew();
IsRunning = true;
GameThread = Thread.CurrentThread;
State = ServerState.Starting;
Log.Info("Starting server.");
MySandboxGame.IsDedicated = true;
MySandboxGame.ConfigDedicated = DedicatedInstance.DedicatedConfig.Model;
Environment.SetEnvironmentVariable("SteamAppId", MyPerServerSettings.AppId.ToString());
VRage.Service.ExitListenerSTA.OnExit += delegate { MySandboxGame.Static?.Exit(); };
base.Start(); base.Start();
// Stops RunInternal from calling MyFileSystem.InitUserSpecific(null), we call it in InstanceManager.
MySandboxGame.IsReloading = true;
try
{
_dsRunInternal.Invoke();
}
catch (TargetInvocationException e)
{
// Makes log formatting a little nicer.
throw e.InnerException ?? e;
} }
MySandboxGame.Log.Close(); /// <inheritdoc />
public override void Stop()
{
if (State == ServerState.Stopped)
Log.Error("Server is already stopped");
Log.Info("Stopping server.");
base.Stop();
Log.Info("Server stopped.");
LogManager.Flush();
_stopHandle.Set();
State = ServerState.Stopped; State = ServerState.Stopped;
IsRunning = false;
}
/// <summary>
/// Restart the program. DOES NOT SAVE!
/// </summary>
public override void Restart()
{
var exe = Assembly.GetExecutingAssembly().Location;
((TorchConfig) Config).WaitForPID = Process.GetCurrentProcess().Id.ToString();
Config.Autostart = true;
Process.Start(exe, Config.ToString());
Save(0).Wait();
Stop();
LogManager.Flush();
Process.GetCurrentProcess().Kill();
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Init(object gameInstance) public override void Init(object gameInstance)
{ {
base.Init(gameInstance); base.Init(gameInstance);
var game = gameInstance as MySandboxGame;
if (game != null && MySession.Static != null)
{
State = ServerState.Running; State = ServerState.Running;
SteamServerAPI.Instance.GameServer.SetKeyValue("SM", "Torch"); // SteamServerAPI.Instance.GameServer.SetKeyValue("SM", "Torch");
}
else
{
State = ServerState.Stopped;
}
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -205,10 +217,13 @@ namespace Torch.Server
if (_watchdog == null && Config.TickTimeout > 0) if (_watchdog == null && Config.TickTimeout > 0)
{ {
Log.Info("Starting server watchdog."); Log.Info("Starting server watchdog.");
_watchdog = new Timer(CheckServerResponding, this, TimeSpan.Zero, TimeSpan.FromSeconds(Config.TickTimeout)); _watchdog = new Timer(CheckServerResponding, this, TimeSpan.Zero,
TimeSpan.FromSeconds(Config.TickTimeout));
} }
} }
#region Freeze Detection
private static void CheckServerResponding(object state) private static void CheckServerResponding(object state)
{ {
var mre = new ManualResetEvent(false); var mre = new ManualResetEvent(false);
@@ -216,7 +231,8 @@ namespace Torch.Server
if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout))) if (!mre.WaitOne(TimeSpan.FromSeconds(Instance.Config.TickTimeout)))
{ {
#if DEBUG #if DEBUG
Log.Error($"Server watchdog detected that the server was frozen for at least {((TorchServer)state).Config.TickTimeout} seconds."); Log.Error(
$"Server watchdog detected that the server was frozen for at least {((TorchServer) state).Config.TickTimeout} seconds.");
Log.Error(DumpFrozenThread(MySandboxGame.Static.UpdateThread)); Log.Error(DumpFrozenThread(MySandboxGame.Static.UpdateThread));
#else #else
Log.Error(DumpFrozenThread(MySandboxGame.Static.UpdateThread)); Log.Error(DumpFrozenThread(MySandboxGame.Static.UpdateThread));
@@ -278,47 +294,7 @@ namespace Torch.Server
return stack; return stack;
} }
/// <inheritdoc /> #endregion
public override void Stop()
{
if (State == ServerState.Stopped)
Log.Error("Server is already stopped");
if (Thread.CurrentThread != MySandboxGame.Static.UpdateThread)
{
Log.Debug("Invoking server stop on game thread.");
Invoke(Stop);
return;
}
Log.Info("Stopping server.");
//Unload all the static junk.
//TODO: Finish unloading all server data so it's in a completely clean state.
MySandboxGame.Static.Exit();
Log.Info("Server stopped.");
LogManager.Flush();
_stopHandle.Set();
State = ServerState.Stopped;
IsRunning = false;
Process.GetCurrentProcess().Kill();
}
/// <summary>
/// Restart the program. DOES NOT SAVE!
/// </summary>
public override void Restart()
{
var exe = Assembly.GetExecutingAssembly().Location;
((TorchConfig)Config).WaitForPID = Process.GetCurrentProcess().Id.ToString();
Config.Autostart = true;
Process.Start(exe, Config.ToString());
Save(0).Wait();
Stop();
LogManager.Flush();
Process.GetCurrentProcess().Kill();
}
/// <inheritdoc/> /// <inheritdoc/>
public override Task Save(long callerId) public override Task Save(long callerId)
@@ -357,7 +333,8 @@ namespace Torch.Server
} }
if (MySession.Static.Players.TryGetPlayerId(callerId, out MyPlayer.PlayerId result)) if (MySession.Static.Players.TryGetPlayerId(callerId, out MyPlayer.PlayerId result))
{ {
Managers.GetManager<IChatManagerServer>()?.SendMessageAsOther("Server", response, statusCode == SaveGameStatus.Success ? MyFontEnum.Green : MyFontEnum.Red, result.SteamId); Managers.GetManager<IChatManagerServer>()?.SendMessageAsOther("Server", response,
statusCode == SaveGameStatus.Success ? MyFontEnum.Green : MyFontEnum.Red, result.SteamId);
} }
} }
} }

View File

@@ -186,10 +186,10 @@ namespace Torch.Managers.PatchManager.MSIL
#pragma warning disable 169 #pragma warning disable 649
[ReflectedMethod(Name = "StackChange")] [ReflectedMethod(Name = "StackChange")]
private static Func<OpCode, int> _stackChange; private static Func<OpCode, int> _stackChange;
#pragma warning restore 169 #pragma warning restore 649
/// <summary> /// <summary>
/// Estimates the stack delta for this instruction. /// Estimates the stack delta for this instruction.

View File

@@ -97,6 +97,7 @@ namespace Torch.Session
CurrentSession.Managers.AddManager(manager); CurrentSession.Managers.AddManager(manager);
} }
(CurrentSession as TorchSession)?.Attach(); (CurrentSession as TorchSession)?.Attach();
_log.Info($"Loaded torch session for {MySession.Static.Name}");
SetState(TorchSessionState.Loaded); SetState(TorchSessionState.Loaded);
} }
catch (Exception e) catch (Exception e)
@@ -115,7 +116,9 @@ namespace Torch.Session
_log.Warn("Session unloading event occurred when we don't have a session."); _log.Warn("Session unloading event occurred when we don't have a session.");
return; return;
} }
_log.Info($"Unloading torch session for {_currentSession.KeenSession.Name}");
SetState(TorchSessionState.Unloading); SetState(TorchSessionState.Unloading);
_currentSession.Detach();
} }
catch (Exception e) catch (Exception e)
{ {
@@ -133,9 +136,8 @@ namespace Torch.Session
_log.Warn("Session unloading event occurred when we don't have a session."); _log.Warn("Session unloading event occurred when we don't have a session.");
return; return;
} }
_log.Info($"Unloading torch session for {_currentSession.KeenSession.Name}"); _log.Info($"Unloaded torch session for {_currentSession.KeenSession.Name}");
SetState(TorchSessionState.Unloaded); SetState(TorchSessionState.Unloaded);
_currentSession.Detach();
_currentSession = null; _currentSession = null;
} }
catch (Exception e) catch (Exception e)

View File

@@ -1,10 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Security.Principal;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -12,6 +15,9 @@ using NLog;
using ProtoBuf.Meta; using ProtoBuf.Meta;
using Sandbox; using Sandbox;
using Sandbox.Engine.Multiplayer; using Sandbox.Engine.Multiplayer;
using Sandbox.Engine.Networking;
using Sandbox.Engine.Platform.VideoMode;
using Sandbox.Engine.Utils;
using Sandbox.Game; using Sandbox.Game;
using Sandbox.Game.Multiplayer; using Sandbox.Game.Multiplayer;
using Sandbox.Game.Screens.Helpers; using Sandbox.Game.Screens.Helpers;
@@ -19,6 +25,7 @@ using Sandbox.Game.World;
using Sandbox.Graphics.GUI; using Sandbox.Graphics.GUI;
using Sandbox.ModAPI; using Sandbox.ModAPI;
using SpaceEngineers.Game; using SpaceEngineers.Game;
using SpaceEngineers.Game.GUI;
using Torch.API; using Torch.API;
using Torch.API.Managers; using Torch.API.Managers;
using Torch.API.ModAPI; using Torch.API.ModAPI;
@@ -31,16 +38,22 @@ using Torch.Managers.PatchManager;
using Torch.Patches; using Torch.Patches;
using Torch.Utils; using Torch.Utils;
using Torch.Session; using Torch.Session;
using VRage;
using VRage.Collections; using VRage.Collections;
using VRage.FileSystem; using VRage.FileSystem;
using VRage.Game; using VRage.Game;
using VRage.Game.Common; using VRage.Game.Common;
using VRage.Game.Components; using VRage.Game.Components;
using VRage.Game.ObjectBuilder; using VRage.Game.ObjectBuilder;
using VRage.Game.SessionComponents;
using VRage.GameServices;
using VRage.Library;
using VRage.ObjectBuilders; using VRage.ObjectBuilders;
using VRage.Plugins; using VRage.Plugins;
using VRage.Scripting; using VRage.Scripting;
using VRage.Steam;
using VRage.Utils; using VRage.Utils;
using VRageRender;
namespace Torch namespace Torch
{ {
@@ -67,8 +80,10 @@ namespace Torch
/// Use only if necessary, prefer dependency injection. /// Use only if necessary, prefer dependency injection.
/// </summary> /// </summary>
public static ITorchBase Instance { get; private set; } public static ITorchBase Instance { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public ITorchConfig Config { get; protected set; } public ITorchConfig Config { get; protected set; }
/// <inheritdoc /> /// <inheritdoc />
public Version TorchVersion { get; } public Version TorchVersion { get; }
@@ -79,8 +94,10 @@ namespace Torch
/// <inheritdoc /> /// <inheritdoc />
public Version GameVersion { get; private set; } public Version GameVersion { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public string[] RunArgs { get; set; } public string[] RunArgs { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[Obsolete("Use GetManager<T>() or the [Dependency] attribute.")] [Obsolete("Use GetManager<T>() or the [Dependency] attribute.")]
public IPluginManager Plugins { get; protected set; } public IPluginManager Plugins { get; protected set; }
@@ -90,10 +107,13 @@ namespace Torch
/// <inheritdoc /> /// <inheritdoc />
public event Action SessionLoading; public event Action SessionLoading;
/// <inheritdoc /> /// <inheritdoc />
public event Action SessionLoaded; public event Action SessionLoaded;
/// <inheritdoc /> /// <inheritdoc />
public event Action SessionUnloading; public event Action SessionUnloading;
/// <inheritdoc /> /// <inheritdoc />
public event Action SessionUnloaded; public event Action SessionUnloaded;
@@ -120,7 +140,9 @@ namespace Torch
Instance = this; Instance = this;
TorchVersion = Assembly.GetExecutingAssembly().GetName().Version; TorchVersion = Assembly.GetExecutingAssembly().GetName().Version;
TorchVersionVerbose = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? TorchVersion.ToString(); TorchVersionVerbose = Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion ?? TorchVersion.ToString();
RunArgs = new string[0]; RunArgs = new string[0];
Managers = new DependencyManager(); Managers = new DependencyManager();
@@ -140,6 +162,39 @@ namespace Torch
Managers.AddManager(new EventManager(this)); Managers.AddManager(new EventManager(this));
Managers.AddManager(Plugins); Managers.AddManager(Plugins);
TorchAPI.Instance = this; TorchAPI.Instance = this;
GameStateChanged += (game, state) =>
{
if (state == TorchGameState.Created)
{
// If the attached assemblies change (MySandboxGame.ctor => MySandboxGame.ParseArgs => MyPlugins.RegisterFromArgs)
// attach assemblies to object factories again.
ObjectFactoryInitPatch.ForceRegisterAssemblies();
// safe to commit here; all important static ctors have run
PatchManager.CommitInternal();
}
};
sessionManager.SessionStateChanged += (session, state) =>
{
switch (state)
{
case TorchSessionState.Loading:
SessionLoading?.Invoke();
break;
case TorchSessionState.Loaded:
SessionLoaded?.Invoke();
break;
case TorchSessionState.Unloading:
SessionUnloading?.Invoke();
break;
case TorchSessionState.Unloaded:
SessionUnloaded?.Invoke();
break;
default:
throw new ArgumentOutOfRangeException(nameof(state), state, null);
}
};
} }
[Obsolete("Prefer using Managers.GetManager for global managers")] [Obsolete("Prefer using Managers.GetManager for global managers")]
@@ -252,34 +307,30 @@ namespace Torch
#endregion #endregion
#region Torch Init/Destroy
protected abstract uint SteamAppId { get; }
protected abstract string SteamAppName { get; }
/// <inheritdoc /> /// <inheritdoc />
public virtual void Init() public virtual void Init()
{ {
Debug.Assert(!_init, "Torch instance is already initialized."); Debug.Assert(!_init, "Torch instance is already initialized.");
SpaceEngineersGame.SetupBasicGameInfo(); SpaceEngineersGame.SetupBasicGameInfo();
SpaceEngineersGame.SetupPerGameSettings(); SpaceEngineersGame.SetupPerGameSettings();
// If the attached assemblies change (MySandboxGame.ctor => MySandboxGame.ParseArgs => MyPlugins.RegisterFromArgs)
// attach assemblies to object factories again.
ObjectFactoryInitPatch.ForceRegisterAssemblies(); ObjectFactoryInitPatch.ForceRegisterAssemblies();
GameStateChanged += (game, state) =>
{
if (state == TorchGameState.Created)
{
ObjectFactoryInitPatch.ForceRegisterAssemblies();
// safe to commit here; all important static ctors have run
PatchManager.CommitInternal();
}
};
Debug.Assert(MyPerGameSettings.BasicGameInfo.GameVersion != null, "MyPerGameSettings.BasicGameInfo.GameVersion != null"); Debug.Assert(MyPerGameSettings.BasicGameInfo.GameVersion != null,
GameVersion = new Version(new MyVersion(MyPerGameSettings.BasicGameInfo.GameVersion.Value).FormattedText.ToString().Replace("_", ".")); "MyPerGameSettings.BasicGameInfo.GameVersion != null");
GameVersion = new Version(new MyVersion(MyPerGameSettings.BasicGameInfo.GameVersion.Value).FormattedText
.ToString().Replace("_", "."));
try try
{ {
Console.Title = $"{Config.InstanceName} - Torch {TorchVersion}, SE {GameVersion}"; Console.Title = $"{Config.InstanceName} - Torch {TorchVersion}, SE {GameVersion}";
} }
catch catch
{ {
// Running as service // Running without a console
} }
#if DEBUG #if DEBUG
@@ -292,11 +343,7 @@ namespace Torch
Log.Info($"Executing assembly: {Assembly.GetEntryAssembly().FullName}"); Log.Info($"Executing assembly: {Assembly.GetEntryAssembly().FullName}");
Log.Info($"Executing directory: {AppDomain.CurrentDomain.BaseDirectory}"); Log.Info($"Executing directory: {AppDomain.CurrentDomain.BaseDirectory}");
MySession.OnLoading += OnSessionLoading; InitVRageInstance();
MySession.AfterLoading += OnSessionLoaded;
MySession.OnUnloading += OnSessionUnloading;
MySession.OnUnloaded += OnSessionUnloaded;
RegisterVRagePlugin();
Managers.GetManager<PluginManager>().LoadPlugins(); Managers.GetManager<PluginManager>().LoadPlugins();
Managers.Attach(); Managers.Attach();
_init = true; _init = true;
@@ -306,109 +353,156 @@ namespace Torch
PatchManager.CommitInternal(); PatchManager.CommitInternal();
} }
private void OnSessionLoading() /// <inheritdoc />
public virtual void Dispose()
{ {
Log.Debug("Session loading"); Managers.Detach();
try DisposeVRageInstance();
{
SessionLoading?.Invoke();
}
catch (Exception e)
{
Log.Error(e);
throw;
}
} }
private void OnSessionLoaded() #endregion
#region VRage Instance Init/Destroy
#pragma warning disable 649
[ReflectedGetter(Name = "m_plugins", Type = typeof(MyPlugins))]
private static readonly Func<List<IPlugin>> _getVRagePluginList;
#pragma warning restore 649
protected SpaceEngineersGame GameInstance { get; private set; }
/// <summary>
/// Sets up the VRage instance.
/// Any flags (ie <see cref="Sandbox.Engine.Platform.Game.IsDedicated"/>) must be set before this is called.
/// </summary>
protected virtual void InitVRageInstance()
{ {
Log.Debug("Session loaded"); bool dedicated = Sandbox.Engine.Platform.Game.IsDedicated;
try Environment.SetEnvironmentVariable("SteamAppId", SteamAppId.ToString());
MyServiceManager.Instance.AddService<IMyGameService>(new MySteamService(dedicated, SteamAppId));
if (dedicated && !MyGameService.HasGameServer)
{ {
SessionLoaded?.Invoke(); Log.Warn("Steam service is not running! Please reinstall dedicated server.");
} return;
catch (Exception e)
{
Log.Error(e);
throw;
}
} }
private void OnSessionUnloading() SpaceEngineersGame.SetupBasicGameInfo();
SpaceEngineersGame.SetupPerGameSettings();
MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion;
MySessionComponentExtDebug.ForceDisable = true;
MyPerGameSettings.SendLogToKeen = false;
// SpaceEngineersGame.SetupAnalytics();
MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location);
TweakGameSettings();
MyInitializer.InvokeBeforeRun(SteamAppId, SteamAppName, Config.InstancePath);
// MyInitializer.InitCheckSum();
// Hook into the VRage plugin system for updates.
_getVRagePluginList().Add(this);
if (!MySandboxGame.IsReloading)
MyFileSystem.InitUserSpecific(dedicated ? null : MyGameService.UserId.ToString());
MySandboxGame.IsReloading = dedicated;
// render init
{ {
Log.Debug("Session unloading"); IMyRender renderer = null;
try if (dedicated)
{ {
SessionUnloading?.Invoke(); renderer = new MyNullRender();
} }
catch (Exception e) else
{ {
Log.Error(e); MyPerformanceSettings preset = MyGuiScreenOptionsGraphics.GetPreset(MyRenderQualityEnum.NORMAL);
throw; MyRenderProxy.Settings.User = MyVideoSettingsManager.GetGraphicsSettingsFromConfig(ref preset)
.PerformanceSettings.RenderSettings;
MyStringId graphicsRenderer = MySandboxGame.Config.GraphicsRenderer;
if (graphicsRenderer == MySandboxGame.DirectX11RendererKey)
{
renderer = new MyDX11Render(new MyRenderSettings?(MyRenderProxy.Settings));
if (!renderer.IsSupported)
{
MySandboxGame.Log.WriteLine(
"DirectX 11 renderer not supported. No renderer to revert back to.");
renderer = null;
} }
} }
if (renderer == null)
{
throw new MyRenderException(
"The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html",
MyRenderExceptionEnum.GpuNotSupported);
}
MySandboxGame.Config.GraphicsRenderer = graphicsRenderer;
}
MyRenderProxy.Initialize(renderer);
MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
}
private void OnSessionUnloaded() GameInstance = new SpaceEngineersGame(RunArgs);
{
Log.Debug("Session unloaded");
try
{
SessionUnloaded?.Invoke();
}
catch (Exception e)
{
Log.Error(e);
throw;
}
} }
/// <summary> /// <summary>
/// Hook into the VRage plugin system for updates. /// Called after the basic game information is filled, but before the game is created.
/// </summary> /// </summary>
private void RegisterVRagePlugin() protected virtual void TweakGameSettings()
{ {
var fieldName = "m_plugins";
var pluginList = typeof(MyPlugins).GetField(fieldName, BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) as List<IPlugin>;
if (pluginList == null)
throw new TypeLoadException($"{fieldName} field not found in {nameof(MyPlugins)}");
pluginList.Add(this);
} }
/// <summary>
/// Tears down the VRage instance
/// </summary>
protected virtual void DisposeVRageInstance()
{
GameInstance.Dispose();
GameInstance = null;
MyGameService.ShutDown();
_getVRagePluginList().Remove(this);
MyInitializer.InvokeAfterRun();
}
#endregion
/// <inheritdoc/> /// <inheritdoc/>
public virtual Task Save(long callerId) public virtual Task Save(long callerId)
{ {
return Task.CompletedTask; return SaveGameAsync(null);
} }
/// <inheritdoc/> /// <inheritdoc/>
public virtual void Start() public virtual void Start()
{ {
if (MySandboxGame.FatalErrorDuringInit)
{
Log.Warn($"Failed to start sandbox game: fatal error during init");
return;
}
GameInstance.Run();
} }
/// <inheritdoc /> /// <inheritdoc />
public virtual void Stop() public virtual void Stop()
{ {
if (IsOnGameThread())
MySandboxGame.Static.Exit();
else
InvokeBlocking(MySandboxGame.Static.Exit);
} }
/// <inheritdoc /> /// <inheritdoc />
public virtual void Restart() public abstract void Restart();
{
}
/// <inheritdoc />
public virtual void Dispose()
{
Managers.Detach();
}
/// <inheritdoc /> /// <inheritdoc />
public virtual void Init(object gameInstance) public virtual void Init(object gameInstance)
{ {
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -435,6 +529,7 @@ namespace Torch
public event TorchGameStateChangedDel GameStateChanged; public event TorchGameStateChangedDel GameStateChanged;
private static readonly HashSet<Assembly> _registeredCoreAssemblies = new HashSet<Assembly>(); private static readonly HashSet<Assembly> _registeredCoreAssemblies = new HashSet<Assembly>();
/// <summary> /// <summary>
/// Registers a core (Torch) assembly with the system, including its /// Registers a core (Torch) assembly with the system, including its
/// <see cref="EventManager"/> shims, <see cref="PatchManager"/> shims, and <see cref="ReflectedManager"/> components. /// <see cref="EventManager"/> shims, <see cref="PatchManager"/> shims, and <see cref="ReflectedManager"/> components.