Decompiled source of ChalkFix v1.0.0

GDWeave/mods/ChalkFix/ChalkFix.dll

Decompiled 2 years 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 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("ChalkFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+4ed109e4f0326fd310b9d109d425c3182652a0f2")]
[assembly: AssemblyProduct("ChalkFix")]
[assembly: AssemblyTitle("ChalkFix")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace ChalkFix;

public class Config
{
}
public class Mod : IMod, global::System.IDisposable
{
	public class ChalkFixScriptMod : 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 List<MultiTokenWaiter> <addAHundredTo>5__2;

			private MultiTokenWaiter <cellAdjustFinder>5__3;

			private TokenConsumer <newlineConsumer>5__4;

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

			private Token <token>5__6;

			private Enumerator<MultiTokenWaiter> <>7__wrap6;

			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 ((uint)(num - -4) > 1u && (uint)(num - 1) > 7u)
				{
					return;
				}
				try
				{
					if (num != -4 && (uint)(num - 7) > 1u)
					{
						return;
					}
					try
					{
					}
					finally
					{
						<>m__Finally2();
					}
				}
				finally
				{
					<>m__Finally1();
				}
			}

			private bool MoveNext()
			{
				//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d6: Expected O, but got Unknown
				//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0403: Expected O, but got Unknown
				//IL_041f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0429: 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_0529: Unknown result type (might be due to invalid IL or missing references)
				//IL_0533: Expected O, but got Unknown
				//IL_052e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0538: Expected O, but got Unknown
				//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0564: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Expected O, but got Unknown
				//IL_0507: Unknown result type (might be due to invalid IL or missing references)
				//IL_0511: Expected O, but got Unknown
				//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b0: Expected O, but got Unknown
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Expected O, but got Unknown
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01de: Expected O, but got Unknown
				//IL_025b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0261: Expected O, but got Unknown
				//IL_0320: Unknown result type (might be due to invalid IL or missing references)
				//IL_032a: Expected O, but got Unknown
				//IL_034a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0354: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						int num = 4;
						List<MultiTokenWaiter> val = new List<MultiTokenWaiter>(num);
						CollectionsMarshal.SetCount<MultiTokenWaiter>(val, num);
						global::System.Span<MultiTokenWaiter> span = CollectionsMarshal.AsSpan<MultiTokenWaiter>(val);
						int num2 = 0;
						span[num2] = new MultiTokenWaiter(new Func<Token, bool>[3]
						{
							delegate(Token t)
							{
								IdentifierToken val11 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val11 != null && val11.Name == "p";
							},
							(Token t) => (int)t.Type == 84,
							delegate(Token t)
							{
								IdentifierToken val10 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val10 != null && val10.Name == "x";
							}
						}, false, false);
						num2++;
						span[num2] = new MultiTokenWaiter(new Func<Token, bool>[3]
						{
							delegate(Token t)
							{
								IdentifierToken val9 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val9 != null && val9.Name == "p2";
							},
							(Token t) => (int)t.Type == 84,
							delegate(Token t)
							{
								IdentifierToken val8 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val8 != null && val8.Name == "x";
							}
						}, false, false);
						num2++;
						span[num2] = new MultiTokenWaiter(new Func<Token, bool>[3]
						{
							delegate(Token t)
							{
								IdentifierToken val7 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val7 != null && val7.Name == "p";
							},
							(Token t) => (int)t.Type == 84,
							delegate(Token t)
							{
								IdentifierToken val6 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val6 != null && val6.Name == "z";
							}
						}, false, false);
						num2++;
						span[num2] = new MultiTokenWaiter(new Func<Token, bool>[3]
						{
							delegate(Token t)
							{
								IdentifierToken val5 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val5 != null && val5.Name == "p2";
							},
							(Token t) => (int)t.Type == 84,
							delegate(Token t)
							{
								IdentifierToken val4 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val4 != null && val4.Name == "z";
							}
						}, false, false);
						num2++;
						<addAHundredTo>5__2 = val;
						<cellAdjustFinder>5__3 = new MultiTokenWaiter(new Func<Token, bool>[5]
						{
							(Token t) => (int)t.Type == 80,
							delegate(Token t)
							{
								IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val3 != null && val3.Name == "pos";
							},
							(Token t) => (int)t.Type == 84,
							delegate(Token t)
							{
								IdentifierToken val2 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
								return val2 != null && val2.Name == "x";
							},
							(Token t) => (int)t.Type == 16
						}, false, false);
						<newlineConsumer>5__4 = new TokenConsumer((Func<Token, bool>)((Token t) => (int)t.Type == 89));
						<>7__wrap4 = tokens.GetEnumerator();
						<>1__state = -3;
						goto IL_0571;
					}
					case 1:
						<>1__state = -3;
						<>2__current = (Token)new IdentifierToken("pos");
						<>1__state = 2;
						return true;
					case 2:
						<>1__state = -3;
						<>2__current = new Token((TokenType)84, (uint?)null);
						<>1__state = 3;
						return true;
					case 3:
						<>1__state = -3;
						<>2__current = (Token)new IdentifierToken("y");
						<>1__state = 4;
						return true;
					case 4:
						<>1__state = -3;
						<>2__current = new Token((TokenType)81, (uint?)null);
						<>1__state = 5;
						return true;
					case 5:
						<>1__state = -3;
						<newlineConsumer>5__4.SetReady();
						goto IL_0477;
					case 6:
						<>1__state = -3;
						if (<newlineConsumer>5__4.Ready)
						{
							<newlineConsumer>5__4.Reset();
						}
						<>7__wrap6 = <addAHundredTo>5__2.GetEnumerator();
						<>1__state = -4;
						goto IL_054b;
					case 7:
						<>1__state = -4;
						<>2__current = (Token)new ConstantToken((Variant)new IntVariant(100L, false));
						<>1__state = 8;
						return true;
					case 8:
						{
							<>1__state = -4;
							goto IL_054b;
						}
						IL_0571:
						if (((global::System.Collections.IEnumerator)<>7__wrap4).MoveNext())
						{
							<token>5__6 = <>7__wrap4.Current;
							if (<cellAdjustFinder>5__3.Check(<token>5__6))
							{
								<>2__current = new Token((TokenType)82, (uint?)null);
								<>1__state = 1;
								return true;
							}
							goto IL_0477;
						}
						<>m__Finally1();
						<>7__wrap4 = null;
						return false;
						IL_054b:
						while (<>7__wrap6.MoveNext())
						{
							if (<>7__wrap6.Current.Check(<token>5__6))
							{
								<>2__current = new Token((TokenType)16, (uint?)null);
								<>1__state = 7;
								return true;
							}
						}
						<>m__Finally2();
						<>7__wrap6 = default(Enumerator<MultiTokenWaiter>);
						<token>5__6 = null;
						goto IL_0571;
						IL_0477:
						if (!<newlineConsumer>5__4.Check(<token>5__6))
						{
							<>2__current = <token>5__6;
							<>1__state = 6;
							return true;
						}
						goto IL_0571;
					}
				}
				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__wrap4 != null)
				{
					((global::System.IDisposable)<>7__wrap4).Dispose();
				}
			}

			private void <>m__Finally2()
			{
				<>1__state = -3;
				((global::System.IDisposable)<>7__wrap6).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/Entities/ChalkCanvas/chalk_canvas.gdc";
		}

		[IteratorStateMachine(typeof(<Modify>d__1))]
		public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
		{
			int num = 4;
			List<MultiTokenWaiter> val = new List<MultiTokenWaiter>(num);
			CollectionsMarshal.SetCount<MultiTokenWaiter>(val, num);
			global::System.Span<MultiTokenWaiter> span = CollectionsMarshal.AsSpan<MultiTokenWaiter>(val);
			int num2 = 0;
			span[num2] = new MultiTokenWaiter(new Func<Token, bool>[3]
			{
				delegate(Token t)
				{
					IdentifierToken val11 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val11 != null && val11.Name == "p";
				},
				(Token t) => (int)t.Type == 84,
				delegate(Token t)
				{
					IdentifierToken val10 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val10 != null && val10.Name == "x";
				}
			}, false, false);
			num2++;
			span[num2] = new MultiTokenWaiter(new Func<Token, bool>[3]
			{
				delegate(Token t)
				{
					IdentifierToken val9 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val9 != null && val9.Name == "p2";
				},
				(Token t) => (int)t.Type == 84,
				delegate(Token t)
				{
					IdentifierToken val8 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val8 != null && val8.Name == "x";
				}
			}, false, false);
			num2++;
			span[num2] = new MultiTokenWaiter(new Func<Token, bool>[3]
			{
				delegate(Token t)
				{
					IdentifierToken val7 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val7 != null && val7.Name == "p";
				},
				(Token t) => (int)t.Type == 84,
				delegate(Token t)
				{
					IdentifierToken val6 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val6 != null && val6.Name == "z";
				}
			}, false, false);
			num2++;
			span[num2] = new MultiTokenWaiter(new Func<Token, bool>[3]
			{
				delegate(Token t)
				{
					IdentifierToken val5 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val5 != null && val5.Name == "p2";
				},
				(Token t) => (int)t.Type == 84,
				delegate(Token t)
				{
					IdentifierToken val4 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val4 != null && val4.Name == "z";
				}
			}, false, false);
			List<MultiTokenWaiter> addAHundredTo = val;
			MultiTokenWaiter cellAdjustFinder = new MultiTokenWaiter(new Func<Token, bool>[5]
			{
				(Token t) => (int)t.Type == 80,
				delegate(Token t)
				{
					IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val3 != null && val3.Name == "pos";
				},
				(Token t) => (int)t.Type == 84,
				delegate(Token t)
				{
					IdentifierToken val2 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val2 != null && val2.Name == "x";
				},
				(Token t) => (int)t.Type == 16
			}, false, false);
			TokenConsumer newlineConsumer = new TokenConsumer((Func<Token, bool>)((Token t) => (int)t.Type == 89));
			global::System.Collections.Generic.IEnumerator<Token> enumerator = tokens.GetEnumerator();
			try
			{
				while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
				{
					Token token = enumerator.Current;
					if (cellAdjustFinder.Check(token))
					{
						yield return new Token((TokenType)82, (uint?)null);
						yield return (Token)new IdentifierToken("pos");
						yield return new Token((TokenType)84, (uint?)null);
						yield return (Token)new IdentifierToken("y");
						yield return new Token((TokenType)81, (uint?)null);
						newlineConsumer.SetReady();
					}
					if (newlineConsumer.Check(token))
					{
						continue;
					}
					yield return token;
					if (newlineConsumer.Ready)
					{
						newlineConsumer.Reset();
					}
					Enumerator<MultiTokenWaiter> enumerator2 = addAHundredTo.GetEnumerator();
					try
					{
						while (enumerator2.MoveNext())
						{
							if (enumerator2.Current.Check(token))
							{
								yield return new Token((TokenType)16, (uint?)null);
								yield return (Token)new ConstantToken((Variant)new IntVariant(100L, false));
							}
						}
					}
					finally
					{
						((global::System.IDisposable)enumerator2).Dispose();
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator)?.Dispose();
			}
		}
	}

	public Config Config;

	public static IModInterface ModInterface;

	public Mod(IModInterface modInterface)
	{
		ModInterface = modInterface;
		modInterface.RegisterScriptMod((IScriptMod)(object)new ChalkFixScriptMod());
		modInterface.Logger.Information("chalk desync fixed! 'v'");
		Config = modInterface.ReadConfig<Config>();
	}

	public void Dispose()
	{
	}
}