Decompiled source of SprintToggle v1.0.1

GDWeave/mods/SprintToggle/SprintToggle.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.Versioning;
using GDWeave;
using GDWeave.Godot;
using GDWeave.Godot.Variants;
using GDWeave.Modding;

[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("SprintToggle")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+42e50ce9e1904f53811a4eb7f51defedced625ae")]
[assembly: AssemblyProduct("SprintToggle")]
[assembly: AssemblyTitle("SprintToggle")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace SprintToggle;

public class Mod : IMod, global::System.IDisposable
{
	public Mod(IModInterface modInterface)
	{
		modInterface.RegisterScriptMod((IScriptMod)(object)new PlayerPatch());
	}

	public void Dispose()
	{
	}
}
public class PlayerPatch : IScriptMod
{
	[CompilerGenerated]
	private sealed class <Modify>d__2 : 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 path;

		public string <>3__path;

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

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

		public PlayerPatch <>4__this;

		private MultiTokenWaiter <extendsWaiter>5__1;

		private MultiTokenWaiter <mouselookMatch>5__2;

		private TokenConsumer <newlineConsumer>5__3;

		private MultiTokenWaiter <sprintMatch>5__4;

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

		private Token <token>5__6;

		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__2(int <>1__state)
		{
			this.<>1__state = <>1__state;
			<>l__initialThreadId = Environment.CurrentManagedThreadId;
		}

		[DebuggerHidden]
		void global::System.IDisposable.Dispose()
		{
			int num = <>1__state;
			if (num != -3 && (uint)(num - 1) > 25u)
			{
				return;
			}
			try
			{
			}
			finally
			{
				<>m__Finally1();
			}
		}

		private bool MoveNext()
		{
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Expected O, but got Unknown
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Expected O, but got Unknown
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Expected O, but got Unknown
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Expected O, but got Unknown
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Expected O, but got Unknown
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Expected O, but got Unknown
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Expected O, but got Unknown
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Expected O, but got Unknown
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Expected O, but got Unknown
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_062e: Expected O, but got Unknown
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Expected O, but got Unknown
			//IL_0678: Unknown result type (might be due to invalid IL or missing references)
			//IL_0682: Expected O, but got Unknown
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Expected O, but got Unknown
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Expected O, but got Unknown
			//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Expected O, but got Unknown
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Expected O, but got Unknown
			//IL_0728: Unknown result type (might be due to invalid IL or missing references)
			//IL_0732: Expected O, but got Unknown
			//IL_074f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Expected O, but got Unknown
			//IL_077c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Expected O, but got Unknown
			//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Expected O, but got Unknown
			//IL_07d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Expected O, but got Unknown
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0804: Expected O, but got Unknown
			//IL_086b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Expected O, but got Unknown
			//IL_0892: Unknown result type (might be due to invalid IL or missing references)
			//IL_089c: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Expected O, but got Unknown
			try
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<extendsWaiter>5__1 = new MultiTokenWaiter(new Func<Token, bool>[2]
					{
						(Token t) => (int)t.Type == 51,
						(Token t) => (int)t.Type == 89
					}, false, true);
					<mouselookMatch>5__2 = new MultiTokenWaiter(new Func<Token, bool>[8]
					{
						delegate(Token t)
						{
							IdentifierToken val10 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val10 != null && val10.Name == "mouse_look";
						},
						(Token t) => (int)t.Type == 23,
						delegate(Token t)
						{
							IdentifierToken val9 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val9 != null && val9.Name == "Input";
						},
						(Token t) => (int)t.Type == 84,
						delegate(Token t)
						{
							IdentifierToken val8 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val8 != null && val8.Name == "is_action_pressed";
						},
						(Token t) => (int)t.Type == 80,
						delegate(Token t)
						{
							ConstantToken val6 = (ConstantToken)(object)((t is ConstantToken) ? t : null);
							int result2;
							if (val6 != null)
							{
								Variant value2 = val6.Value;
								StringVariant val7 = (StringVariant)(object)((value2 is StringVariant) ? value2 : null);
								if (val7 != null)
								{
									result2 = ((val7.Value == "mouse_look") ? 1 : 0);
									goto IL_002c;
								}
							}
							result2 = 0;
							goto IL_002c;
							IL_002c:
							return (byte)result2 != 0;
						},
						(Token t) => (int)t.Type == 81
					}, false, false);
					<newlineConsumer>5__3 = new TokenConsumer((Func<Token, bool>)((Token t) => (int)t.Type == 89));
					<sprintMatch>5__4 = new MultiTokenWaiter(new Func<Token, bool>[9]
					{
						delegate(Token t)
						{
							IdentifierToken val5 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val5 != null && val5.Name == "sprinting";
						},
						(Token t) => (int)t.Type == 23,
						(Token t) => (int)t.Type == 15,
						delegate(Token t)
						{
							IdentifierToken val4 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val4 != null && val4.Name == "Input";
						},
						(Token t) => (int)t.Type == 84,
						delegate(Token t)
						{
							IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val3 != null && val3.Name == "is_action_pressed";
						},
						(Token t) => (int)t.Type == 80,
						delegate(Token t)
						{
							ConstantToken val = (ConstantToken)(object)((t is ConstantToken) ? t : null);
							int result;
							if (val != null)
							{
								Variant value = val.Value;
								StringVariant val2 = (StringVariant)(object)((value is StringVariant) ? value : null);
								if (val2 != null)
								{
									result = ((val2.Value == "move_sneak") ? 1 : 0);
									goto IL_002c;
								}
							}
							result = 0;
							goto IL_002c;
							IL_002c:
							return (byte)result != 0;
						},
						(Token t) => (int)t.Type == 81
					}, false, false);
					<>s__5 = tokens.GetEnumerator();
					<>1__state = -3;
					break;
				case 1:
					<>1__state = -3;
					<>2__current = new Token((TokenType)59, (uint?)null);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -3;
					<>2__current = (Token)new IdentifierToken("sprint_toggle");
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -3;
					<>2__current = new Token((TokenType)23, (uint?)null);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -3;
					<>2__current = (Token)new ConstantToken((Variant)new BoolVariant(false));
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -3;
					<>2__current = new Token((TokenType)89, (uint?)null);
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -3;
					goto IL_08e1;
				case 7:
					<>1__state = -3;
					<>2__current = new Token((TokenType)89, (uint?)1u);
					<>1__state = 8;
					return true;
				case 8:
					<>1__state = -3;
					<>2__current = new Token((TokenType)38, (uint?)null);
					<>1__state = 9;
					return true;
				case 9:
					<>1__state = -3;
					<>2__current = (Token)new IdentifierToken("Input");
					<>1__state = 10;
					return true;
				case 10:
					<>1__state = -3;
					<>2__current = new Token((TokenType)84, (uint?)null);
					<>1__state = 11;
					return true;
				case 11:
					<>1__state = -3;
					<>2__current = (Token)new IdentifierToken("is_action_just_pressed");
					<>1__state = 12;
					return true;
				case 12:
					<>1__state = -3;
					<>2__current = new Token((TokenType)80, (uint?)null);
					<>1__state = 13;
					return true;
				case 13:
					<>1__state = -3;
					<>2__current = (Token)new ConstantToken((Variant)new StringVariant("move_sprint"));
					<>1__state = 14;
					return true;
				case 14:
					<>1__state = -3;
					<>2__current = new Token((TokenType)81, (uint?)null);
					<>1__state = 15;
					return true;
				case 15:
					<>1__state = -3;
					<>2__current = new Token((TokenType)86, (uint?)null);
					<>1__state = 16;
					return true;
				case 16:
					<>1__state = -3;
					<>2__current = new Token((TokenType)89, (uint?)2u);
					<>1__state = 17;
					return true;
				case 17:
					<>1__state = -3;
					<>2__current = (Token)new IdentifierToken("sprint_toggle");
					<>1__state = 18;
					return true;
				case 18:
					<>1__state = -3;
					<>2__current = new Token((TokenType)23, (uint?)null);
					<>1__state = 19;
					return true;
				case 19:
					<>1__state = -3;
					<>2__current = new Token((TokenType)15, (uint?)null);
					<>1__state = 20;
					return true;
				case 20:
					<>1__state = -3;
					<>2__current = (Token)new IdentifierToken("sprint_toggle");
					<>1__state = 21;
					return true;
				case 21:
					<>1__state = -3;
					<>2__current = new Token((TokenType)89, (uint?)1u);
					<>1__state = 22;
					return true;
				case 22:
					<>1__state = -3;
					goto IL_08e1;
				case 23:
					<>1__state = -3;
					<>2__current = new Token((TokenType)13, (uint?)null);
					<>1__state = 24;
					return true;
				case 24:
					<>1__state = -3;
					<>2__current = (Token)new IdentifierToken("sprint_toggle");
					<>1__state = 25;
					return true;
				case 25:
					<>1__state = -3;
					<newlineConsumer>5__3.SetReady();
					goto IL_08e1;
				case 26:
					{
						<>1__state = -3;
						goto IL_08e1;
					}
					IL_08e1:
					<token>5__6 = null;
					break;
				}
				while (((global::System.Collections.IEnumerator)<>s__5).MoveNext())
				{
					<token>5__6 = <>s__5.Current;
					if (<extendsWaiter>5__1.Check(<token>5__6))
					{
						<>2__current = <token>5__6;
						<>1__state = 1;
						return true;
					}
					if (<newlineConsumer>5__3.Check(<token>5__6))
					{
						continue;
					}
					if (<mouselookMatch>5__2.Check(<token>5__6))
					{
						<>2__current = <token>5__6;
						<>1__state = 7;
						return true;
					}
					if (<sprintMatch>5__4.Check(<token>5__6))
					{
						<>2__current = <token>5__6;
						<>1__state = 23;
						return true;
					}
					<>2__current = <token>5__6;
					<>1__state = 26;
					return true;
				}
				<>m__Finally1();
				<>s__5 = null;
				return false;
			}
			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 (<>s__5 != null)
			{
				((global::System.IDisposable)<>s__5).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__2 <Modify>d__;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				<Modify>d__ = this;
			}
			else
			{
				<Modify>d__ = new <Modify>d__2(0)
				{
					<>4__this = <>4__this
				};
			}
			<Modify>d__.path = <>3__path;
			<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();
		}
	}

	private const string SprintToggle = "sprint_toggle";

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

	[IteratorStateMachine(typeof(<Modify>d__2))]
	public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
	{
		MultiTokenWaiter extendsWaiter = new MultiTokenWaiter(new Func<Token, bool>[2]
		{
			(Token t) => (int)t.Type == 51,
			(Token t) => (int)t.Type == 89
		}, false, true);
		MultiTokenWaiter mouselookMatch = new MultiTokenWaiter(new Func<Token, bool>[8]
		{
			delegate(Token t)
			{
				IdentifierToken val10 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val10 != null && val10.Name == "mouse_look";
			},
			(Token t) => (int)t.Type == 23,
			delegate(Token t)
			{
				IdentifierToken val9 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val9 != null && val9.Name == "Input";
			},
			(Token t) => (int)t.Type == 84,
			delegate(Token t)
			{
				IdentifierToken val8 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val8 != null && val8.Name == "is_action_pressed";
			},
			(Token t) => (int)t.Type == 80,
			delegate(Token t)
			{
				ConstantToken val6 = (ConstantToken)(object)((t is ConstantToken) ? t : null);
				int result2;
				if (val6 != null)
				{
					Variant value2 = val6.Value;
					StringVariant val7 = (StringVariant)(object)((value2 is StringVariant) ? value2 : null);
					if (val7 != null)
					{
						result2 = ((val7.Value == "mouse_look") ? 1 : 0);
						goto IL_002c;
					}
				}
				result2 = 0;
				goto IL_002c;
				IL_002c:
				return (byte)result2 != 0;
			},
			(Token t) => (int)t.Type == 81
		}, false, false);
		TokenConsumer newlineConsumer = new TokenConsumer((Func<Token, bool>)((Token t) => (int)t.Type == 89));
		MultiTokenWaiter sprintMatch = new MultiTokenWaiter(new Func<Token, bool>[9]
		{
			delegate(Token t)
			{
				IdentifierToken val5 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val5 != null && val5.Name == "sprinting";
			},
			(Token t) => (int)t.Type == 23,
			(Token t) => (int)t.Type == 15,
			delegate(Token t)
			{
				IdentifierToken val4 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val4 != null && val4.Name == "Input";
			},
			(Token t) => (int)t.Type == 84,
			delegate(Token t)
			{
				IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val3 != null && val3.Name == "is_action_pressed";
			},
			(Token t) => (int)t.Type == 80,
			delegate(Token t)
			{
				ConstantToken val = (ConstantToken)(object)((t is ConstantToken) ? t : null);
				int result;
				if (val != null)
				{
					Variant value = val.Value;
					StringVariant val2 = (StringVariant)(object)((value is StringVariant) ? value : null);
					if (val2 != null)
					{
						result = ((val2.Value == "move_sneak") ? 1 : 0);
						goto IL_002c;
					}
				}
				result = 0;
				goto IL_002c;
				IL_002c:
				return (byte)result != 0;
			},
			(Token t) => (int)t.Type == 81
		}, false, false);
		global::System.Collections.Generic.IEnumerator<Token> enumerator = tokens.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Token token = enumerator.Current;
				if (extendsWaiter.Check(token))
				{
					yield return token;
					yield return new Token((TokenType)59, (uint?)null);
					yield return (Token)new IdentifierToken("sprint_toggle");
					yield return new Token((TokenType)23, (uint?)null);
					yield return (Token)new ConstantToken((Variant)new BoolVariant(false));
					yield return new Token((TokenType)89, (uint?)null);
				}
				else if (!newlineConsumer.Check(token))
				{
					if (mouselookMatch.Check(token))
					{
						yield return token;
						yield return new Token((TokenType)89, (uint?)1u);
						yield return new Token((TokenType)38, (uint?)null);
						yield return (Token)new IdentifierToken("Input");
						yield return new Token((TokenType)84, (uint?)null);
						yield return (Token)new IdentifierToken("is_action_just_pressed");
						yield return new Token((TokenType)80, (uint?)null);
						yield return (Token)new ConstantToken((Variant)new StringVariant("move_sprint"));
						yield return new Token((TokenType)81, (uint?)null);
						yield return new Token((TokenType)86, (uint?)null);
						yield return new Token((TokenType)89, (uint?)2u);
						yield return (Token)new IdentifierToken("sprint_toggle");
						yield return new Token((TokenType)23, (uint?)null);
						yield return new Token((TokenType)15, (uint?)null);
						yield return (Token)new IdentifierToken("sprint_toggle");
						yield return new Token((TokenType)89, (uint?)1u);
					}
					else if (sprintMatch.Check(token))
					{
						yield return token;
						yield return new Token((TokenType)13, (uint?)null);
						yield return (Token)new IdentifierToken("sprint_toggle");
						newlineConsumer.SetReady();
					}
					else
					{
						yield return token;
					}
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}
}