using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using IL.RoR2; using Mono.Cecil.Cil; using MonoMod.Cil; using R2API; using RoR2; using UnityEngine; [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("BalancedTranscendence")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BalancedTranscendence")] [assembly: AssemblyTitle("BalancedTranscendence")] [assembly: AssemblyVersion("1.0.0.0")] namespace BalancedTranscendence; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Sagittariod.BalancedTranscendence", "Balanced Transcendence", "1.0.0")] public class TranscendenceNerfPlugin : BaseUnityPlugin { public static ConfigEntry healthMaxBase; public static ConfigEntry healthMaxStack; public static ConfigEntry rechargeDelayBaseIncrease; public static ConfigEntry rechargeDelayStackIncrease; public void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown BindConfigs(); UpdateItemDescription(); CharacterBody.RecalculateStats += new Manipulator(CharacterBody_RecalculateStats_IL); CharacterBody.UpdateOutOfCombatAndDanger += new Manipulator(CharacterBody_get_outOfDanger_IL); } private void BindConfigs() { healthMaxBase = ((BaseUnityPlugin)this).Config.Bind("Transcendence", "Base Max Health", 0.5f, "Maximum health increase on the first stack (Vanilla = 0.5"); healthMaxStack = ((BaseUnityPlugin)this).Config.Bind("Transcendence", "Stack Max Health", 0.5f, "Maximum health increase per additional stack (Vanilla = 0.25)"); rechargeDelayBaseIncrease = ((BaseUnityPlugin)this).Config.Bind("Transcendence", "Base Recharge Delay Penalty", 0.5f, "Added delay before being considered out of danger from first stack."); rechargeDelayStackIncrease = ((BaseUnityPlugin)this).Config.Bind("Transcendence", "Stack Recharge Delay Penalty", 0.5f, "Added delay before being considered out of danger from additional stacks."); } private void UpdateItemDescription() { LanguageAPI.Add("ITEM_SHIELDONLY_PICKUP", "Convert all your health into shield. Increase maximum health. You are considered in danger for longer."); LanguageAPI.Add("ITEM_SHIELDONLY_DESC", $"Convert all but 1 health into regenerating shields. Gain {healthMaxBase.Value * 100f}% (+{healthMaxStack.Value * 100f}% per stack) maximum health. Increases the delay after getting hit before being considered out of danger delay by {rechargeDelayBaseIncrease.Value * 100f}% (+{rechargeDelayStackIncrease.Value * 100f}% per stack)."); } private void CharacterBody_RecalculateStats_IL(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); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "ShieldOnly") })) { if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f) })) { val.Next.Operand = healthMaxBase.Value; } if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.25f) })) { val.Next.Operand = healthMaxStack.Value; } } } private void CharacterBody_get_outOfDanger_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_004d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 7f) })) { return; } int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)delegate(float vanillaDelay, CharacterBody body) { if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.inventory)) { int itemCountEffective = body.inventory.GetItemCountEffective(Items.ShieldOnly); if (itemCountEffective > 0) { float num = rechargeDelayBaseIncrease.Value + rechargeDelayStackIncrease.Value * (float)(itemCountEffective - 1); return vanillaDelay * (1f + num); } } return vanillaDelay; }); } }