Decompiled source of TenMinuteEnergy v1.0.1

GDWeave/mods/LRFLEW.TenMinuteEnergy/LRFLEW.TenMinuteEnergy.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using GDWeave;
using GDWeave.Godot;
using GDWeave.Godot.Variants;
using GDWeave.Modding;
using Serilog;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyCompany("LRFLEW.TenMinuteEnergy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+f8708377076ae6cd42a46fa880476ca7e866bd5d")]
[assembly: AssemblyProduct("LRFLEW.TenMinuteEnergy")]
[assembly: AssemblyTitle("LRFLEW.TenMinuteEnergy")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace LRFLEW.TenMinuteEnergy;

public sealed class Mod : IMod, global::System.IDisposable
{
	public Mod(IModInterface modInterface)
	{
		modInterface.Logger.Information("TenMinuteEnergy: Mod Loaded");
		modInterface.RegisterScriptMod((IScriptMod)(object)new PlayerPatcher(modInterface.Logger));
	}

	public void Dispose()
	{
	}
}
internal class PlayerPatcher : IScriptMod
{
	[CompilerGenerated]
	private sealed class <Modify>d__6 : global::System.Collections.Generic.IEnumerable<Token>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<Token>, global::System.Collections.IEnumerator, global::System.IDisposable
	{
		private int <>1__state;

		private Token <>2__current;

		private int <>l__initialThreadId;

		private global::System.Collections.Generic.IEnumerable<Token> tokens;

		public global::System.Collections.Generic.IEnumerable<Token> <>3__tokens;

		public PlayerPatcher <>4__this;

		private MultiTokenWaiter <func_waiter>5__2;

		private MultiTokenWaiter[] <speed_waiters>5__3;

		private double[] <speed_atms>5__4;

		private int[] <speed_timers>5__5;

		private MultiTokenWaiter[] <catch_waiters>5__6;

		private MultiTokenWaiter[] <bounce_waiters>5__7;

		private int[] <bounce_timers>5__8;

		private MultiTokenWaiter <skip_waiter>5__9;

		private global::System.Collections.Generic.IEnumerator<Token> <>7__wrap9;

		private Token <token>5__11;

		private int <i>5__12;

		private global::System.Collections.Generic.IEnumerator<Token> <>7__wrap12;

		Token global::System.Collections.Generic.IEnumerator<Token>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

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

		[DebuggerHidden]
		public <Modify>d__6(int <>1__state)
		{
			this.<>1__state = <>1__state;
			<>l__initialThreadId = Environment.CurrentManagedThreadId;
		}

		[DebuggerHidden]
		void global::System.IDisposable.Dispose()
		{
			int num = <>1__state;
			if ((uint)(num - -6) > 3u && (uint)(num - 1) > 8u)
			{
				return;
			}
			try
			{
				switch (num)
				{
				case -4:
				case 3:
					try
					{
						break;
					}
					finally
					{
						<>m__Finally2();
					}
				case -5:
				case 4:
					try
					{
						break;
					}
					finally
					{
						<>m__Finally3();
					}
				case -6:
				case 5:
					try
					{
						break;
					}
					finally
					{
						<>m__Finally4();
					}
				}
			}
			finally
			{
				<>m__Finally1();
			}
		}

		private bool MoveNext()
		{
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Expected O, but got Unknown
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Expected O, but got Unknown
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Expected O, but got Unknown
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Expected O, but got Unknown
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Expected O, but got Unknown
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Expected O, but got Unknown
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Expected O, but got Unknown
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Expected O, but got Unknown
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Expected O, but got Unknown
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Expected O, but got Unknown
			try
			{
				int num = <>1__state;
				PlayerPatcher playerPatcher = <>4__this;
				MultiTokenWaiter[] array4;
				MultiTokenWaiter[] array5;
				MultiTokenWaiter[] array6;
				MultiTokenWaiter[] array7;
				global::System.ReadOnlySpan<MultiTokenWaiter> readOnlySpan3;
				global::System.ReadOnlySpan<MultiTokenWaiter> readOnlySpan4;
				global::System.ReadOnlySpan<MultiTokenWaiter> readOnlySpan5;
				int num3;
				MultiTokenWaiter[] array8;
				int num2;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<func_waiter>5__2 = new MultiTokenWaiter(new Func<Token, bool>[2]
					{
						(Token t) => (int)t.Type == 48,
						delegate(Token t)
						{
							IdentifierToken val = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val != null && val.Name == "_consume_item";
						}
					}, false, false);
					<speed_waiters>5__3 = (MultiTokenWaiter[])(object)new MultiTokenWaiter[2]
					{
						MatchWaiter("speed"),
						MatchWaiter("speed_burst")
					};
					<speed_atms>5__4 = new double[2] { 1.3, 4.0 };
					<speed_timers>5__5 = new int[2] { 18000, 900 };
					<catch_waiters>5__6 = (MultiTokenWaiter[])(object)new MultiTokenWaiter[3]
					{
						MatchWaiter("catch"),
						MatchWaiter("catch_big"),
						MatchWaiter("catch_deluxe")
					};
					<bounce_waiters>5__7 = (MultiTokenWaiter[])(object)new MultiTokenWaiter[2]
					{
						MatchWaiter("bounce"),
						MatchWaiter("bounce_big")
					};
					<bounce_timers>5__8 = new int[2] { 1200, 600 };
					<skip_waiter>5__9 = null;
					<>7__wrap9 = tokens.GetEnumerator();
					<>1__state = -3;
					goto IL_0690;
				case 1:
					<>1__state = -3;
					goto IL_0240;
				case 2:
					<>1__state = -3;
					goto IL_0240;
				case 3:
					<>1__state = -4;
					goto IL_02ea;
				case 4:
					<>1__state = -5;
					goto IL_03dd;
				case 5:
					<>1__state = -6;
					goto IL_04d0;
				case 6:
					<>1__state = -3;
					<>2__current = new Token((TokenType)23, (uint?)null);
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -3;
					<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)(<i>5__12 + 1), false));
					<>1__state = 8;
					return true;
				case 8:
					<>1__state = -3;
					<>2__current = new Token((TokenType)89, (uint?)3u);
					<>1__state = 9;
					return true;
				case 9:
					{
						<>1__state = -3;
						Func<Token, bool>[] array = AssignPattern("jump_bonus_tier", <i>5__12 + 1);
						Func<Token, bool>[] array2 = AssignPattern("jump_bonus_timer", <bounce_timers>5__8[<i>5__12]);
						num2 = 0;
						Func<Token, bool>[] array3 = new Func<Token, bool>[array.Length + array2.Length];
						global::System.ReadOnlySpan<Func<Token, bool>> readOnlySpan = new global::System.ReadOnlySpan<Func<Token, bool>>(array);
						readOnlySpan.CopyTo(new global::System.Span<Func<Token, bool>>(array3).Slice(num2, readOnlySpan.Length));
						num2 += readOnlySpan.Length;
						global::System.ReadOnlySpan<Func<Token, bool>> readOnlySpan2 = new global::System.ReadOnlySpan<Func<Token, bool>>(array2);
						readOnlySpan2.CopyTo(new global::System.Span<Func<Token, bool>>(array3).Slice(num2, readOnlySpan2.Length));
						num2 += readOnlySpan2.Length;
						<skip_waiter>5__9 = new MultiTokenWaiter(array3, false, false);
						goto IL_0650;
					}
					IL_0689:
					<token>5__11 = null;
					goto IL_0690;
					IL_0240:
					if (<func_waiter>5__2.Matched)
					{
						<i>5__12 = 0;
						goto IL_033a;
					}
					<func_waiter>5__2.Check(<token>5__11);
					goto IL_0689;
					IL_03dd:
					if (((global::System.Collections.IEnumerator)<>7__wrap12).MoveNext())
					{
						Token current = <>7__wrap12.Current;
						<>2__current = current;
						<>1__state = 4;
						return true;
					}
					<>m__Finally3();
					<>7__wrap12 = null;
					<skip_waiter>5__9 = new MultiTokenWaiter(AssignPattern("catch_drink_timer", 18000), false, false);
					goto IL_0413;
					IL_033a:
					if (<i>5__12 < <speed_waiters>5__3.Length)
					{
						if (<speed_waiters>5__3[<i>5__12].Check(<token>5__11))
						{
							global::System.Collections.Generic.IEnumerable<Token> enumerable = WriteTimeInst("boost_timer", <speed_timers>5__5[<i>5__12], "boost_amt", (Variant)new RealVariant(<speed_atms>5__4[<i>5__12], false));
							<>7__wrap12 = enumerable.GetEnumerator();
							<>1__state = -4;
							goto IL_02ea;
						}
						goto IL_0328;
					}
					<i>5__12 = 0;
					goto IL_0425;
					IL_0690:
					if (((global::System.Collections.IEnumerator)<>7__wrap9).MoveNext())
					{
						<token>5__11 = <>7__wrap9.Current;
						if (<skip_waiter>5__9 != null)
						{
							if (<skip_waiter>5__9.Check(<token>5__11))
							{
								<skip_waiter>5__9 = null;
							}
							else if (<skip_waiter>5__9.Step == 0)
							{
								playerPatcher.Logger.Error("TenMinuteEnergy: Unexpected Token found when patching the player script. This may be caused by a mod conflict or an unsupported game update. Will continue to attempt the patch, but will likely cause errors.");
								<skip_waiter>5__9 = null;
								<>2__current = <token>5__11;
								<>1__state = 1;
								return true;
							}
							goto IL_0240;
						}
						<>2__current = <token>5__11;
						<>1__state = 2;
						return true;
					}
					<>m__Finally1();
					<>7__wrap9 = null;
					array4 = <speed_waiters>5__3;
					array5 = <catch_waiters>5__6;
					array6 = <bounce_waiters>5__7;
					num3 = 0;
					array7 = (MultiTokenWaiter[])(object)new MultiTokenWaiter[array4.Length + array5.Length + array6.Length];
					readOnlySpan3 = new global::System.ReadOnlySpan<MultiTokenWaiter>(array4);
					readOnlySpan3.CopyTo(new global::System.Span<MultiTokenWaiter>(array7).Slice(num3, readOnlySpan3.Length));
					num3 += readOnlySpan3.Length;
					readOnlySpan4 = new global::System.ReadOnlySpan<MultiTokenWaiter>(array5);
					readOnlySpan4.CopyTo(new global::System.Span<MultiTokenWaiter>(array7).Slice(num3, readOnlySpan4.Length));
					num3 += readOnlySpan4.Length;
					readOnlySpan5 = new global::System.ReadOnlySpan<MultiTokenWaiter>(array6);
					readOnlySpan5.CopyTo(new global::System.Span<MultiTokenWaiter>(array7).Slice(num3, readOnlySpan5.Length));
					num3 += readOnlySpan5.Length;
					array8 = array7;
					for (num2 = 0; num2 < array8.Length; num2++)
					{
						if (!array8[num2].Matched)
						{
							playerPatcher.Logger.Warning("TenMinuteEnergy: Not all patch locations were found in the script file. This may be caused by a mod conflict or an unsupported game update. Not all mod functionality will work, but the game should otherwise work fine.");
							break;
						}
					}
					playerPatcher.Logger.Information("TenMinuteEnergy: player.gdc Patched");
					return false;
					IL_0425:
					if (<i>5__12 < <catch_waiters>5__6.Length)
					{
						if (<catch_waiters>5__6[<i>5__12].Check(<token>5__11))
						{
							global::System.Collections.Generic.IEnumerable<Token> enumerable2 = WriteTimeInst("catch_drink_timer", 18000, "catch_drink_tier", (Variant)new IntVariant((long)(<i>5__12 + 1), false));
							<>7__wrap12 = enumerable2.GetEnumerator();
							<>1__state = -5;
							goto IL_03dd;
						}
						goto IL_0413;
					}
					<i>5__12 = 0;
					goto IL_0662;
					IL_0662:
					if (<i>5__12 < <bounce_waiters>5__7.Length)
					{
						if (<bounce_waiters>5__7[<i>5__12].Check(<token>5__11))
						{
							global::System.Collections.Generic.IEnumerable<Token> enumerable3 = WriteTimeInst("jump_bonus_timer", <bounce_timers>5__8[<i>5__12], "jump_bonus_tier", (Variant)new IntVariant((long)(<i>5__12 + 1), false));
							<>7__wrap12 = enumerable3.GetEnumerator();
							<>1__state = -6;
							goto IL_04d0;
						}
						goto IL_0650;
					}
					goto IL_0689;
					IL_02ea:
					if (((global::System.Collections.IEnumerator)<>7__wrap12).MoveNext())
					{
						Token current2 = <>7__wrap12.Current;
						<>2__current = current2;
						<>1__state = 3;
						return true;
					}
					<>m__Finally2();
					<>7__wrap12 = null;
					<skip_waiter>5__9 = new MultiTokenWaiter(AssignPattern("boost_timer", <speed_timers>5__5[<i>5__12]), false, false);
					goto IL_0328;
					IL_0413:
					num2 = <i>5__12 + 1;
					<i>5__12 = num2;
					goto IL_0425;
					IL_04d0:
					if (((global::System.Collections.IEnumerator)<>7__wrap12).MoveNext())
					{
						Token current3 = <>7__wrap12.Current;
						<>2__current = current3;
						<>1__state = 5;
						return true;
					}
					<>m__Finally4();
					<>7__wrap12 = null;
					<>2__current = (Token)new IdentifierToken("jump_bonus_tier");
					<>1__state = 6;
					return true;
					IL_0328:
					num2 = <i>5__12 + 1;
					<i>5__12 = num2;
					goto IL_033a;
					IL_0650:
					num2 = <i>5__12 + 1;
					<i>5__12 = num2;
					goto IL_0662;
				}
			}
			catch
			{
				//try-fault
				((global::System.IDisposable)this).Dispose();
				throw;
			}
		}

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

		private void <>m__Finally1()
		{
			<>1__state = -1;
			if (<>7__wrap9 != null)
			{
				((global::System.IDisposable)<>7__wrap9).Dispose();
			}
		}

		private void <>m__Finally2()
		{
			<>1__state = -3;
			if (<>7__wrap12 != null)
			{
				((global::System.IDisposable)<>7__wrap12).Dispose();
			}
		}

		private void <>m__Finally3()
		{
			<>1__state = -3;
			if (<>7__wrap12 != null)
			{
				((global::System.IDisposable)<>7__wrap12).Dispose();
			}
		}

		private void <>m__Finally4()
		{
			<>1__state = -3;
			if (<>7__wrap12 != null)
			{
				((global::System.IDisposable)<>7__wrap12).Dispose();
			}
		}

		[DebuggerHidden]
		void global::System.Collections.IEnumerator.Reset()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			throw new NotSupportedException();
		}

		[DebuggerHidden]
		global::System.Collections.Generic.IEnumerator<Token> global::System.Collections.Generic.IEnumerable<Token>.GetEnumerator()
		{
			<Modify>d__6 <Modify>d__;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				<Modify>d__ = this;
			}
			else
			{
				<Modify>d__ = new <Modify>d__6(0)
				{
					<>4__this = <>4__this
				};
			}
			<Modify>d__.tokens = <>3__tokens;
			return <Modify>d__;
		}

		[DebuggerHidden]
		global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
		{
			return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<Token>)this).GetEnumerator();
		}
	}

	[CompilerGenerated]
	private sealed class <WriteTimeInst>d__4 : global::System.Collections.Generic.IEnumerable<Token>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<Token>, global::System.Collections.IEnumerator, global::System.IDisposable
	{
		private int <>1__state;

		private Token <>2__current;

		private int <>l__initialThreadId;

		private string timer;

		public string <>3__timer;

		private string tier;

		public string <>3__tier;

		private Variant value;

		public Variant <>3__value;

		private int time;

		public int <>3__time;

		Token global::System.Collections.Generic.IEnumerator<Token>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

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

		[DebuggerHidden]
		public <WriteTimeInst>d__4(int <>1__state)
		{
			this.<>1__state = <>1__state;
			<>l__initialThreadId = Environment.CurrentManagedThreadId;
		}

		[DebuggerHidden]
		void global::System.IDisposable.Dispose()
		{
		}

		private bool MoveNext()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Expected O, but got Unknown
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Expected O, but got Unknown
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Expected O, but got Unknown
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Expected O, but got Unknown
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = new Token((TokenType)38, (uint?)null);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>2__current = (Token)new IdentifierToken(timer);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>2__current = new Token((TokenType)11, (uint?)null);
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				<>2__current = (Token)new ConstantToken((Variant)new IntVariant(0L, false));
				<>1__state = 4;
				return true;
			case 4:
				<>1__state = -1;
				<>2__current = new Token((TokenType)13, (uint?)null);
				<>1__state = 5;
				return true;
			case 5:
				<>1__state = -1;
				<>2__current = (Token)new IdentifierToken(tier);
				<>1__state = 6;
				return true;
			case 6:
				<>1__state = -1;
				<>2__current = new Token((TokenType)7, (uint?)null);
				<>1__state = 7;
				return true;
			case 7:
				<>1__state = -1;
				<>2__current = (Token)new ConstantToken(value);
				<>1__state = 8;
				return true;
			case 8:
				<>1__state = -1;
				<>2__current = new Token((TokenType)86, (uint?)null);
				<>1__state = 9;
				return true;
			case 9:
				<>1__state = -1;
				<>2__current = (Token)new IdentifierToken(timer);
				<>1__state = 10;
				return true;
			case 10:
				<>1__state = -1;
				<>2__current = new Token((TokenType)24, (uint?)null);
				<>1__state = 11;
				return true;
			case 11:
				<>1__state = -1;
				<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)time, false));
				<>1__state = 12;
				return true;
			case 12:
				<>1__state = -1;
				<>2__current = new Token((TokenType)89, (uint?)3u);
				<>1__state = 13;
				return true;
			case 13:
				<>1__state = -1;
				<>2__current = new Token((TokenType)40, (uint?)null);
				<>1__state = 14;
				return true;
			case 14:
				<>1__state = -1;
				<>2__current = new Token((TokenType)86, (uint?)null);
				<>1__state = 15;
				return true;
			case 15:
				<>1__state = -1;
				<>2__current = (Token)new IdentifierToken(timer);
				<>1__state = 16;
				return true;
			case 16:
				<>1__state = -1;
				<>2__current = new Token((TokenType)23, (uint?)null);
				<>1__state = 17;
				return true;
			case 17:
				<>1__state = -1;
				<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)time, false));
				<>1__state = 18;
				return true;
			case 18:
				<>1__state = -1;
				<>2__current = new Token((TokenType)89, (uint?)3u);
				<>1__state = 19;
				return true;
			case 19:
				<>1__state = -1;
				return false;
			}
		}

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

		[DebuggerHidden]
		void global::System.Collections.IEnumerator.Reset()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			throw new NotSupportedException();
		}

		[DebuggerHidden]
		global::System.Collections.Generic.IEnumerator<Token> global::System.Collections.Generic.IEnumerable<Token>.GetEnumerator()
		{
			<WriteTimeInst>d__4 <WriteTimeInst>d__;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				<WriteTimeInst>d__ = this;
			}
			else
			{
				<WriteTimeInst>d__ = new <WriteTimeInst>d__4(0);
			}
			<WriteTimeInst>d__.timer = <>3__timer;
			<WriteTimeInst>d__.time = <>3__time;
			<WriteTimeInst>d__.tier = <>3__tier;
			<WriteTimeInst>d__.value = <>3__value;
			return <WriteTimeInst>d__;
		}

		[DebuggerHidden]
		global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
		{
			return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<Token>)this).GetEnumerator();
		}
	}

	private readonly ILogger Logger;

	public PlayerPatcher(ILogger logger)
	{
		Logger = logger;
		base..ctor();
	}

	public bool ShouldRun(string path)
	{
		return path == "res://Scenes/Entities/Player/player.gdc";
	}

	private static MultiTokenWaiter MatchWaiter(string caseString)
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		string caseString2 = caseString;
		return new MultiTokenWaiter(new Func<Token, bool>[3]
		{
			delegate(Token t)
			{
				ConstantToken val = (ConstantToken)(object)((t is ConstantToken) ? t : null);
				if (val != null)
				{
					Variant value = val.Value;
					StringVariant val2 = (StringVariant)(object)((value is StringVariant) ? value : null);
					if (val2 != null)
					{
						return val2.Value == caseString2;
					}
				}
				return false;
			},
			(Token t) => t != null && (int)t.Type == 86,
			delegate(Token t)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Invalid comparison between Unknown and I4
				if (t != null && (int)t.Type == 89)
				{
					uint? associatedData = t.AssociatedData;
					if (associatedData.HasValue)
					{
						return associatedData.GetValueOrDefault() == 3;
					}
				}
				return false;
			}
		}, false, false);
	}

	[IteratorStateMachine(typeof(<WriteTimeInst>d__4))]
	private static global::System.Collections.Generic.IEnumerable<Token> WriteTimeInst(string timer, int time, string tier, Variant value)
	{
		yield return new Token((TokenType)38, (uint?)null);
		yield return (Token)new IdentifierToken(timer);
		yield return new Token((TokenType)11, (uint?)null);
		yield return (Token)new ConstantToken((Variant)new IntVariant(0L, false));
		yield return new Token((TokenType)13, (uint?)null);
		yield return (Token)new IdentifierToken(tier);
		yield return new Token((TokenType)7, (uint?)null);
		yield return (Token)new ConstantToken(value);
		yield return new Token((TokenType)86, (uint?)null);
		yield return (Token)new IdentifierToken(timer);
		yield return new Token((TokenType)24, (uint?)null);
		yield return (Token)new ConstantToken((Variant)new IntVariant((long)time, false));
		yield return new Token((TokenType)89, (uint?)3u);
		yield return new Token((TokenType)40, (uint?)null);
		yield return new Token((TokenType)86, (uint?)null);
		yield return (Token)new IdentifierToken(timer);
		yield return new Token((TokenType)23, (uint?)null);
		yield return (Token)new ConstantToken((Variant)new IntVariant((long)time, false));
		yield return new Token((TokenType)89, (uint?)3u);
	}

	private static Func<Token, bool>[] AssignPattern(string var, int value)
	{
		string var2 = var;
		return new Func<Token, bool>[4]
		{
			delegate(Token t)
			{
				IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val3 != null && val3.Name == var2;
			},
			(Token t) => t != null && (int)t.Type == 23,
			delegate(Token t)
			{
				ConstantToken val = (ConstantToken)(object)((t is ConstantToken) ? t : null);
				if (val != null)
				{
					Variant value2 = val.Value;
					IntVariant val2 = (IntVariant)(object)((value2 is IntVariant) ? value2 : null);
					if (val2 != null)
					{
						return val2.Value == value;
					}
				}
				return false;
			},
			delegate(Token t)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Invalid comparison between Unknown and I4
				if (t != null && (int)t.Type == 89)
				{
					uint? associatedData = t.AssociatedData;
					if (associatedData.HasValue)
					{
						return associatedData.GetValueOrDefault() == 3;
					}
				}
				return false;
			}
		};
	}

	[IteratorStateMachine(typeof(<Modify>d__6))]
	public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
	{
		MultiTokenWaiter func_waiter = new MultiTokenWaiter(new Func<Token, bool>[2]
		{
			(Token t) => (int)t.Type == 48,
			delegate(Token t)
			{
				IdentifierToken val = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val != null && val.Name == "_consume_item";
			}
		}, false, false);
		MultiTokenWaiter[] speed_waiters = (MultiTokenWaiter[])(object)new MultiTokenWaiter[2]
		{
			MatchWaiter("speed"),
			MatchWaiter("speed_burst")
		};
		double[] speed_atms = new double[2] { 1.3, 4.0 };
		int[] speed_timers = new int[2] { 18000, 900 };
		MultiTokenWaiter[] catch_waiters = (MultiTokenWaiter[])(object)new MultiTokenWaiter[3]
		{
			MatchWaiter("catch"),
			MatchWaiter("catch_big"),
			MatchWaiter("catch_deluxe")
		};
		MultiTokenWaiter[] bounce_waiters = (MultiTokenWaiter[])(object)new MultiTokenWaiter[2]
		{
			MatchWaiter("bounce"),
			MatchWaiter("bounce_big")
		};
		int[] bounce_timers = new int[2] { 1200, 600 };
		MultiTokenWaiter skip_waiter = null;
		global::System.Collections.Generic.IEnumerator<Token> enumerator = tokens.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Token token = enumerator.Current;
				if (skip_waiter != null)
				{
					if (skip_waiter.Check(token))
					{
						skip_waiter = null;
					}
					else if (skip_waiter.Step == 0)
					{
						Logger.Error("TenMinuteEnergy: Unexpected Token found when patching the player script. This may be caused by a mod conflict or an unsupported game update. Will continue to attempt the patch, but will likely cause errors.");
						skip_waiter = null;
						yield return token;
					}
				}
				else
				{
					yield return token;
				}
				if (func_waiter.Matched)
				{
					int num;
					for (int i = 0; i < speed_waiters.Length; i = num)
					{
						if (speed_waiters[i].Check(token))
						{
							global::System.Collections.Generic.IEnumerable<Token> enumerable = WriteTimeInst("boost_timer", speed_timers[i], "boost_amt", (Variant)new RealVariant(speed_atms[i], false));
							global::System.Collections.Generic.IEnumerator<Token> enumerator2 = enumerable.GetEnumerator();
							try
							{
								while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
								{
									yield return enumerator2.Current;
								}
							}
							finally
							{
								((global::System.IDisposable)enumerator2)?.Dispose();
							}
							skip_waiter = new MultiTokenWaiter(AssignPattern("boost_timer", speed_timers[i]), false, false);
						}
						num = i + 1;
					}
					for (int i = 0; i < catch_waiters.Length; i = num)
					{
						if (catch_waiters[i].Check(token))
						{
							global::System.Collections.Generic.IEnumerable<Token> enumerable2 = WriteTimeInst("catch_drink_timer", 18000, "catch_drink_tier", (Variant)new IntVariant((long)(i + 1), false));
							global::System.Collections.Generic.IEnumerator<Token> enumerator2 = enumerable2.GetEnumerator();
							try
							{
								while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
								{
									yield return enumerator2.Current;
								}
							}
							finally
							{
								((global::System.IDisposable)enumerator2)?.Dispose();
							}
							skip_waiter = new MultiTokenWaiter(AssignPattern("catch_drink_timer", 18000), false, false);
						}
						num = i + 1;
					}
					for (int i = 0; i < bounce_waiters.Length; i = num)
					{
						if (bounce_waiters[i].Check(token))
						{
							global::System.Collections.Generic.IEnumerable<Token> enumerable3 = WriteTimeInst("jump_bonus_timer", bounce_timers[i], "jump_bonus_tier", (Variant)new IntVariant((long)(i + 1), false));
							global::System.Collections.Generic.IEnumerator<Token> enumerator2 = enumerable3.GetEnumerator();
							try
							{
								while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
								{
									yield return enumerator2.Current;
								}
							}
							finally
							{
								((global::System.IDisposable)enumerator2)?.Dispose();
							}
							yield return (Token)new IdentifierToken("jump_bonus_tier");
							yield return new Token((TokenType)23, (uint?)null);
							yield return (Token)new ConstantToken((Variant)new IntVariant((long)(i + 1), false));
							yield return new Token((TokenType)89, (uint?)3u);
							Func<Token, bool>[] array = AssignPattern("jump_bonus_tier", i + 1);
							Func<Token, bool>[] array2 = AssignPattern("jump_bonus_timer", bounce_timers[i]);
							num = 0;
							Func<Token, bool>[] array3 = new Func<Token, bool>[array.Length + array2.Length];
							global::System.ReadOnlySpan<Func<Token, bool>> readOnlySpan = new global::System.ReadOnlySpan<Func<Token, bool>>(array);
							readOnlySpan.CopyTo(new global::System.Span<Func<Token, bool>>(array3).Slice(num, readOnlySpan.Length));
							num += readOnlySpan.Length;
							global::System.ReadOnlySpan<Func<Token, bool>> readOnlySpan2 = new global::System.ReadOnlySpan<Func<Token, bool>>(array2);
							readOnlySpan2.CopyTo(new global::System.Span<Func<Token, bool>>(array3).Slice(num, readOnlySpan2.Length));
							_ = num + readOnlySpan2.Length;
							skip_waiter = new MultiTokenWaiter(array3, false, false);
						}
						num = i + 1;
					}
				}
				else
				{
					func_waiter.Check(token);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
		MultiTokenWaiter[] array4 = speed_waiters;
		MultiTokenWaiter[] array5 = catch_waiters;
		MultiTokenWaiter[] array6 = bounce_waiters;
		int num2 = 0;
		MultiTokenWaiter[] array7 = (MultiTokenWaiter[])(object)new MultiTokenWaiter[array4.Length + array5.Length + array6.Length];
		global::System.ReadOnlySpan<MultiTokenWaiter> readOnlySpan3 = new global::System.ReadOnlySpan<MultiTokenWaiter>(array4);
		readOnlySpan3.CopyTo(new global::System.Span<MultiTokenWaiter>(array7).Slice(num2, readOnlySpan3.Length));
		num2 += readOnlySpan3.Length;
		global::System.ReadOnlySpan<MultiTokenWaiter> readOnlySpan4 = new global::System.ReadOnlySpan<MultiTokenWaiter>(array5);
		readOnlySpan4.CopyTo(new global::System.Span<MultiTokenWaiter>(array7).Slice(num2, readOnlySpan4.Length));
		num2 += readOnlySpan4.Length;
		global::System.ReadOnlySpan<MultiTokenWaiter> readOnlySpan5 = new global::System.ReadOnlySpan<MultiTokenWaiter>(array6);
		readOnlySpan5.CopyTo(new global::System.Span<MultiTokenWaiter>(array7).Slice(num2, readOnlySpan5.Length));
		_ = num2 + readOnlySpan5.Length;
		MultiTokenWaiter[] array8 = array7;
		for (int num = 0; num < array8.Length; num++)
		{
			if (!array8[num].Matched)
			{
				Logger.Warning("TenMinuteEnergy: Not all patch locations were found in the script file. This may be caused by a mod conflict or an unsupported game update. Not all mod functionality will work, but the game should otherwise work fine.");
				break;
			}
		}
		Logger.Information("TenMinuteEnergy: player.gdc Patched");
	}
}