Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Valuables Uncapped v2.1.0
EmpressValuablesUncapped.dll
Decompiled 3 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("Empress Valuables Uncapped")] [assembly: AssemblyTitle("EmpressValuablesUncapped")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.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 Empress.ValuablesUncapped { [BepInPlugin("empress.repo.valuablesbypass", "Empress Valuables Uncapped", "1.3.0")] public sealed class EmpressValuablesUncappedPlugin : BaseUnityPlugin { public const string PluginGuid = "empress.repo.valuablesbypass"; public const string PluginName = "Empress Valuables Uncapped"; public const string PluginVersion = "1.3.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> BypassValueBudget; internal static ConfigEntry<bool> FillValuableSpots; internal static ConfigEntry<bool> HostOnly; private void Awake() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; BypassValueBudget = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "BypassValueBudget", true, "Ignores the total value budget so expensive valuables no longer reduce how many valuables spawn."); FillValuableSpots = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FillValuableSpots", false, "Uses most valid valuable spots instead of the vanilla spawn amount caps."); HostOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HostOnly", true, "Applies the bypass only on the host/master client."); Harmony val = new Harmony("empress.repo.valuablesbypass"); val.PatchAll(typeof(ValuableDirectorSetupHostPatch)); val.PatchAll(typeof(ValuableDirectorSpawnValuablePatch)); } } [HarmonyPatch(typeof(ValuableDirector), "SetupHost")] internal static class ValuableDirectorSetupHostPatch { private static readonly FieldRef<ValuableDirector, ValuableDebug> ValuableDebugRef = AccessTools.FieldRefAccess<ValuableDirector, ValuableDebug>("valuableDebug"); private static void Prefix(ValuableDirector __instance) { if (EmpressValuablesUncappedPlugin.FillValuableSpots.Value && (!EmpressValuablesUncappedPlugin.HostOnly.Value || SemiFunc.IsMasterClientOrSingleplayer())) { ValuableDebugRef.Invoke(__instance) = (ValuableDebug)1; } } } [HarmonyPatch] internal static class ValuableDirectorSpawnValuablePatch { private static readonly Type ValuableDirectorType = AccessTools.TypeByName("ValuableDirector") ?? throw new TypeLoadException("ValuableDirector"); private static readonly FieldRef<object, float> TotalMaxValueRef = AccessTools.FieldRefAccess<float>(ValuableDirectorType, "totalMaxValue"); private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("PrefabRef") ?? throw new TypeLoadException("PrefabRef"); Type type2 = AccessTools.TypeByName("ValuableVolume") ?? throw new TypeLoadException("ValuableVolume"); MethodInfo methodInfo = AccessTools.Method(ValuableDirectorType, "SpawnValuable", new Type[3] { type, type2, typeof(string) }, (Type[])null); if (methodInfo != null) { return methodInfo; } methodInfo = AccessTools.Method(ValuableDirectorType, "Spawn", new Type[3] { type, type2, typeof(string) }, (Type[])null); if (methodInfo != null) { return methodInfo; } throw new MissingMethodException("ValuableDirector", "SpawnValuable(PrefabRef, ValuableVolume, string)"); } private static void Prefix(object __instance) { if (!EmpressValuablesUncappedPlugin.BypassValueBudget.Value || (EmpressValuablesUncappedPlugin.HostOnly.Value && !SemiFunc.IsMasterClientOrSingleplayer())) { return; } try { TotalMaxValueRef.Invoke(__instance) = float.PositiveInfinity; } catch (Exception arg) { EmpressValuablesUncappedPlugin.Log.LogError((object)$"Failed to bypass valuable budget: {arg}"); } } } }