Decompiled source of VoiceTrainedSpecies v1.2.1

GDWeave/mods/VoiceTrainedSpecies/VoiceTrainedSpecies.dll

Decompiled 2 weeks 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 System.Text.Json.Serialization;
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("VoiceTrainedSpecies")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+afaa7a5c1e62ef6d06db914f3c77db60892069c7")]
[assembly: AssemblyProduct("VoiceTrainedSpecies")]
[assembly: AssemblyTitle("VoiceTrainedSpecies")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace VoiceTrainedSpecies;

public class Config
{
	[JsonInclude]
	public string Species = "set following to cat/dog";

	[JsonInclude]
	public string BarkSpecies = "dog";

	[JsonInclude]
	public string GrowlSpecies = "dog";

	[JsonInclude]
	public string WhineSpecies = "dog";
}
public class Mod : IMod, global::System.IDisposable
{
	public Config Config;

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

	public void Dispose()
	{
	}
}
public class PlayerPatch : 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;

		public PlayerPatch <>4__this;

		private MultiTokenWaiter <typeMatch>5__2;

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

		private Token <token>5__4;

		private string <barkSpecies>5__5;

		private string <growlSpecies>5__6;

		private string <whineSpecies>5__7;

		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 (num == -3 || (uint)(num - 1) <= 11u)
			{
				try
				{
				}
				finally
				{
					<>m__Finally1();
				}
			}
		}

		private bool MoveNext()
		{
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Expected O, but got Unknown
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Expected O, but got Unknown
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Expected O, but got Unknown
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Expected O, but got Unknown
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Expected O, but got Unknown
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Expected O, but got Unknown
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Expected O, but got Unknown
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Expected O, but got Unknown
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Expected O, but got Unknown
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Expected O, but got Unknown
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			try
			{
				int num = <>1__state;
				PlayerPatch playerPatch = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<typeMatch>5__2 = new MultiTokenWaiter(new Func<Token, bool>[4]
					{
						(Token t) => (int)t.Type == 59,
						delegate(Token t)
						{
							IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
							return val3 != null && val3.Name == "type";
						},
						(Token t) => (int)t.Type == 23,
						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 == 0;
								}
							}
							return false;
						}
					}, false, false);
					<>7__wrap2 = tokens.GetEnumerator();
					<>1__state = -3;
					break;
				case 1:
					<>1__state = -3;
					if (<typeMatch>5__2.Check(<token>5__4))
					{
						<barkSpecies>5__5 = playerPatch._config.BarkSpecies.ToLower();
						<growlSpecies>5__6 = playerPatch._config.GrowlSpecies.ToLower();
						<whineSpecies>5__7 = playerPatch._config.WhineSpecies.ToLower();
						string[] obj = new string[2] { "dog", "cat" };
						if (!Enumerable.Contains<string>((global::System.Collections.Generic.IEnumerable<string>)obj, <barkSpecies>5__5))
						{
							<barkSpecies>5__5 = "dog";
						}
						if (!Enumerable.Contains<string>((global::System.Collections.Generic.IEnumerable<string>)obj, <growlSpecies>5__6))
						{
							<growlSpecies>5__6 = "dog";
						}
						if (!Enumerable.Contains<string>((global::System.Collections.Generic.IEnumerable<string>)obj, <whineSpecies>5__7))
						{
							<whineSpecies>5__7 = "dog";
						}
						<>2__current = new Token((TokenType)89, (uint?)1u);
						<>1__state = 2;
						return true;
					}
					goto IL_0403;
				case 2:
					<>1__state = -3;
					<>2__current = (Token)new IdentifierToken("bark_id");
					<>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 = new Token((TokenType)76, (uint?)null);
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -3;
					<>2__current = (Token)new ConstantToken((Variant)new StringVariant("bark_" + <barkSpecies>5__5));
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -3;
					<>2__current = new Token((TokenType)82, (uint?)null);
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -3;
					<>2__current = (Token)new ConstantToken((Variant)new StringVariant("growl_" + <growlSpecies>5__6));
					<>1__state = 8;
					return true;
				case 8:
					<>1__state = -3;
					<>2__current = new Token((TokenType)82, (uint?)null);
					<>1__state = 9;
					return true;
				case 9:
					<>1__state = -3;
					<>2__current = (Token)new ConstantToken((Variant)new StringVariant("whine_" + <whineSpecies>5__7));
					<>1__state = 10;
					return true;
				case 10:
					<>1__state = -3;
					<>2__current = new Token((TokenType)77, (uint?)null);
					<>1__state = 11;
					return true;
				case 11:
					<>1__state = -3;
					<>2__current = new Token((TokenType)89, (uint?)1u);
					<>1__state = 12;
					return true;
				case 12:
					{
						<>1__state = -3;
						<barkSpecies>5__5 = null;
						<growlSpecies>5__6 = null;
						<whineSpecies>5__7 = null;
						goto IL_0403;
					}
					IL_0403:
					<token>5__4 = null;
					break;
				}
				if (((global::System.Collections.IEnumerator)<>7__wrap2).MoveNext())
				{
					<token>5__4 = <>7__wrap2.Current;
					<>2__current = <token>5__4;
					<>1__state = 1;
					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__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)
				{
					<>4__this = <>4__this
				};
			}
			<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 readonly Config _config;

	public PlayerPatch(Config config)
	{
		_config = config;
		base..ctor();
	}

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

	[IteratorStateMachine(typeof(<Modify>d__3))]
	public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
	{
		MultiTokenWaiter typeMatch = new MultiTokenWaiter(new Func<Token, bool>[4]
		{
			(Token t) => (int)t.Type == 59,
			delegate(Token t)
			{
				IdentifierToken val3 = (IdentifierToken)(object)((t is IdentifierToken) ? t : null);
				return val3 != null && val3.Name == "type";
			},
			(Token t) => (int)t.Type == 23,
			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 == 0;
					}
				}
				return false;
			}
		}, false, false);
		global::System.Collections.Generic.IEnumerator<Token> enumerator = tokens.GetEnumerator();
		try
		{
			while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
			{
				Token token = enumerator.Current;
				yield return token;
				if (typeMatch.Check(token))
				{
					string barkSpecies = _config.BarkSpecies.ToLower();
					string growlSpecies = _config.GrowlSpecies.ToLower();
					string whineSpecies = _config.WhineSpecies.ToLower();
					string[] obj = new string[2] { "dog", "cat" };
					if (!Enumerable.Contains<string>((global::System.Collections.Generic.IEnumerable<string>)obj, barkSpecies))
					{
						barkSpecies = "dog";
					}
					if (!Enumerable.Contains<string>((global::System.Collections.Generic.IEnumerable<string>)obj, growlSpecies))
					{
						growlSpecies = "dog";
					}
					if (!Enumerable.Contains<string>((global::System.Collections.Generic.IEnumerable<string>)obj, whineSpecies))
					{
						whineSpecies = "dog";
					}
					yield return new Token((TokenType)89, (uint?)1u);
					yield return (Token)new IdentifierToken("bark_id");
					yield return new Token((TokenType)23, (uint?)null);
					yield return new Token((TokenType)76, (uint?)null);
					yield return (Token)new ConstantToken((Variant)new StringVariant("bark_" + barkSpecies));
					yield return new Token((TokenType)82, (uint?)null);
					yield return (Token)new ConstantToken((Variant)new StringVariant("growl_" + growlSpecies));
					yield return new Token((TokenType)82, (uint?)null);
					yield return (Token)new ConstantToken((Variant)new StringVariant("whine_" + whineSpecies));
					yield return new Token((TokenType)77, (uint?)null);
					yield return new Token((TokenType)89, (uint?)1u);
				}
			}
		}
		finally
		{
			((global::System.IDisposable)enumerator)?.Dispose();
		}
	}
}