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 BetterSoulCost v1.0.8
BetterSoulCost.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 IL.RoR2; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("BetterSoulCost")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BetterSoulCost")] [assembly: AssemblyTitle("BetterSoulCost")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace BetterSoulCost; [BepInPlugin("com.RiskOfBrainrot.BetterSoulCost", "BetterSoulCost", "1.0.6")] public class SoulCostPlugin : BaseUnityPlugin { public const string guid = "com.RiskOfBrainrot.BetterSoulCost"; public const string teamName = "RiskOfBrainrot"; public const string modName = "BetterSoulCost"; public const string version = "1.0.6"; public static PluginInfo PInfo { get; private set; } internal static ConfigFile CustomConfigFile { get; set; } public static ConfigEntry<bool> DoCradleSoulCost { get; set; } private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\BetterSoulCost.cfg", true); DoCradleSoulCost = CustomConfigFile.Bind<bool>("BetterSoulCost: Reworks", "Change Soul Cost Stacking", true, "If true, soul penalties will increase exponentially to approximate consistent health loss, rather than hyperbolically."); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(FixSoulPayCost)); ShrineColossusAccessBehavior.OnInteraction += new Manipulator(ShapingShrineSoulSpread); } public static void DebugBreakpoint(string methodName, int breakpointNumber = -1) { string text = "BetterSoulCost: " + methodName + " IL hook failed!"; if (breakpointNumber >= 0) { text += $" (breakpoint {breakpointNumber})"; } Debug.LogError((object)text); } private void ShapingShrineSoulSpread(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.GotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddUnmanagedBuff") }); val.Remove(); val.EmitDelegate<Action<CharacterBody, int, int>>((Action<CharacterBody, int, int>)delegate(CharacterBody body, int buffIndex, int buffCount) { AddSoulCostToBody(body, (BuffIndex)buffIndex, (float)buffCount * 0.1f); }); } public static void AddSoulCostToBody(CharacterBody body, float soulCost) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) AddSoulCostToBody(body, Buffs.SoulCost.buffIndex, soulCost); } public static void AddSoulCostToBody(CharacterBody body, BuffIndex buffIndex, float soulCost) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } soulCost = Mathf.Min(soulCost, 0.99f); int buffCount = body.GetBuffCount(buffIndex); float num = soulCost * 10f; if (DoCradleSoulCost.Value) { float num2 = 1f; if (buffCount > 0) { num2 = 1f / (1f + 0.1f * (float)buffCount); } float num3 = num * num / (num2 * (10f - num)); num += num3; } body.AddUnmanagedBuff(buffIndex, Mathf.CeilToInt(num)); } [SystemInitializer(new Type[] { typeof(CostTypeCatalog) })] private void FixSoulPayCost() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown CostTypeDef costTypeDef = CostTypeCatalog.GetCostTypeDef((CostTypeIndex)15); MethodInfo method = ((Delegate)(object)costTypeDef.payCost).Method; MethodInfo method2 = ((Delegate)(object)costTypeDef.isAffordable).Method; ILHook val = new ILHook((MethodBase)method, new Manipulator(FixSoulCost)); ILHook val2 = new ILHook((MethodBase)method2, new Manipulator(FixSoulCostAfford)); } private void FixSoulCostAfford(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.Emit(OpCodes.Ldc_I4, 1); val.Emit(OpCodes.Ret); } private void FixSoulCost(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown ILCursor val = new ILCursor(il); int minHealthLoc = 0; if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "get_fullCombinedHealth") }) || !val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref minHealthLoc) })) { DebugBreakpoint("FixSoulCost", 1); return; } val.EmitDelegate<Func<float, float>>((Func<float, float>)((float _) => 0f)); if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddUnmanagedBuff") })) { DebugBreakpoint("FixSoulCost", 2); return; } val.Remove(); val.EmitDelegate<Action<CharacterBody, int, int>>((Action<CharacterBody, int, int>)delegate(CharacterBody body, int buffIndex, int buffCount) { if (buffCount > 0) { float soulCost = (float)buffCount * 0.1f; AddSoulCostToBody(body, (BuffIndex)buffIndex, soulCost); } }); } }