using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DaXcess")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright (c) DaXcess 2025")]
[assembly: AssemblyDescription("Force BepInEx dependencies to be soft dependencies")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BepInExDepSoftener")]
[assembly: AssemblyTitle("BepInExDepSoftener")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/DaXcess/BepInExDepSoftener")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInExDepSoftener
{
public static class BepInExDepSoftener
{
private static readonly ConfigFile Config;
internal static readonly string[] SoftDependencies;
public static IEnumerable<string> TargetDLLs { get; }
static BepInExDepSoftener()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
TargetDLLs = Array.Empty<string>();
Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "BepInExDepSoftener.cfg"), true);
ConfigEntry<string> val = Config.Bind<string>("General", "SoftDependencies", "", "A list of mod ids that should be considered soft dependencies by all other mods");
SoftDependencies = val.Value.Split(":::", StringSplitOptions.RemoveEmptyEntries);
}
public static void Initialize()
{
Harmony.CreateAndPatchAll(typeof(PreUnityPatches), (string)null);
}
public static void Patch(AssemblyDefinition assembly)
{
}
}
[HarmonyPatch]
internal static class PreUnityPatches
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void MainPatcherEntrypoint()
{
Harmony.CreateAndPatchAll(typeof(Patches), (string)null);
}
}
[HarmonyPatch]
internal static class Patches
{
[HarmonyPatch(typeof(Chainloader), "<Start>g__IsHardDependency|32_10")]
[HarmonyPrefix]
private static bool PatchIsHardDependency(BepInDependency dep, ref bool __result)
{
if (!BepInExDepSoftener.SoftDependencies.Contains(dep.DependencyGUID))
{
return true;
}
__result = false;
return false;
}
}
}