Decompiled source of BetterCosmeticDefaulter v0.1.0

GDWeave/mods/Nineball.BetterCosmeticDefaulter/Nineball.BetterCosmeticDefaulter.dll

Decompiled 17 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using GDWeave;
using GDWeave.Godot;
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("Nineball.BetterCosmeticDefaulter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+ffb08f8edd2de9ac1f33910a23ca85771b382bd2")]
[assembly: AssemblyProduct("Nineball.BetterCosmeticDefaulter")]
[assembly: AssemblyTitle("Nineball.BetterCosmeticDefaulter")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Nineball.BetterCosmeticDefaulter;

public class Config
{
}
public class Mod : IMod, global::System.IDisposable
{
	public Config Config;

	public Mod(IModInterface modInterface)
	{
		Config = modInterface.ReadConfig<Config>();
		modInterface.RegisterScriptMod((IScriptMod)(object)new PlayerPatcher(modInterface));
	}

	public void Dispose()
	{
	}
}
public class PlayerPatcher : IScriptMod
{
	[CompilerGenerated]
	private sealed class <Modify>d__3 : 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 FunctionWaiter <beginErrorHandleInjection>5__2;

		private MultiTokenWaiter <endErrorHandleInjection>5__3;

		private MultiTokenWaiter <usernameErrorIndicatorInjection>5__4;

		private bool <ignore>5__5;

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

		private global::System.Collections.Generic.IEnumerator<Token> <>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__3(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 - -5) > 2u && (uint)(num - 1) > 4u)
			{
				return;
			}
			try
			{
				switch (num)
				{
				case -4:
				case 2:
					try
					{
						break;
					}
					finally
					{
						<>m__Finally2();
					}
				case -5:
				case 4:
					try
					{
						break;
					}
					finally
					{
						<>m__Finally3();
					}
				}
			}
			finally
			{
				<>m__Finally1();
			}
		}

		private bool MoveNext()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			try
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<beginErrorHandleInjection>5__2 = new FunctionWaiter("_update_cosmetics", false);
					<endErrorHandleInjection>5__3 = new MultiTokenWaiter(new Func<Token, bool>[8]
					{
						delegate(Token t)
						{
							IdentifierToken val4 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val4 != null && val4.Name == "PlayerData";
						},
						(Token t) => (int)t.Type == 84,
						delegate(Token t)
						{
							IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val3 != null && val3.Name == "FALLBACK_COSM";
						},
						(Token t) => (int)t.Type == 84,
						delegate(Token t)
						{
							IdentifierToken val2 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val2 != null && val2.Name == "duplicate";
						},
						(Token t) => (int)t.Type == 80,
						(Token t) => (int)t.Type == 81,
						(Token t) => (int)t.Type == 89
					}, false, false);
					<usernameErrorIndicatorInjection>5__4 = new MultiTokenWaiter(new Func<Token, bool>[4]
					{
						delegate(Token t)
						{
							IdentifierToken val = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val != null && val.Name == "username";
						},
						(Token t) => (int)t.Type == 23,
						(Token t) => true,
						(Token t) => (int)t.Type == 89
					}, false, false);
					<ignore>5__5 = false;
					<>7__wrap5 = tokens.GetEnumerator();
					<>1__state = -3;
					break;
				case 1:
				{
					<>1__state = -3;
					<ignore>5__5 = true;
					global::System.Collections.Generic.IEnumerable<Token> enumerable2 = Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>((global::System.Collections.Generic.IEnumerable<Token>)new List<Token>(), ScriptTokenizer.Tokenize("var nb_fallback = PlayerData.FALLBACK_COSM.duplicate()", 1u)), ScriptTokenizer.Tokenize("var valid = true", 1u)), ScriptTokenizer.Tokenize("var recovered = false", 1u)), ScriptTokenizer.Tokenize("for key in nb_fallback.keys():", 1u)), ScriptTokenizer.Tokenize("  if !data.keys().has(key):", 2u)), ScriptTokenizer.Tokenize("    valid = false", 3u)), ScriptTokenizer.Tokenize("for key in data.keys():", 1u)), ScriptTokenizer.Tokenize("  var value = data[key]", 2u)), ScriptTokenizer.Tokenize("  if key == \"accessory\":", 2u)), ScriptTokenizer.Tokenize("    var filtered = []", 3u)), ScriptTokenizer.Tokenize("    for c in data[key]:", 3u)), ScriptTokenizer.Tokenize("      if Globals._cosmetic_exists(c):", 4u)), ScriptTokenizer.Tokenize("        filtered.append(c)", 5u)), ScriptTokenizer.Tokenize("      else:", 4u)), ScriptTokenizer.Tokenize("        recovered = true", 5u)), ScriptTokenizer.Tokenize("    data[key] = filtered", 3u)), ScriptTokenizer.Tokenize("  else:", 2u)), ScriptTokenizer.Tokenize("    if !Globals._cosmetic_exists(data[key]):", 3u)), ScriptTokenizer.Tokenize("      data[key] = nb_fallback[key]", 4u)), ScriptTokenizer.Tokenize("      recovered = true", 4u)), ScriptTokenizer.Tokenize("if !valid:", 1u)), ScriptTokenizer.Tokenize("  data = PlayerData.FALLBACK_COSM.duplicate()", 2u));
					<>7__wrap6 = enumerable2.GetEnumerator();
					<>1__state = -4;
					goto IL_040f;
				}
				case 2:
					<>1__state = -4;
					goto IL_040f;
				case 3:
				{
					<>1__state = -3;
					global::System.Collections.Generic.IEnumerable<Token> enumerable = Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>((global::System.Collections.Generic.IEnumerable<Token>)new List<Token>(), ScriptTokenizer.Tokenize("if !valid:", 1u)), ScriptTokenizer.Tokenize("  username += \"**\"", 2u)), ScriptTokenizer.Tokenize("elif recovered:", 1u)), ScriptTokenizer.Tokenize("  username += \"*\"", 2u));
					<>7__wrap6 = enumerable.GetEnumerator();
					<>1__state = -5;
					goto IL_04fc;
				}
				case 4:
					<>1__state = -5;
					goto IL_04fc;
				case 5:
					{
						<>1__state = -3;
						break;
					}
					IL_04fc:
					if (((global::System.Collections.IEnumerator)<>7__wrap6).MoveNext())
					{
						Token current = <>7__wrap6.Current;
						<>2__current = current;
						<>1__state = 4;
						return true;
					}
					<>m__Finally3();
					<>7__wrap6 = null;
					break;
					IL_040f:
					if (((global::System.Collections.IEnumerator)<>7__wrap6).MoveNext())
					{
						Token current2 = <>7__wrap6.Current;
						<>2__current = current2;
						<>1__state = 2;
						return true;
					}
					<>m__Finally2();
					<>7__wrap6 = null;
					break;
				}
				while (((global::System.Collections.IEnumerator)<>7__wrap5).MoveNext())
				{
					Token current3 = <>7__wrap5.Current;
					if (<beginErrorHandleInjection>5__2.Check(current3))
					{
						<>2__current = current3;
						<>1__state = 1;
						return true;
					}
					if (<endErrorHandleInjection>5__3.Check(current3))
					{
						<ignore>5__5 = false;
						continue;
					}
					if (<usernameErrorIndicatorInjection>5__4.Check(current3))
					{
						<>2__current = current3;
						<>1__state = 3;
						return true;
					}
					if (<ignore>5__5)
					{
						continue;
					}
					<>2__current = current3;
					<>1__state = 5;
					return true;
				}
				<>m__Finally1();
				<>7__wrap5 = 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__wrap5 != null)
			{
				((global::System.IDisposable)<>7__wrap5).Dispose();
			}
		}

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

		private void <>m__Finally3()
		{
			<>1__state = -3;
			if (<>7__wrap6 != null)
			{
				((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__3 <Modify>d__;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				<Modify>d__ = this;
			}
			else
			{
				<Modify>d__ = new <Modify>d__3(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();
		}
	}

	private IModInterface modInterface;

	public bool ShouldRun(string path)
	{
		if (!(path == "res://Scenes/Entities/Player/player.gdc"))
		{
			return path == "res://mods/bizzlemip.antilag/player2.gdc";
		}
		return true;
	}

	public PlayerPatcher(IModInterface modInterface)
	{
		this.modInterface = modInterface;
	}

	[IteratorStateMachine(typeof(<Modify>d__3))]
	public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
	{
		FunctionWaiter beginErrorHandleInjection = new FunctionWaiter("_update_cosmetics", false);
		MultiTokenWaiter endErrorHandleInjection = new MultiTokenWaiter(new Func<Token, bool>[8]
		{
			delegate(Token t)
			{
				IdentifierToken val4 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val4 != null && val4.Name == "PlayerData";
			},
			(Token t) => (int)t.Type == 84,
			delegate(Token t)
			{
				IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val3 != null && val3.Name == "FALLBACK_COSM";
			},
			(Token t) => (int)t.Type == 84,
			delegate(Token t)
			{
				IdentifierToken val2 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val2 != null && val2.Name == "duplicate";
			},
			(Token t) => (int)t.Type == 80,
			(Token t) => (int)t.Type == 81,
			(Token t) => (int)t.Type == 89
		}, false, false);
		MultiTokenWaiter usernameErrorIndicatorInjection = new MultiTokenWaiter(new Func<Token, bool>[4]
		{
			delegate(Token t)
			{
				IdentifierToken val = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val != null && val.Name == "username";
			},
			(Token t) => (int)t.Type == 23,
			(Token t) => true,
			(Token t) => (int)t.Type == 89
		}, false, false);
		bool ignore = false;
		global::System.Collections.Generic.IEnumerator<Token> enumerator = tokens.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Token current = enumerator.Current;
				if (beginErrorHandleInjection.Check(current))
				{
					yield return current;
					ignore = true;
					global::System.Collections.Generic.IEnumerable<Token> enumerable = Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>((global::System.Collections.Generic.IEnumerable<Token>)new List<Token>(), ScriptTokenizer.Tokenize("var nb_fallback = PlayerData.FALLBACK_COSM.duplicate()", 1u)), ScriptTokenizer.Tokenize("var valid = true", 1u)), ScriptTokenizer.Tokenize("var recovered = false", 1u)), ScriptTokenizer.Tokenize("for key in nb_fallback.keys():", 1u)), ScriptTokenizer.Tokenize("  if !data.keys().has(key):", 2u)), ScriptTokenizer.Tokenize("    valid = false", 3u)), ScriptTokenizer.Tokenize("for key in data.keys():", 1u)), ScriptTokenizer.Tokenize("  var value = data[key]", 2u)), ScriptTokenizer.Tokenize("  if key == \"accessory\":", 2u)), ScriptTokenizer.Tokenize("    var filtered = []", 3u)), ScriptTokenizer.Tokenize("    for c in data[key]:", 3u)), ScriptTokenizer.Tokenize("      if Globals._cosmetic_exists(c):", 4u)), ScriptTokenizer.Tokenize("        filtered.append(c)", 5u)), ScriptTokenizer.Tokenize("      else:", 4u)), ScriptTokenizer.Tokenize("        recovered = true", 5u)), ScriptTokenizer.Tokenize("    data[key] = filtered", 3u)), ScriptTokenizer.Tokenize("  else:", 2u)), ScriptTokenizer.Tokenize("    if !Globals._cosmetic_exists(data[key]):", 3u)), ScriptTokenizer.Tokenize("      data[key] = nb_fallback[key]", 4u)), ScriptTokenizer.Tokenize("      recovered = true", 4u)), ScriptTokenizer.Tokenize("if !valid:", 1u)), ScriptTokenizer.Tokenize("  data = PlayerData.FALLBACK_COSM.duplicate()", 2u));
					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();
					}
				}
				else if (endErrorHandleInjection.Check(current))
				{
					ignore = false;
				}
				else if (usernameErrorIndicatorInjection.Check(current))
				{
					yield return current;
					global::System.Collections.Generic.IEnumerable<Token> enumerable2 = Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>(Enumerable.Concat<Token>((global::System.Collections.Generic.IEnumerable<Token>)new List<Token>(), ScriptTokenizer.Tokenize("if !valid:", 1u)), ScriptTokenizer.Tokenize("  username += \"**\"", 2u)), ScriptTokenizer.Tokenize("elif recovered:", 1u)), ScriptTokenizer.Tokenize("  username += \"*\"", 2u));
					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();
					}
				}
				else if (!ignore)
				{
					yield return current;
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}
}