Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of FruityBarrierDecay v2.2.0
BarrierRework.dll
Decompiled 2 days 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 MoreStats; using On.RoR2; using On.RoR2.Items; using R2API; using R2API.Utils; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; 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("BarrierRework")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BarrierRework")] [assembly: AssemblyTitle("BarrierRework")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: UnverifiableCode] namespace BarrierRework; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.RiskOfBrainrot.FruityBarrierDecay", "FruityBarrierDecay", "2.1.3")] [R2APISubmoduleDependency(new string[] { "LanguageAPI", "ContentAddition" })] public class BarrierReworkPlugin : BaseUnityPlugin { public static float _aegisBarrierFlat = 40f; public static float _aegisBarrierPercent = 10f; public static BuffDef aegisDecayBuff; public const string guid = "com.RiskOfBrainrot.FruityBarrierDecay"; public const string teamName = "RiskOfBrainrot"; public const string modName = "FruityBarrierDecay"; public const string version = "2.1.3"; private bool _useDynamicDecay = true; private float _barrierDecayRateStatic = 30f; private float _barrierDecayHighFactor = 5f; private float _barrierDecayLowFactor = 0.33f; public static PluginInfo PInfo { get; private set; } internal static ConfigFile CustomConfigFile { get; private set; } public static ConfigEntry<float> BarrierDecayRateStatic { get; set; } public static ConfigEntry<float> BarrierDecayHighFactor { get; set; } public static ConfigEntry<float> BarrierDecayLowFactor { get; set; } public static ConfigEntry<bool> AegisRework { get; set; } public static ConfigEntry<float> AegisBarrierFlat { get; set; } public static ConfigEntry<float> AegisBarrierPercent { get; set; } protected void ReworkAegis() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown CreateBuff(); Hooks(); HealthComponent.Heal += new Manipulator(RemoveAegisOverheal); LanguageAPI.Add("ITEM_BARRIERONOVERHEAL_PICKUP", "Gain barrier on any interaction. While out of danger, barrier stops decaying."); LanguageAPI.Add("ITEM_BARRIERONOVERHEAL_DESC", "Using any interactable grants a <style=cIsHealing>temporary barrier</style> " + $"for <style=cIsHealing>{AegisBarrierFlat.Value} health</style> <style=cStack>(+{AegisBarrierFlat.Value} per stack)</style> " + "plus an additional " + $"<style=cIsHealing>{AegisBarrierPercent.Value}%</style> <style=cStack>(+{AegisBarrierPercent.Value}% per stack)</style> " + "of <style=cIsHealing>maximum health</style>. While outside of danger, <style=cIsUtility>barrier will not decay</style>."); } private void RemoveAegisOverheal(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<ItemCounts>(x, "barrierOnOverHeal") }); val.Emit(OpCodes.Pop); val.Emit(OpCodes.Ldc_I4_0); } private void CreateBuff() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) aegisDecayBuff = ScriptableObject.CreateInstance<BuffDef>(); ((Object)aegisDecayBuff).name = "AegisDecayFreeze"; aegisDecayBuff.buffColor = new Color(0.95f, 0.85f, 0.08f); aegisDecayBuff.canStack = false; aegisDecayBuff.isDebuff = false; aegisDecayBuff.iconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/texBuffGenericShield.tif").WaitForCompletion(); ContentAddition.AddBuffDef(aegisDecayBuff); } public void Hooks() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown MultiShopCardUtils.OnMoneyPurchase += new hook_OnMoneyPurchase(OnMoneyPurchase); MultiShopCardUtils.OnNonMoneyPurchase += new hook_OnNonMoneyPurchase(OnNonMoneyPurchase); CharacterBody.OnInventoryChanged += new hook_OnInventoryChanged(AddItemBehavior); StatHooks.GetMoreStatCoefficients += new MoreStatHookEventHandler(AegisDecayFreeze); } private void AegisDecayFreeze(CharacterBody body, MoreStatHookEventArgs args) { if (body.HasBuff(aegisDecayBuff)) { args.barrierFreezeCount++; } } private void OnNonMoneyPurchase(orig_OnNonMoneyPurchase orig, PayCostContext context) { AegisBarrierGrant(context); orig.Invoke(context); } private void OnMoneyPurchase(orig_OnMoneyPurchase orig, PayCostContext context) { AegisBarrierGrant(context); orig.Invoke(context); } private void AddItemBehavior(orig_OnInventoryChanged orig, CharacterBody self) { orig.Invoke(self); if (NetworkServer.active) { self.AddItemBehavior<AegisDecayBehavior>(self.inventory.GetItemCountEffective(Items.BarrierOnOverHeal)); } } private void AegisBarrierGrant(PayCostContext context) { CharacterMaster activatorMaster = context.activatorMaster; CharacterBody val = ((activatorMaster != null) ? activatorMaster.GetBody() : null); if (Object.op_Implicit((Object)(object)val)) { int itemCountEffective = val.inventory.GetItemCountEffective(Items.BarrierOnOverHeal); HealthComponent healthComponent = val.healthComponent; if (itemCountEffective > 0 && (Object)(object)healthComponent != (Object)null) { float num = Util.ConvertAmplificationPercentageIntoReductionNormalized((float)itemCountEffective * AegisBarrierPercent.Value * 0.01f) * healthComponent.fullCombinedHealth; float num2 = (float)itemCountEffective * AegisBarrierFlat.Value; healthComponent.AddBarrierAuthority(num + num2); } } } public void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\FruityBarrierDecay.cfg", true); AegisRework = CustomConfigFile.Bind<bool>("Aegis Rework", "Enable Aegis Rework", true, "Set to true to use fruity aegis, set to false for vanilla aegis."); AegisBarrierFlat = CustomConfigFile.Bind<float>("Aegis Rework", "Aegis Barrier On Interactable (Flat)", _aegisBarrierFlat, "How much barrier the reworked Aegis grants on using interactables."); AegisBarrierPercent = CustomConfigFile.Bind<float>("Aegis Rework", "Aegis Barrier On Interactable (Percent)", _aegisBarrierPercent, "How much barrier the reworked Aegis grants on using interactables. Approaches and does not exceed 100%."); BarrierDecayRateStatic = CustomConfigFile.Bind<float>("Barrier Stats", "Flat Decay Time", _barrierDecayRateStatic, "Base barrier decay rate before modifiers, vanilla is 30. Expressed in seconds to deplete maximum barrier."); BarrierDecayHighFactor = CustomConfigFile.Bind<float>("Barrier Stats", "Dynamic Decay Factor (High)", _barrierDecayHighFactor, "Decay rate modifier when at HIGH barrier, vanilla is 3. Expressed as a multiplication of base decay."); BarrierDecayLowFactor = CustomConfigFile.Bind<float>("Barrier Stats", "Dynamic Decay Factor (Low)", _barrierDecayLowFactor, "Decay rate modifier when at LOW barrier, vanilla is 0.5. Expressed as a multiplication of base decay."); if (AegisRework.Value) { ReworkAegis(); } RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(BuffBarrier)); } private void BuffBarrier() { BaseStats.BarrierDecayStaticMaxHealthTime = BarrierDecayRateStatic.Value; BaseStats.BarrierHighDecayFactor = BarrierDecayHighFactor.Value; BaseStats.BarrierLowDecayFactor = BarrierDecayLowFactor.Value; } private void ChangeBarrierDecay(CharacterBody sender, MoreStatHookEventArgs args) { } } public class AegisDecayBehavior : ItemBehavior { private bool decayFrozen = false; public void FixedUpdate() { if (base.body.outOfDanger != decayFrozen) { if (!decayFrozen) { FreezeDecay(); } else { UnfreezeDecay(); } } } private void FreezeDecay() { decayFrozen = true; base.body.AddBuff(BarrierReworkPlugin.aegisDecayBuff); } private void UnfreezeDecay() { decayFrozen = false; base.body.RemoveBuff(BarrierReworkPlugin.aegisDecayBuff); } private void OnDisable() { if (decayFrozen) { UnfreezeDecay(); } } }