using System.IO; 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(Stream assembly, Stream? symbols = null) { if (TryLoadPreset()) { return; } base.LoadGameAssembly(assembly, symbols); } public override void LoadGameAssembly(string diskPath) { if (TryLoadPreset()) { return; } base.LoadGameAssembly(diskPath); } public override bool TryLoadAssembly(IResourceManager resMan, string assemblyName) { if (TryLoadPreset()) { return true; } return base.TryLoadAssembly(resMan, assemblyName); } private bool TryLoadPreset() where T : GameShared { if (typeof(T) == typeof(GameShared) && SharedContentAssembly != null) { InitMod(SharedContentAssembly); return true; } if (typeof(T) == typeof(GameServer) && ServerContentAssembly != null) { InitMod(ServerContentAssembly); return true; } if (typeof(T) == typeof(GameClient) && ClientContentAssembly != null) { InitMod(ClientContentAssembly); return true; } return false; } } } }