mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using System.Reflection;
|
|
using Robust.Shared.ContentPack;
|
|
using Robust.Shared.Interfaces.Resources;
|
|
|
|
namespace Robust.UnitTesting
|
|
{
|
|
public abstract partial class RobustIntegrationTest
|
|
{
|
|
private sealed class ModLoader : Robust.Shared.ContentPack.ModLoader, IModLoader
|
|
{
|
|
public Assembly ClientContentAssembly { get; set; }
|
|
public Assembly ServerContentAssembly { get; set; }
|
|
public Assembly SharedContentAssembly { get; set; }
|
|
|
|
public override void LoadGameAssembly<T>(byte[] assembly, byte[] symbols = null)
|
|
{
|
|
if (TryLoadPreset<T>())
|
|
{
|
|
return;
|
|
}
|
|
|
|
base.LoadGameAssembly<T>(assembly, symbols);
|
|
}
|
|
|
|
public override void LoadGameAssembly<T>(string diskPath)
|
|
{
|
|
if (TryLoadPreset<T>())
|
|
{
|
|
return;
|
|
}
|
|
|
|
base.LoadGameAssembly<T>(diskPath);
|
|
}
|
|
|
|
public override bool TryLoadAssembly<T>(IResourceManager resMan, string assemblyName)
|
|
{
|
|
if (TryLoadPreset<T>())
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return base.TryLoadAssembly<T>(resMan, assemblyName);
|
|
}
|
|
|
|
private bool TryLoadPreset<T>() where T : GameShared
|
|
{
|
|
if (typeof(T) == typeof(GameShared) && SharedContentAssembly != null)
|
|
{
|
|
InitMod<T>(SharedContentAssembly);
|
|
return true;
|
|
}
|
|
|
|
if (typeof(T) == typeof(GameServer) && ServerContentAssembly != null)
|
|
{
|
|
InitMod<T>(ServerContentAssembly);
|
|
return true;
|
|
}
|
|
|
|
if (typeof(T) == typeof(GameClient) && ClientContentAssembly != null)
|
|
{
|
|
InitMod<T>(ClientContentAssembly);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|