Decompiled source of CommandsEx v2.0.0

GDWeave/mods/CommandsEx/CommandsEx.dll

Decompiled a week 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 CommandsEx.Patches;
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("CommandsEx")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+262de526596bdd4a693e8dbfc221ea4e4448355d")]
[assembly: AssemblyProduct("CommandsEx")]
[assembly: AssemblyTitle("CommandsEx")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace CommandsEx
{
	public class Mod : IMod, global::System.IDisposable
	{
		public static Mod Instance;

		public Mod(IModInterface modInterface)
		{
			Instance = this;
			modInterface.RegisterScriptMod((IScriptMod)(object)new ChatPatch());
		}

		public void Dispose()
		{
		}
	}
}
namespace CommandsEx.Patches
{
	public class ChatPatch : IScriptMod
	{
		[CompilerGenerated]
		private sealed class <Modify>d__1 : 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;

			private MultiTokenWaiter <waiter_chat>5__2;

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

			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__1(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) <= 22u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
			}

			private bool MoveNext()
			{
				//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02de: Expected O, but got Unknown
				//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0304: Expected O, but got Unknown
				//IL_0326: Unknown result type (might be due to invalid IL or missing references)
				//IL_0330: Expected O, but got Unknown
				//IL_034c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0356: Expected O, but got Unknown
				//IL_0378: Unknown result type (might be due to invalid IL or missing references)
				//IL_0382: Expected O, but got Unknown
				//IL_039e: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a8: Expected O, but got Unknown
				//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ad: Expected O, but got Unknown
				//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d9: Expected O, but got Unknown
				//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0405: Expected O, but got Unknown
				//IL_0425: Unknown result type (might be due to invalid IL or missing references)
				//IL_042f: Expected O, but got Unknown
				//IL_044c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0456: Expected O, but got Unknown
				//IL_0479: Unknown result type (might be due to invalid IL or missing references)
				//IL_0483: Expected O, but got Unknown
				//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_04aa: Expected O, but got Unknown
				//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_04af: Expected O, but got Unknown
				//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04dc: Expected O, but got Unknown
				//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0509: Expected O, but got Unknown
				//IL_0526: Unknown result type (might be due to invalid IL or missing references)
				//IL_0530: Expected O, but got Unknown
				//IL_0553: Unknown result type (might be due to invalid IL or missing references)
				//IL_055d: Expected O, but got Unknown
				//IL_057a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0584: Expected O, but got Unknown
				//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b1: Expected O, but got Unknown
				//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05db: Expected O, but got Unknown
				//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0608: Expected O, but got Unknown
				//IL_0625: Unknown result type (might be due to invalid IL or missing references)
				//IL_062f: Expected O, but got Unknown
				//IL_0266: Unknown result type (might be due to invalid IL or missing references)
				//IL_0270: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<waiter_chat>5__2 = new MultiTokenWaiter(new Func<Token, bool>[14]
						{
							(Token t) => (int)t.Type == 38,
							delegate(Token t)
							{
								IdentifierToken val8 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val8 != null && val8.Name == "text";
							},
							(Token t) => (int)t.Type == 84,
							delegate(Token t)
							{
								IdentifierToken val7 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val7 != null && val7.Name == "replace";
							},
							(Token t) => (int)t.Type == 80,
							delegate(Token t)
							{
								ConstantToken val5 = (ConstantToken)(object)((t is ConstantToken) ? t : null);
								if (val5 != null)
								{
									Variant value3 = val5.Value;
									StringVariant val6 = (StringVariant)(object)((value3 is StringVariant) ? value3 : null);
									if (val6 != null)
									{
										return val6.Value == " ";
									}
								}
								return false;
							},
							(Token t) => (int)t.Type == 82,
							delegate(Token t)
							{
								ConstantToken val3 = (ConstantToken)(object)((t is ConstantToken) ? t : null);
								if (val3 != null)
								{
									Variant value2 = val3.Value;
									StringVariant val4 = (StringVariant)(object)((value2 is StringVariant) ? value2 : null);
									if (val4 != null)
									{
										return val4.Value == "";
									}
								}
								return false;
							},
							(Token t) => (int)t.Type == 81,
							(Token t) => (int)t.Type == 7,
							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 == "";
									}
								}
								return false;
							},
							(Token t) => (int)t.Type == 86,
							(Token t) => (int)t.Type == 46,
							(Token t) => (int)t.Type == 89
						}, false, false);
						<>7__wrap2 = tokens.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						<>2__current = new Token((TokenType)38, (uint?)null);
						<>1__state = 2;
						return true;
					case 2:
						<>1__state = -3;
						<>2__current = (Token)new IdentifierToken("text");
						<>1__state = 3;
						return true;
					case 3:
						<>1__state = -3;
						<>2__current = new Token((TokenType)84, (uint?)null);
						<>1__state = 4;
						return true;
					case 4:
						<>1__state = -3;
						<>2__current = (Token)new IdentifierToken("begins_with");
						<>1__state = 5;
						return true;
					case 5:
						<>1__state = -3;
						<>2__current = new Token((TokenType)80, (uint?)null);
						<>1__state = 6;
						return true;
					case 6:
						<>1__state = -3;
						<>2__current = (Token)new ConstantToken((Variant)new StringVariant("/"));
						<>1__state = 7;
						return true;
					case 7:
						<>1__state = -3;
						<>2__current = new Token((TokenType)81, (uint?)null);
						<>1__state = 8;
						return true;
					case 8:
						<>1__state = -3;
						<>2__current = new Token((TokenType)86, (uint?)null);
						<>1__state = 9;
						return true;
					case 9:
						<>1__state = -3;
						<>2__current = new Token((TokenType)89, (uint?)2u);
						<>1__state = 10;
						return true;
					case 10:
						<>1__state = -3;
						<>2__current = (Token)new IdentifierToken("get_node");
						<>1__state = 11;
						return true;
					case 11:
						<>1__state = -3;
						<>2__current = new Token((TokenType)80, (uint?)null);
						<>1__state = 12;
						return true;
					case 12:
						<>1__state = -3;
						<>2__current = (Token)new ConstantToken((Variant)new StringVariant("/root/CommandsEx"));
						<>1__state = 13;
						return true;
					case 13:
						<>1__state = -3;
						<>2__current = new Token((TokenType)81, (uint?)null);
						<>1__state = 14;
						return true;
					case 14:
						<>1__state = -3;
						<>2__current = new Token((TokenType)84, (uint?)null);
						<>1__state = 15;
						return true;
					case 15:
						<>1__state = -3;
						<>2__current = (Token)new IdentifierToken("handle_command");
						<>1__state = 16;
						return true;
					case 16:
						<>1__state = -3;
						<>2__current = new Token((TokenType)80, (uint?)null);
						<>1__state = 17;
						return true;
					case 17:
						<>1__state = -3;
						<>2__current = (Token)new IdentifierToken("text");
						<>1__state = 18;
						return true;
					case 18:
						<>1__state = -3;
						<>2__current = new Token((TokenType)81, (uint?)null);
						<>1__state = 19;
						return true;
					case 19:
						<>1__state = -3;
						<>2__current = new Token((TokenType)89, (uint?)2u);
						<>1__state = 20;
						return true;
					case 20:
						<>1__state = -3;
						<>2__current = new Token((TokenType)46, (uint?)null);
						<>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;
						break;
					case 23:
						<>1__state = -3;
						break;
					}
					if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext())
					{
						Token current = <>7__wrap2.Current;
						if (<waiter_chat>5__2.Check(current))
						{
							<>2__current = current;
							<>1__state = 1;
							return true;
						}
						<>2__current = current;
						<>1__state = 23;
						return true;
					}
					<>m__Finally1();
					<>7__wrap2 = 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 (<>7__wrap2 != null)
				{
					((global::System.IDisposable)<>7__wrap2).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__1 <Modify>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Modify>d__ = this;
				}
				else
				{
					<Modify>d__ = new <Modify>d__1(0);
				}
				<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();
			}
		}

		public bool ShouldRun(string path)
		{
			return path == "res://Scenes/HUD/playerhud.gdc";
		}

		[IteratorStateMachine(typeof(<Modify>d__1))]
		public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
		{
			MultiTokenWaiter waiter_chat = new MultiTokenWaiter(new Func<Token, bool>[14]
			{
				(Token t) => (int)t.Type == 38,
				delegate(Token t)
				{
					IdentifierToken val8 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val8 != null && val8.Name == "text";
				},
				(Token t) => (int)t.Type == 84,
				delegate(Token t)
				{
					IdentifierToken val7 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val7 != null && val7.Name == "replace";
				},
				(Token t) => (int)t.Type == 80,
				delegate(Token t)
				{
					ConstantToken val5 = (ConstantToken)(object)((t is ConstantToken) ? t : null);
					if (val5 != null)
					{
						Variant value3 = val5.Value;
						StringVariant val6 = (StringVariant)(object)((value3 is StringVariant) ? value3 : null);
						if (val6 != null)
						{
							return val6.Value == " ";
						}
					}
					return false;
				},
				(Token t) => (int)t.Type == 82,
				delegate(Token t)
				{
					ConstantToken val3 = (ConstantToken)(object)((t is ConstantToken) ? t : null);
					if (val3 != null)
					{
						Variant value2 = val3.Value;
						StringVariant val4 = (StringVariant)(object)((value2 is StringVariant) ? value2 : null);
						if (val4 != null)
						{
							return val4.Value == "";
						}
					}
					return false;
				},
				(Token t) => (int)t.Type == 81,
				(Token t) => (int)t.Type == 7,
				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 == "";
						}
					}
					return false;
				},
				(Token t) => (int)t.Type == 86,
				(Token t) => (int)t.Type == 46,
				(Token t) => (int)t.Type == 89
			}, false, false);
			global::System.Collections.Generic.IEnumerator<Token> enumerator = tokens.GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
				{
					Token current = enumerator.Current;
					if (waiter_chat.Check(current))
					{
						yield return current;
						yield return new Token((TokenType)38, (uint?)null);
						yield return (Token)new IdentifierToken("text");
						yield return new Token((TokenType)84, (uint?)null);
						yield return (Token)new IdentifierToken("begins_with");
						yield return new Token((TokenType)80, (uint?)null);
						yield return (Token)new ConstantToken((Variant)new StringVariant("/"));
						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("get_node");
						yield return new Token((TokenType)80, (uint?)null);
						yield return (Token)new ConstantToken((Variant)new StringVariant("/root/CommandsEx"));
						yield return new Token((TokenType)81, (uint?)null);
						yield return new Token((TokenType)84, (uint?)null);
						yield return (Token)new IdentifierToken("handle_command");
						yield return new Token((TokenType)80, (uint?)null);
						yield return (Token)new IdentifierToken("text");
						yield return new Token((TokenType)81, (uint?)null);
						yield return new Token((TokenType)89, (uint?)2u);
						yield return new Token((TokenType)46, (uint?)null);
						yield return new Token((TokenType)89, (uint?)1u);
					}
					else
					{
						yield return current;
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
		}
	}
}