Decompiled source of LucysLib v0.1.2

GDWeave/mods/LucysLib/LucysLib.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
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("LucysLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+da04c6201f4d2dfa2d01def8496e1f060eea0b80")]
[assembly: AssemblyProduct("LucysLib")]
[assembly: AssemblyTitle("LucysLib")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace LucysLib;

public class Mod : IMod, global::System.IDisposable
{
	public static IModInterface ModInterface;

	public Mod(IModInterface modInterface)
	{
		modInterface.Logger.Information("Lucy was here :3");
		ModInterface = modInterface;
		modInterface.RegisterScriptMod((IScriptMod)(object)new LucysNetFixes());
	}

	public void Dispose()
	{
	}
}
[RequiredMember]
public record CodeChange
{
	[CompilerGenerated]
	protected virtual global::System.Type EqualityContract
	{
		[CompilerGenerated]
		get
		{
			return typeof(CodeChange);
		}
	}

	[RequiredMember]
	public string name;

	[RequiredMember]
	public Func<Token, bool>[] multitoken_prefix;

	[RequiredMember]
	public Token[] code_to_add;

	[CompilerGenerated]
	public override string ToString()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		StringBuilder val = new StringBuilder();
		val.Append("CodeChange");
		val.Append(" { ");
		if (PrintMembers(val))
		{
			val.Append(' ');
		}
		val.Append('}');
		return ((object)val).ToString();
	}

	[CompilerGenerated]
	protected virtual bool PrintMembers(StringBuilder builder)
	{
		RuntimeHelpers.EnsureSufficientExecutionStack();
		builder.Append("name = ");
		builder.Append((object)name);
		builder.Append(", multitoken_prefix = ");
		builder.Append((object)multitoken_prefix);
		builder.Append(", code_to_add = ");
		builder.Append((object)code_to_add);
		return true;
	}

	[CompilerGenerated]
	public virtual bool Equals(CodeChange? other)
	{
		if ((object)this != other)
		{
			if ((object)other != null && EqualityContract == other.EqualityContract && EqualityComparer<string>.Default.Equals(name, other.name) && EqualityComparer<Func<Token, bool>[]>.Default.Equals(multitoken_prefix, other.multitoken_prefix))
			{
				return EqualityComparer<Token[]>.Default.Equals(code_to_add, other.code_to_add);
			}
			return false;
		}
		return true;
	}

	[CompilerGenerated]
	[SetsRequiredMembers]
	protected CodeChange(CodeChange original)
	{
		name = original.name;
		multitoken_prefix = original.multitoken_prefix;
		code_to_add = original.code_to_add;
	}

	[Obsolete("Constructors of types with required members are not supported in this version of your compiler.", true)]
	[CompilerFeatureRequired("RequiredMembers")]
	public CodeChange()
	{
	}
}
public class LucysNetFixes : IScriptMod
{
	[CompilerGenerated]
	private sealed class <GDWeave-Modding-IScriptMod-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;

		public LucysNetFixes <>4__this;

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

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

		private List<ValueTuple<CodeChange, MultiTokenWaiter>> <pending_changes>5__2;

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

		private Token <token>5__4;

		private Enumerator<ValueTuple<CodeChange, MultiTokenWaiter>> <>7__wrap4;

		private CodeChange <change>5__6;

		private Token[] <>7__wrap6;

		private int <>7__wrap7;

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

		private bool MoveNext()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = <>1__state;
				LucysNetFixes lucysNetFixes = <>4__this;
				bool flag;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<pending_changes>5__2 = Enumerable.ToList<ValueTuple<CodeChange, MultiTokenWaiter>>(Enumerable.Select<CodeChange, ValueTuple<CodeChange, MultiTokenWaiter>>((global::System.Collections.Generic.IEnumerable<CodeChange>)lucysNetFixes.changes, (Func<CodeChange, ValueTuple<CodeChange, MultiTokenWaiter>>)((CodeChange c) => new ValueTuple<CodeChange, MultiTokenWaiter>(c, new MultiTokenWaiter(c.multitoken_prefix, false, false)))));
					<>7__wrap2 = tokens.GetEnumerator();
					<>1__state = -3;
					goto IL_01ef;
				case 1:
					<>1__state = -4;
					<>7__wrap6 = <change>5__6.code_to_add;
					<>7__wrap7 = 0;
					goto IL_0182;
				case 2:
					<>1__state = -4;
					<>7__wrap7++;
					goto IL_0182;
				case 3:
					{
						<>1__state = -3;
						goto IL_01e8;
					}
					IL_0182:
					if (<>7__wrap7 < <>7__wrap6.Length)
					{
						Token val = <>7__wrap6[<>7__wrap7];
						<>2__current = val;
						<>1__state = 2;
						return true;
					}
					<>7__wrap6 = null;
					flag = true;
					goto IL_01b4;
					IL_01ef:
					if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext())
					{
						<token>5__4 = <>7__wrap2.Current;
						flag = false;
						<>7__wrap4 = <pending_changes>5__2.GetEnumerator();
						<>1__state = -4;
						while (<>7__wrap4.MoveNext())
						{
							ValueTuple<CodeChange, MultiTokenWaiter> current = <>7__wrap4.Current;
							<change>5__6 = current.Item1;
							if (current.Item2.Check(<token>5__4))
							{
								Mod.ModInterface.Logger.Information("Adding LucysLib Network mod " + <change>5__6.name);
								<>2__current = <token>5__4;
								<>1__state = 1;
								return true;
							}
							<change>5__6 = null;
						}
						goto IL_01b4;
					}
					<>m__Finally1();
					<>7__wrap2 = null;
					return false;
					IL_01b4:
					<>m__Finally2();
					<>7__wrap4 = default(Enumerator<ValueTuple<CodeChange, MultiTokenWaiter>>);
					if (!flag)
					{
						<>2__current = <token>5__4;
						<>1__state = 3;
						return true;
					}
					goto IL_01e8;
					IL_01e8:
					<token>5__4 = null;
					goto IL_01ef;
				}
			}
			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();
			}
		}

		private void <>m__Finally2()
		{
			<>1__state = -3;
			((global::System.IDisposable)<>7__wrap4).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()
		{
			<GDWeave-Modding-IScriptMod-Modify>d__2 <GDWeave-Modding-IScriptMod-Modify>d__;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				<GDWeave-Modding-IScriptMod-Modify>d__ = this;
			}
			else
			{
				<GDWeave-Modding-IScriptMod-Modify>d__ = new <GDWeave-Modding-IScriptMod-Modify>d__2(0)
				{
					<>4__this = <>4__this
				};
			}
			<GDWeave-Modding-IScriptMod-Modify>d__.tokens = <>3__tokens;
			return <GDWeave-Modding-IScriptMod-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 CodeChange[] changes = new CodeChange[1]
	{
		new CodeChange
		{
			name = "read packet intercept",
			multitoken_prefix = new Func<Token, bool>[7]
			{
				delegate(Token t)
				{
					IdentifierToken val4 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val4 != null && val4.Name == "FLUSH_PACKET_INFORMATION";
				},
				(Token t) => (int)t.Type == 76,
				delegate(Token t)
				{
					IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
					return val3 != null && val3.Name == "PACKET_SENDER";
				},
				(Token t) => (int)t.Type == 77,
				(Token t) => (int)t.Type == 24,
				delegate(Token t)
				{
					ConstantToken val = (ConstantToken)(object)((t is ConstantToken) ? t : null);
					if (val != null)
					{
						Variant value = val.Value;
						IntVariant val2 = (IntVariant)(object)((value is IntVariant) ? value : null);
						if (val2 != null)
						{
							return val2.Value == 1;
						}
					}
					return false;
				},
				(Token t) => (int)t.Type == 89
			},
			code_to_add = (Token[])(object)new Token[17]
			{
				new Token((TokenType)38, (uint?)null),
				new Token((TokenType)87, (uint?)null),
				(Token)new ConstantToken((Variant)new StringVariant("/root/LucysLib")),
				new Token((TokenType)84, (uint?)null),
				(Token)new IdentifierToken("NetManager"),
				new Token((TokenType)84, (uint?)null),
				(Token)new IdentifierToken("process_packet"),
				new Token((TokenType)80, (uint?)null),
				(Token)new IdentifierToken("DATA"),
				new Token((TokenType)82, (uint?)null),
				(Token)new IdentifierToken("PACKET_SENDER"),
				new Token((TokenType)82, (uint?)null),
				(Token)new IdentifierToken("from_host"),
				new Token((TokenType)81, (uint?)null),
				new Token((TokenType)86, (uint?)null),
				new Token((TokenType)46, (uint?)null),
				new Token((TokenType)89, (uint?)2u)
			}
		}
	};

	bool IScriptMod.ShouldRun(string path)
	{
		return path == "res://Scenes/Singletons/SteamNetwork.gdc";
	}

	[IteratorStateMachine(typeof(<GDWeave-Modding-IScriptMod-Modify>d__2))]
	global::System.Collections.Generic.IEnumerable<Token> IScriptMod.Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
	{
		List<ValueTuple<CodeChange, MultiTokenWaiter>> pending_changes = Enumerable.ToList<ValueTuple<CodeChange, MultiTokenWaiter>>(Enumerable.Select<CodeChange, ValueTuple<CodeChange, MultiTokenWaiter>>((global::System.Collections.Generic.IEnumerable<CodeChange>)changes, (Func<CodeChange, ValueTuple<CodeChange, MultiTokenWaiter>>)((CodeChange c) => new ValueTuple<CodeChange, MultiTokenWaiter>(c, new MultiTokenWaiter(c.multitoken_prefix, false, false)))));
		global::System.Collections.Generic.IEnumerator<Token> enumerator = tokens.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Token token = enumerator.Current;
				bool flag = false;
				Enumerator<ValueTuple<CodeChange, MultiTokenWaiter>> enumerator2 = pending_changes.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						ValueTuple<CodeChange, MultiTokenWaiter> current = enumerator2.Current;
						CodeChange change = current.Item1;
						if (current.Item2.Check(token))
						{
							Mod.ModInterface.Logger.Information("Adding LucysLib Network mod " + change.name);
							yield return token;
							Token[] code_to_add = change.code_to_add;
							for (int i = 0; i < code_to_add.Length; i++)
							{
								yield return code_to_add[i];
							}
							flag = true;
							break;
						}
					}
				}
				finally
				{
					((global::System.IDisposable)enumerator2).Dispose();
				}
				if (!flag)
				{
					yield return token;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}
}