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 v1.2.1
EmpressValuableBypass.dll
Decompiled 3 months 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: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmpressValuableBypass")] [assembly: AssemblyTitle("EmpressValuableBypass")] [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 Empress.ValuablesBypass { [BepInPlugin("empress.repo.valuablesbypass", "Empress Valuables Bypass", "1.1.1")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "empress.repo.valuablesbypass"; public const string PluginName = "Empress Valuables Bypass"; public const string PluginVersion = "1.1.1"; internal static ManualLogSource Log; internal static Harmony Harmony; internal static ConfigEntry<bool> BypassValueBudget; internal static ConfigEntry<bool> HostOnly; private void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; BypassValueBudget = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "BypassValueBudget", true, "If true, ignores the total value budget so expensive items no longer reduce how many valuables spawn."); HostOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HostOnly", true, "Apply the bypass only on the host/master. Keep this true for multiplayer safety."); Harmony = new Harmony("empress.repo.valuablesbypass"); Harmony.PatchAll(); Log.LogInfo((object)string.Format("{0} {1} loaded. BypassValueBudget={2}, HostOnly={3}", "Empress Valuables Bypass", "1.1.1", BypassValueBudget.Value, HostOnly.Value)); } private void OnDestroy() { try { Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch (Exception arg) { ManualLogSource log = Log; if (log != null) { log.LogError((object)$"Unpatch failed: {arg}"); } } } } [HarmonyPatch] internal static class ValuableDirector_Spawn_Patch { private static readonly Type TargetType = AccessTools.TypeByName("ValuableDirector"); private static readonly FieldRef<object, float> f_totalMaxValue = AccessTools.FieldRefAccess<float>(TargetType, "totalMaxValue"); private static readonly Func<object, bool> isHost = BuildIsHostCheck(); private static MethodBase TargetMethod() { return AccessTools.Method(TargetType, "Spawn", new Type[3] { AccessTools.TypeByName("PrefabRef"), AccessTools.TypeByName("ValuableVolume"), typeof(string) }, (Type[])null); } private static bool Prefix(object __instance) { if (!Plugin.BypassValueBudget.Value) { return true; } if (Plugin.HostOnly.Value && !isHost(__instance)) { return true; } try { f_totalMaxValue.Invoke(__instance) = float.PositiveInfinity; } catch (Exception arg) { Plugin.Log.LogError((object)$"ValuablesBypass: failed in Prefix => {arg}"); } return true; } private static Func<object, bool> BuildIsHostCheck() { try { Type type = AccessTools.TypeByName("Photon.Pun.PhotonNetwork"); if (type != null) { PropertyInfo prop = AccessTools.Property(type, "IsMasterClient"); if (prop?.GetGetMethod() != null) { return (object _) => (bool)prop.GetGetMethod().Invoke(null, null); } } } catch { } try { Type type2 = AccessTools.TypeByName("GameManager"); FieldInfo instField = AccessTools.Field(type2, "instance"); PropertyInfo modeProp = AccessTools.Property(type2, "gameMode"); if (instField != null && modeProp?.GetGetMethod() != null) { return delegate { object value = instField.GetValue(null); if (value == null) { return true; } int num = (int)modeProp.GetGetMethod().Invoke(value, null); return num == 0; }; } } catch { } return (object _) => true; } } }