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 TastyAdrenaline v1.0.1
plugins\TastyAdrenaline.dll
Decompiled 2 days agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace TastyAdrenaline; internal static class AdrenalinePatch { [HarmonyPatch(typeof(Player), "AddAdrenaline")] private static class PlayerAddAdrenalinePatch { private static void Prefix(ref float v) { if (isMultiplierActive && !isPotionGainActive && !(v <= 0f)) { v *= TastyAdrenalinePlugin.AdrenalineMultiplier.Value; } } } private static bool isMultiplierActive; private static bool isPotionGainActive; private static Harmony harmony; internal static void Apply() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown harmony = new Harmony("com.celwood.tastyadrenaline"); harmony.PatchAll(typeof(AdrenalinePatch).Assembly); } internal static void SetIsActive(bool isActive) { isMultiplierActive = isActive; } internal static void AddPotionGain(float v) { isPotionGainActive = true; try { ((Character)Player.m_localPlayer).AddAdrenaline(v); } finally { isPotionGainActive = false; } } } public class SE_TastyAdrenaline : SE_Stats { private const float TickIntervalSeconds = 1.95f; private bool isRunning; public SE_TastyAdrenaline() { ((StatusEffect)this).m_ttl = 10f; ((StatusEffect)this).m_name = "SE_TastyAdrenaline"; ((StatusEffect)this).m_tooltip = "Slowly gain adrenaline instantly and every 2 seconds while active."; } public override void Setup(Character character) { ((SE_Stats)this).Setup(character); Player val = (Player)(object)((character is Player) ? character : null); if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer)) { AdrenalinePatch.SetIsActive(isActive: true); isRunning = true; ((MonoBehaviour)val).StartCoroutine(GainAdrenalineOverTime(val)); } } public override void Stop() { isRunning = false; AdrenalinePatch.SetIsActive(isActive: false); ((StatusEffect)this).Stop(); } public override string GetTooltipString() { StringBuilder stringBuilder = new StringBuilder(128); if (!string.IsNullOrEmpty(((StatusEffect)this).m_tooltip)) { stringBuilder.AppendLine(((StatusEffect)this).m_tooltip); } stringBuilder.AppendFormat("<color=orange>Gaining adrenaline over {3}s</color>", ((StatusEffect)this).m_ttl); return stringBuilder.ToString(); } private float GetAdrenalineAmountForTick(int tickIndex, int tickCount) { if (tickIndex == tickCount - 1 && TastyAdrenalinePlugin.FinalAdrenalineAmount.Value > 0f) { return TastyAdrenalinePlugin.FinalAdrenalineAmount.Value; } if (tickIndex == 0 && TastyAdrenalinePlugin.InitialAdrenalineAmount.Value > 0f) { return TastyAdrenalinePlugin.InitialAdrenalineAmount.Value; } return TastyAdrenalinePlugin.AdrenalinePerTick.Value; } private IEnumerator GainAdrenalineOverTime(Player player) { int tickCount = Mathf.Max(1, Mathf.CeilToInt(((StatusEffect)this).m_ttl / 1.95f)); for (int tick = 0; tick < tickCount; tick++) { if (!isRunning) { break; } if (!((Object)(object)player != (Object)null)) { break; } AdrenalinePatch.AddPotionGain(GetAdrenalineAmountForTick(tick, tickCount)); if (tick < tickCount - 1) { yield return (object)new WaitForSeconds(1.95f); } } isRunning = false; } } public class SE_TastyWrapper : StatusEffect { public StatusEffect m_originalSE; public StatusEffect m_extraSE; public override void Setup(Character character) { ((StatusEffect)this).Setup(character); if (!((Object)(object)character == (Object)null)) { if ((Object)(object)m_originalSE != (Object)null) { character.GetSEMan().AddStatusEffect(m_originalSE, true, 0, 0f, (short)(-1)); } if ((Object)(object)m_extraSE != (Object)null) { character.GetSEMan().AddStatusEffect(m_extraSE, true, 0, 0f, (short)(-1)); } } } } [BepInPlugin("com.celwood.tastyadrenaline", "Tasty Adrenaline", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class TastyAdrenalinePlugin : BaseUnityPlugin { public const string PluginGuid = "com.celwood.tastyadrenaline"; public const string PluginName = "Tasty Adrenaline"; public const string PluginVersion = "1.0.1"; internal static ConfigEntry<float> AdrenalinePerTick { get; private set; } internal static ConfigEntry<float> InitialAdrenalineAmount { get; private set; } internal static ConfigEntry<float> FinalAdrenalineAmount { get; private set; } internal static ConfigEntry<float> AdrenalineMultiplier { get; private set; } private void Awake() { AdrenalinePerTick = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AdrenalinePerTick", 1f, "Amount of adrenaline gained on each regular tick."); InitialAdrenalineAmount = ((BaseUnityPlugin)this).Config.Bind<float>("General", "InitialAdrenalineAmount", 0f, "Amount of adrenaline gained on use of Tasty Mead. Defaults to 0, which uses AdrenalinePerTick."); FinalAdrenalineAmount = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FinalAdrenalineAmount", 0f, "Amount of adrenaline gained when the effects of Tasty Mead fade. Defaults to 0, which uses AdrenalinePerTick."); AdrenalineMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AdrenalineMultiplier", 1f, "Multiplier applied to other positive adrenaline gains while Tasty Mead is active. This does not affect the adrenaline gained from the Tasty Adrenaline status effect."); AdrenalinePatch.Apply(); Logger.LogInfo((object)"Tasty Adrenaline loaded"); PrefabManager.OnVanillaPrefabsAvailable += PatchTastyMead; } private void PatchTastyMead() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown try { SE_TastyAdrenaline sE_TastyAdrenaline = ScriptableObject.CreateInstance<SE_TastyAdrenaline>(); ((Object)sE_TastyAdrenaline).name = "SE_TastyAdrenaline"; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)sE_TastyAdrenaline, false)); GameObject prefab = PrefabManager.Instance.GetPrefab("MeadTasty"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"[TastyAdrenaline] Tasty mead prefab not found."); return; } ItemDrop component = prefab.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)("[TastyAdrenaline] " + ((Object)prefab).name + " has no ItemDrop component.")); return; } StatusEffect consumeStatusEffect = component.m_itemData.m_shared.m_consumeStatusEffect; SE_TastyWrapper sE_TastyWrapper = ScriptableObject.CreateInstance<SE_TastyWrapper>(); ((Object)sE_TastyWrapper).name = "SE_TastyWrapper_Adrenaline"; sE_TastyWrapper.m_originalSE = consumeStatusEffect; sE_TastyWrapper.m_extraSE = (StatusEffect)(object)sE_TastyAdrenaline; ((StatusEffect)sE_TastyWrapper).m_ttl = (((Object)(object)consumeStatusEffect != (Object)null) ? consumeStatusEffect.m_ttl : ((StatusEffect)sE_TastyAdrenaline).m_ttl); ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)sE_TastyWrapper, false)); component.m_itemData.m_shared.m_consumeStatusEffect = (StatusEffect)(object)sE_TastyWrapper; Logger.LogInfo((object)("[TastyAdrenaline] Attached adrenaline wrapper to tasty mead: " + ((Object)prefab).name)); } catch (Exception arg) { Logger.LogError((object)$"Error patching tasty mead: {arg}"); } finally { PrefabManager.OnVanillaPrefabsAvailable -= PatchTastyMead; } } }