Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of SacrificeChanges v1.0.1
SacrificeChanges.dll
Decompiled 2 years 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 HG.Reflection; using IL.RoR2.Artifacts; using Mono.Cecil.Cil; using MonoMod.Cil; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: OptIn] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] internal static class log { private static ManualLogSource logger; internal static void start(ManualLogSource logSource) { logger = logSource; } internal static void start(string name) { logger = Logger.CreateLogSource(name); } internal static void info(object data) { logger.LogInfo(data); } internal static void message(object data) { logger.LogMessage(data); } internal static void warning(object data) { logger.LogWarning(data); } internal static void error(object data) { logger.LogError(data); } internal static void fatal(object data) { logger.LogFatal(data); } } namespace SacrificeChanges; [BepInPlugin("dolso.sacrificechanges", "SacrificeChanges", "1.0.1")] internal class Sacrifice : BaseUnityPlugin { private static ConfigFile ConfigFile; public static ConfigEntry<bool> timelessToggle; public static ConfigEntry<bool> dropReworkToggle; public static ConfigEntry<float> dropMultiplier; public static ConfigEntry<float> dropVariance; internal static ManualLogSource log = Logger.CreateLogSource("Sacrifice"); private static float storedChance = 0f; private void Awake() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown DoConfig(); if (dropReworkToggle.Value) { Run.onRunStartGlobal += delegate { storedChance = 0f + Random.Range(0f - dropVariance.Value, dropVariance.Value); log.LogMessage((object)("Initial pool = " + storedChance)); }; } if (timelessToggle.Value || dropReworkToggle.Value) { SacrificeArtifactManager.OnServerCharacterDeath += new Manipulator(OnServerCharacterDeath_IL); log.LogInfo((object)"Sacrifice Changes Loaded"); } } private void OnServerCharacterDeath_IL(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (timelessToggle.Value) { ILLabel val3 = default(ILLabel); val.GotoNext(new Func<Instruction, bool>[2] { (Instruction a) => ILPatternMatchingExt.MatchBrtrue(a, ref val3), (Instruction a) => ILPatternMatchingExt.MatchRet(a) }); val.EmitDelegate<Func<bool>>((Func<bool>)(() => (int)SceneCatalog.mostRecentSceneDef.sceneType != 2)); val.Emit(OpCodes.And); } if (!dropReworkToggle.Value) { return; } int num2 = default(int); float num = default(float); ILLabel val2 = default(ILLabel); val.GotoNext(new Func<Instruction, bool>[5] { (Instruction a) => ILPatternMatchingExt.MatchLdloc(a, ref num2), (Instruction a) => ILPatternMatchingExt.MatchLdcR4(a, ref num), (Instruction a) => ILPatternMatchingExt.MatchLdnull(a), (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(Util), "CheckRoll"), (Instruction a) => ILPatternMatchingExt.MatchBrfalse(a, ref val2) }); val.Index += 1; val.RemoveRange(3); val.EmitDelegate<Func<float, bool>>((Func<float, bool>)delegate(float dropchance) { storedChance += dropchance * dropMultiplier.Value; log.LogInfo((object)("Stored drop chance: " + storedChance.ToString("0"))); if (storedChance < 100f) { return false; } storedChance -= 100f + Random.Range(0f - dropVariance.Value, dropVariance.Value); log.LogMessage((object)("Pool reset to: " + storedChance.ToString("0"))); return true; }); } private void DoConfig() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown ConfigFile = new ConfigFile(Paths.ConfigPath + "//SacrificeChanges.cfg", true); timelessToggle = ConfigFile.Bind<bool>("Sacrifice", "Timeless drop toggle", true, "If timeless areas such as Bulwark's Ambry and Gilded Coast should have sacrifice drops disable"); dropReworkToggle = ConfigFile.Bind<bool>("Sacrifice", "Drop Rework toggle", true, "If drop rework should be enabled"); dropMultiplier = ConfigFile.Bind<float>("Sacrifice", "Drop Chance Multiplier", 1f, "Drop chance multiplier"); dropVariance = ConfigFile.Bind<float>("Sacrifice", "Drop pool reset variance", 20f, new ConfigDescription("When pool reaches 100%, substract -100 +-reset_variance", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void SCRVariance(ConCommandArgs args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)args.sender).isLocalPlayer) { Debug.LogWarning((object)"Only Host may change this value"); return; } if (((ConCommandArgs)(ref args)).Count == 0) { Debug.Log((object)("Reset Variance = " + dropVariance.Value)); return; } if (!float.TryParse(((ConCommandArgs)(ref args))[0], out var result)) { Debug.LogWarning((object)("Could not parse: " + ((ConCommandArgs)(ref args))[0])); return; } if (result < 0f || result > 100f) { Debug.LogWarning((object)"Number must be between 0 and 100"); return; } dropVariance.Value = result; Debug.Log((object)("Set reset variance to: " + dropVariance.Value)); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void SCDMultipler(ConCommandArgs args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)args.sender).isLocalPlayer) { Debug.LogWarning((object)"Only Host may change this value"); return; } if (((ConCommandArgs)(ref args)).Count == 0) { Debug.Log((object)("Drop Multiplier = " + dropMultiplier.Value)); return; } if (!float.TryParse(((ConCommandArgs)(ref args))[0], out var result)) { Debug.LogWarning((object)("Could not parse: " + ((ConCommandArgs)(ref args))[0])); return; } dropMultiplier.Value = result; Debug.Log((object)("Set drop chance multiplier to: " + dropMultiplier.Value)); } }