Decompiled source of Getting Yolked v1.0.0

tony4twentys-Getting Yolked.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Getting Yolked")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Getting Yolked")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("41234e88-2c24-4a63-8949-297cd0d3ef85")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("tony4twentys.Getting_Yolked", "Getting Yolked", "1.0.0")]
[BepInProcess("PEAK.exe")]
public class GettingYolkedPlugin : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <BoostStamina>d__5 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Character character;

		private float <boost>5__1;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <BoostStamina>d__5(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				Log.LogInfo((object)"[Getting Yolked] BoostStamina coroutine started");
				<>2__current = (object)new WaitForSeconds(0.25f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<boost>5__1 = ExtraStaminaFromEgg.Value;
				character.AddExtraStamina(<boost>5__1);
				if (character.IsLocal)
				{
					Log.LogInfo((object)$"[Getting Yolked] +{<boost>5__1} stamina granted from egg \ud83e\udd5a\ud83d\udcaa");
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static ConfigEntry<float> ExtraStaminaFromEgg;

	internal static ManualLogSource Log;

	internal static GettingYolkedPlugin Instance;

	private void Awake()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		ExtraStaminaFromEgg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ExtraStaminaFromEgg", 0.2f, "Amount of stamina to restore when eating an egg.");
		Harmony val = new Harmony("tony4twentys.getting_yolked");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"\ud83e\udd5a Getting Yolked mod initialized!");
	}

	public static void TryApplyEggBonus(Character character)
	{
		Log.LogInfo((object)"[Getting Yolked] TryApplyEggBonus called");
		if (!((Object)(object)character == (Object)null))
		{
			((MonoBehaviour)character).StartCoroutine(BoostStamina(character));
		}
	}

	[IteratorStateMachine(typeof(<BoostStamina>d__5))]
	private static IEnumerator BoostStamina(Character character)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <BoostStamina>d__5(0)
		{
			character = character
		};
	}
}
[HarmonyPatch]
public class Patch_FinishCastPrimary
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(Item), "FinishCastPrimary")]
	private static void Postfix(Item __instance)
	{
		GettingYolkedPlugin.Log.LogInfo((object)"[Getting Yolked] FinishCastPrimary triggered");
		if (!((Object)(object)__instance == (Object)null))
		{
			Character localCharacter = Character.localCharacter;
			if (!((Object)(object)__instance.holderCharacter != (Object)(object)localCharacter) && ((Object)__instance).name.StartsWith("Egg"))
			{
				GettingYolkedPlugin.TryApplyEggBonus(localCharacter);
			}
		}
	}
}
[HarmonyPatch]
public class Patch_FinishCastSecondary
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(Item), "FinishCastSecondary")]
	private static void Postfix(Item __instance)
	{
		GettingYolkedPlugin.Log.LogInfo((object)"[Getting Yolked] FinishCastSecondary triggered");
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		Character localCharacter = Character.localCharacter;
		if (!((Object)(object)__instance.holderCharacter != (Object)(object)localCharacter) && ((Object)__instance).name.StartsWith("Egg"))
		{
			Character holderCharacter = __instance.holderCharacter;
			Character val = ((holderCharacter != null) ? ((Component)holderCharacter).GetComponentInChildren<PlayerEyeLook>() : null)?.character;
			if ((Object)(object)val == (Object)null)
			{
				GettingYolkedPlugin.Log.LogInfo((object)"[Getting Yolked] No valid feed target");
			}
			else
			{
				GettingYolkedPlugin.TryApplyEggBonus(val);
			}
		}
	}
}
[HarmonyPatch(typeof(Character), "GetFedItemRPC")]
public class Patch_GetFedItemRPC
{
	[HarmonyPostfix]
	public static void Postfix(Character __instance, int itemPhotonID)
	{
		GettingYolkedPlugin.Log.LogInfo((object)"[Getting Yolked] GetFedItemRPC triggered");
		PhotonView val = PhotonView.Find(itemPhotonID);
		if (!((Object)(object)val == (Object)null))
		{
			Item component = ((Component)val).GetComponent<Item>();
			if (!((Object)(object)component == (Object)null) && ((Object)component).name.StartsWith("Egg"))
			{
				GettingYolkedPlugin.TryApplyEggBonus(__instance);
			}
		}
	}
}