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;
using Serilog;
[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("Heresy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+1767338f79658286228d66299008f00ac80174b2")]
[assembly: AssemblyProduct("Heresy")]
[assembly: AssemblyTitle("Heresy")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Heresy;
public class Config
{
[JsonInclude]
public bool WaterToWine;
}
public class HeresyMod : NiceScriptMod
{
public HeresyMod(Config config, ILogger logger)
{
ILogger logger2 = logger;
Config config2 = config;
Dictionary<string, OnMatch> obj = new Dictionary<string, OnMatch>();
obj.Add("res://Scenes/Map/Props/water_main.gdc", (OnMatch)delegate(ref TokenCursor cur)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
if (!cur.TryMatchAhead((IWaiter)new FunctionWaiter("_ready", false)))
{
logger2.Warning("[[Heresy] Failed to match _ready for water_main.gd");
}
else
{
cur.Patch((global::System.Collections.Generic.IEnumerable<object>)ScriptTokenizer.Tokenize("$StaticBody/CollisionShape.pause_mode = PAUSE_MODE_PROCESS\n$StaticBody/CollisionShape.translation.y -= 0.5\n$StaticBody.set_collision_layer_bit(0, true)", 1u));
}
});
obj.Add("res://Scenes/HUD/Shop/ShopButtons/button_item.gdc", (OnMatch)delegate(ref TokenCursor cur)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
if (config2.WaterToWine)
{
if (!cur.TryMatchAhead((IWaiter)new FunctionWaiter("_custom_purchase", false)))
{
logger2.Warning("[Heresy] Failed to match _custom_purchase for button_item.gd");
}
else
{
cur.Patch((global::System.Collections.Generic.IEnumerable<object>)ScriptTokenizer.Tokenize("if item_id == \"potion_revert\":\n item_id = \"potion_wine\"\n slot_name = Globals.item_data[\"potion_wine\"][\"file\"].item_name", 1u));
}
}
});
obj.Add("res://Scenes/Map/Zones/death_transport_zone.gdc", (OnMatch)delegate(ref TokenCursor cur)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
if (!cur.TryMatchAhead((IWaiter)new FunctionWaiter("_ready", false)))
{
logger2.Warning("[Heresy] Failed to match _ready for death_transport_zone.gd");
}
else
{
cur.Patch((global::System.Collections.Generic.IEnumerable<object>)ScriptTokenizer.Tokenize("set_collision_layer_bit(0, true)\nset_collision_layer_mask(0, true)\nadd_to_group(\"water\")", 1u));
}
});
base..ctor(obj);
}
}
public class Mod : IMod, global::System.IDisposable
{
public Config Config;
public Mod(IModInterface modInterface)
{
Config = modInterface.ReadConfig<Config>();
modInterface.RegisterScriptMod((IScriptMod)(object)new HeresyMod(Config, modInterface.Logger));
}
public void Dispose()
{
}
}
public class NoMatchException : global::System.Exception
{
public NoMatchException()
{
}
public NoMatchException(string? message)
: base(message)
{
}
public NoMatchException(string? message, global::System.Exception? innerException)
: base(message, innerException)
{
}
}
public class TokenCursor
{
[CompilerGenerated]
private sealed class <DisplayStrings>d__12 : global::System.Collections.Generic.IEnumerable<string>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<string>, global::System.Collections.IEnumerator, global::System.IDisposable
{
private int <>1__state;
private string <>2__current;
private int <>l__initialThreadId;
public TokenCursor <>4__this;
private Enumerator<Token> <>7__wrap1;
private Token <tok>5__3;
private int <i>5__4;
string global::System.Collections.Generic.IEnumerator<string>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object global::System.Collections.IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DisplayStrings>d__12(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) <= 100u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
}
private bool MoveNext()
{
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_13ce: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_04c3: Expected I4, but got Unknown
try
{
int num = <>1__state;
TokenCursor tokenCursor = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>7__wrap1 = tokenCursor.List.GetEnumerator();
<>1__state = -3;
goto IL_13b2;
case 1:
<>1__state = -3;
goto IL_13ab;
case 2:
<>1__state = -3;
goto IL_13ab;
case 3:
<>1__state = -3;
goto IL_13ab;
case 4:
<>1__state = -3;
goto IL_13ab;
case 5:
<>1__state = -3;
goto IL_13ab;
case 6:
<>1__state = -3;
goto IL_13ab;
case 7:
<>1__state = -3;
goto IL_13ab;
case 8:
<>1__state = -3;
<>2__current = "";
<>1__state = 9;
return true;
case 9:
<>1__state = -3;
goto IL_13ab;
case 10:
<>1__state = -3;
goto IL_13ab;
case 11:
<>1__state = -3;
goto IL_13ab;
case 12:
<>1__state = -3;
goto IL_13ab;
case 13:
<>1__state = -3;
goto IL_13ab;
case 14:
<>1__state = -3;
goto IL_13ab;
case 15:
<>1__state = -3;
goto IL_13ab;
case 16:
<>1__state = -3;
goto IL_13ab;
case 17:
<>1__state = -3;
goto IL_13ab;
case 18:
<>1__state = -3;
goto IL_13ab;
case 19:
<>1__state = -3;
goto IL_13ab;
case 20:
<>1__state = -3;
goto IL_13ab;
case 21:
<>1__state = -3;
goto IL_13ab;
case 22:
<>1__state = -3;
goto IL_13ab;
case 23:
<>1__state = -3;
goto IL_13ab;
case 24:
<>1__state = -3;
goto IL_13ab;
case 25:
<>1__state = -3;
goto IL_13ab;
case 26:
<>1__state = -3;
goto IL_13ab;
case 27:
<>1__state = -3;
goto IL_13ab;
case 28:
<>1__state = -3;
goto IL_13ab;
case 29:
<>1__state = -3;
goto IL_13ab;
case 30:
<>1__state = -3;
goto IL_13ab;
case 31:
<>1__state = -3;
goto IL_13ab;
case 32:
<>1__state = -3;
goto IL_13ab;
case 33:
<>1__state = -3;
goto IL_13ab;
case 34:
<>1__state = -3;
goto IL_13ab;
case 35:
<>1__state = -3;
goto IL_13ab;
case 36:
<>1__state = -3;
goto IL_13ab;
case 37:
<>1__state = -3;
goto IL_13ab;
case 38:
<>1__state = -3;
goto IL_13ab;
case 39:
<>1__state = -3;
goto IL_13ab;
case 40:
<>1__state = -3;
goto IL_13ab;
case 41:
<>1__state = -3;
goto IL_13ab;
case 42:
<>1__state = -3;
goto IL_13ab;
case 43:
<>1__state = -3;
goto IL_13ab;
case 44:
<>1__state = -3;
goto IL_13ab;
case 45:
<>1__state = -3;
goto IL_13ab;
case 46:
<>1__state = -3;
goto IL_13ab;
case 47:
<>1__state = -3;
goto IL_13ab;
case 48:
<>1__state = -3;
goto IL_13ab;
case 49:
<>1__state = -3;
goto IL_13ab;
case 50:
<>1__state = -3;
goto IL_13ab;
case 51:
<>1__state = -3;
goto IL_13ab;
case 52:
<>1__state = -3;
goto IL_13ab;
case 53:
<>1__state = -3;
goto IL_13ab;
case 54:
<>1__state = -3;
goto IL_13ab;
case 55:
<>1__state = -3;
goto IL_13ab;
case 56:
<>1__state = -3;
goto IL_13ab;
case 57:
<>1__state = -3;
goto IL_13ab;
case 58:
<>1__state = -3;
goto IL_13ab;
case 59:
<>1__state = -3;
goto IL_13ab;
case 60:
<>1__state = -3;
goto IL_13ab;
case 61:
<>1__state = -3;
goto IL_13ab;
case 62:
<>1__state = -3;
goto IL_13ab;
case 63:
<>1__state = -3;
goto IL_13ab;
case 64:
<>1__state = -3;
goto IL_13ab;
case 65:
<>1__state = -3;
goto IL_13ab;
case 66:
<>1__state = -3;
goto IL_13ab;
case 67:
<>1__state = -3;
goto IL_13ab;
case 68:
<>1__state = -3;
goto IL_13ab;
case 69:
<>1__state = -3;
goto IL_13ab;
case 70:
<>1__state = -3;
goto IL_13ab;
case 71:
<>1__state = -3;
goto IL_13ab;
case 72:
<>1__state = -3;
goto IL_13ab;
case 73:
<>1__state = -3;
goto IL_13ab;
case 74:
<>1__state = -3;
goto IL_13ab;
case 75:
<>1__state = -3;
goto IL_13ab;
case 76:
<>1__state = -3;
goto IL_13ab;
case 77:
<>1__state = -3;
goto IL_13ab;
case 78:
<>1__state = -3;
goto IL_13ab;
case 79:
<>1__state = -3;
goto IL_13ab;
case 80:
<>1__state = -3;
goto IL_13ab;
case 81:
<>1__state = -3;
goto IL_13ab;
case 82:
<>1__state = -3;
goto IL_13ab;
case 83:
<>1__state = -3;
goto IL_13ab;
case 84:
<>1__state = -3;
goto IL_13ab;
case 85:
<>1__state = -3;
goto IL_13ab;
case 86:
<>1__state = -3;
goto IL_13ab;
case 87:
<>1__state = -3;
goto IL_13ab;
case 88:
<>1__state = -3;
goto IL_13ab;
case 89:
<>1__state = -3;
goto IL_13ab;
case 90:
<>1__state = -3;
goto IL_13ab;
case 91:
<>1__state = -3;
goto IL_13ab;
case 92:
<>1__state = -3;
<i>5__4 = 0;
goto IL_126b;
case 93:
<>1__state = -3;
<i>5__4++;
goto IL_126b;
case 94:
<>1__state = -3;
goto IL_13ab;
case 95:
<>1__state = -3;
goto IL_13ab;
case 96:
<>1__state = -3;
goto IL_13ab;
case 97:
<>1__state = -3;
goto IL_13ab;
case 98:
<>1__state = -3;
goto IL_13ab;
case 99:
<>1__state = -3;
goto IL_13ab;
case 100:
<>1__state = -3;
goto IL_13ab;
case 101:
{
<>1__state = -3;
goto IL_13ab;
}
IL_126b:
if (<i>5__4 < <tok>5__3.AssociatedData.GetValueOrDefault())
{
<>2__current = "\t";
<>1__state = 93;
return true;
}
goto IL_13ab;
IL_13b2:
if (<>7__wrap1.MoveNext())
{
<tok>5__3 = <>7__wrap1.Current;
Token obj = <tok>5__3;
ConstantToken val = (ConstantToken)(object)((obj is ConstantToken) ? obj : null);
if (val != null)
{
if (val.Value is NilVariant)
{
<>2__current = "null";
<>1__state = 1;
return true;
}
Variant value = val.Value;
BoolVariant val2 = (BoolVariant)(object)((value is BoolVariant) ? value : null);
if (val2 != null)
{
<>2__current = (val2.Value ? "true" : "false");
<>1__state = 2;
return true;
}
Variant value2 = val.Value;
StringVariant val3 = (StringVariant)(object)((value2 is StringVariant) ? value2 : null);
if (val3 != null)
{
<>2__current = "\"" + val3.Value + "\"";
<>1__state = 3;
return true;
}
<>2__current = val.Value.GetValue().ToString();
<>1__state = 4;
return true;
}
Token obj2 = <tok>5__3;
IdentifierToken val4 = (IdentifierToken)(object)((obj2 is IdentifierToken) ? obj2 : null);
if (val4 != null)
{
<>2__current = val4.Name;
<>1__state = 5;
return true;
}
TokenType type = <tok>5__3.Type;
switch ((int)type)
{
case 3:
<>2__current = "self";
<>1__state = 6;
return true;
case 4:
<>2__current = global::System.Enum.GetName<VariantType>((VariantType)<tok>5__3.AssociatedData.GetValueOrDefault()) ?? "<type>";
<>1__state = 7;
return true;
case 5:
<>2__current = global::System.Enum.GetName<BuiltinFunction>((BuiltinFunction)<tok>5__3.AssociatedData.GetValueOrDefault()) ?? "<fn>";
<>1__state = 8;
return true;
case 6:
<>2__current = "in";
<>1__state = 10;
return true;
case 7:
<>2__current = "==";
<>1__state = 11;
return true;
case 8:
<>2__current = "!=";
<>1__state = 12;
return true;
case 9:
<>2__current = "<";
<>1__state = 13;
return true;
case 10:
<>2__current = "<=";
<>1__state = 14;
return true;
case 11:
<>2__current = ">";
<>1__state = 15;
return true;
case 12:
<>2__current = ">=";
<>1__state = 16;
return true;
case 13:
<>2__current = "&&";
<>1__state = 17;
return true;
case 14:
<>2__current = "||";
<>1__state = 18;
return true;
case 15:
<>2__current = "!";
<>1__state = 19;
return true;
case 16:
<>2__current = "+";
<>1__state = 20;
return true;
case 17:
<>2__current = "-";
<>1__state = 21;
return true;
case 18:
<>2__current = "*";
<>1__state = 22;
return true;
case 19:
<>2__current = "/";
<>1__state = 23;
return true;
case 20:
<>2__current = "%";
<>1__state = 24;
return true;
case 21:
<>2__current = "<<";
<>1__state = 25;
return true;
case 22:
<>2__current = ">>";
<>1__state = 26;
return true;
case 23:
<>2__current = "=";
<>1__state = 27;
return true;
case 24:
<>2__current = "+=";
<>1__state = 28;
return true;
case 25:
<>2__current = "-=";
<>1__state = 29;
return true;
case 26:
<>2__current = "*=";
<>1__state = 30;
return true;
case 27:
<>2__current = "/=";
<>1__state = 31;
return true;
case 28:
<>2__current = "%=";
<>1__state = 32;
return true;
case 29:
<>2__current = "<<=";
<>1__state = 33;
return true;
case 30:
<>2__current = ">>=";
<>1__state = 34;
return true;
case 31:
<>2__current = "&=";
<>1__state = 35;
return true;
case 32:
<>2__current = "|=";
<>1__state = 36;
return true;
case 33:
<>2__current = "^=";
<>1__state = 37;
return true;
case 34:
<>2__current = "&";
<>1__state = 38;
return true;
case 35:
<>2__current = "|";
<>1__state = 39;
return true;
case 36:
<>2__current = "^";
<>1__state = 40;
return true;
case 37:
<>2__current = "~";
<>1__state = 41;
return true;
case 38:
<>2__current = "if";
<>1__state = 42;
return true;
case 39:
<>2__current = "elif";
<>1__state = 43;
return true;
case 40:
<>2__current = "else";
<>1__state = 44;
return true;
case 41:
<>2__current = "for";
<>1__state = 45;
return true;
case 42:
<>2__current = "while";
<>1__state = 46;
return true;
case 43:
<>2__current = "break";
<>1__state = 47;
return true;
case 44:
<>2__current = "continue";
<>1__state = 48;
return true;
case 45:
<>2__current = "pass";
<>1__state = 49;
return true;
case 46:
<>2__current = "return";
<>1__state = 50;
return true;
case 47:
<>2__current = "match";
<>1__state = 51;
return true;
case 48:
<>2__current = "func";
<>1__state = 52;
return true;
case 49:
<>2__current = "class";
<>1__state = 53;
return true;
case 50:
<>2__current = "<class name>";
<>1__state = 54;
return true;
case 51:
<>2__current = "extends";
<>1__state = 55;
return true;
case 52:
<>2__current = "is";
<>1__state = 56;
return true;
case 53:
<>2__current = "@onready";
<>1__state = 57;
return true;
case 54:
<>2__current = "@tool";
<>1__state = 58;
return true;
case 55:
<>2__current = "static";
<>1__state = 59;
return true;
case 56:
<>2__current = "@export";
<>1__state = 60;
return true;
case 57:
<>2__current = "setget";
<>1__state = 61;
return true;
case 58:
<>2__current = "const";
<>1__state = 62;
return true;
case 59:
<>2__current = "var";
<>1__state = 63;
return true;
case 60:
<>2__current = "as";
<>1__state = 64;
return true;
case 61:
<>2__current = "void";
<>1__state = 65;
return true;
case 62:
<>2__current = "enum";
<>1__state = 66;
return true;
case 63:
<>2__current = "preload";
<>1__state = 67;
return true;
case 64:
<>2__current = "assert";
<>1__state = 68;
return true;
case 65:
<>2__current = "yield";
<>1__state = 69;
return true;
case 66:
<>2__current = "signal";
<>1__state = 70;
return true;
case 67:
<>2__current = "breakpoint";
<>1__state = 71;
return true;
case 68:
<>2__current = "remote";
<>1__state = 72;
return true;
case 69:
<>2__current = "sync";
<>1__state = 73;
return true;
case 70:
<>2__current = "master";
<>1__state = 74;
return true;
case 71:
case 72:
<>2__current = "puppet";
<>1__state = 75;
return true;
case 73:
<>2__current = "remotesync";
<>1__state = 76;
return true;
case 74:
<>2__current = "mastersync";
<>1__state = 77;
return true;
case 75:
<>2__current = "puppetsync";
<>1__state = 78;
return true;
case 76:
<>2__current = "[";
<>1__state = 79;
return true;
case 77:
<>2__current = "]";
<>1__state = 80;
return true;
case 78:
<>2__current = "{";
<>1__state = 81;
return true;
case 79:
<>2__current = "}";
<>1__state = 82;
return true;
case 80:
<>2__current = "(";
<>1__state = 83;
return true;
case 81:
<>2__current = ")";
<>1__state = 84;
return true;
case 82:
<>2__current = ",";
<>1__state = 85;
return true;
case 83:
<>2__current = ":";
<>1__state = 86;
return true;
case 84:
<>2__current = ".";
<>1__state = 87;
return true;
case 85:
<>2__current = "?";
<>1__state = 88;
return true;
case 86:
<>2__current = ":";
<>1__state = 89;
return true;
case 87:
<>2__current = "$";
<>1__state = 90;
return true;
case 88:
<>2__current = "->";
<>1__state = 91;
return true;
case 89:
<>2__current = "\n";
<>1__state = 92;
return true;
case 90:
<>2__current = "PI";
<>1__state = 94;
return true;
case 91:
<>2__current = "TAU";
<>1__state = 95;
return true;
case 92:
<>2__current = "*";
<>1__state = 96;
return true;
case 93:
<>2__current = "INF";
<>1__state = 97;
return true;
case 94:
<>2__current = "NAN";
<>1__state = 98;
return true;
case 95:
<>2__current = "Error";
<>1__state = 99;
return true;
case 96:
<>2__current = "";
<>1__state = 100;
return true;
case 97:
<>2__current = "";
<>1__state = 101;
return true;
}
goto IL_13ab;
}
<>m__Finally1();
<>7__wrap1 = default(Enumerator<Token>);
return false;
IL_13ab:
<tok>5__3 = null;
goto IL_13b2;
}
}
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;
((global::System.IDisposable)<>7__wrap1).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<string> global::System.Collections.Generic.IEnumerable<string>.GetEnumerator()
{
<DisplayStrings>d__12 result;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
result = this;
}
else
{
result = new <DisplayStrings>d__12(0)
{
<>4__this = <>4__this
};
}
return result;
}
[DebuggerHidden]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return (global::System.Collections.IEnumerator)((global::System.Collections.Generic.IEnumerable<string>)this).GetEnumerator();
}
}
[CompilerGenerated]
private sealed class <ToTokens>d__7 : 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 object tokenlike;
public object <>3__tokenlike;
private NiceScriptMod.Wrapped <wrap>5__2;
private object?[] <>7__wrap2;
private int <>7__wrap3;
private global::System.Collections.Generic.IEnumerator<Token> <>7__wrap4;
private NiceScriptMod.Delimited <delim>5__6;
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 <ToTokens>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void global::System.IDisposable.Dispose()
{
switch (<>1__state)
{
case -3:
case 17:
try
{
break;
}
finally
{
<>m__Finally1();
}
case -4:
case 20:
try
{
break;
}
finally
{
<>m__Finally2();
}
}
}
private bool MoveNext()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Expected O, but got Unknown
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Expected O, but got Unknown
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Expected O, but got Unknown
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Expected O, but got Unknown
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Expected O, but got Unknown
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Expected O, but got Unknown
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Expected O, but got Unknown
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Expected O, but got Unknown
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Expected O, but got Unknown
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Expected O, but got Unknown
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Expected O, but got Unknown
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Expected O, but got Unknown
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Expected O, but got Unknown
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Expected O, but got Unknown
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Expected O, but got Unknown
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Expected O, but got Unknown
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Expected O, but got Unknown
//IL_0397: Unknown result type (might be due to invalid IL or missing references)
//IL_03a1: 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_03d5: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Expected O, but got Unknown
//IL_0403: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Expected O, but got Unknown
//IL_0408: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Expected O, but got Unknown
//IL_044f: Unknown result type (might be due to invalid IL or missing references)
//IL_0459: Expected O, but got Unknown
//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
try
{
Token current2;
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
object obj2 = tokenlike;
Token val = (Token)((obj2 is Token) ? obj2 : null);
if (val != null)
{
<>2__current = val;
<>1__state = 1;
return true;
}
if (tokenlike is TokenType)
{
TokenType val2 = (TokenType)tokenlike;
<>2__current = new Token(val2, (uint?)null);
<>1__state = 2;
return true;
}
if (tokenlike is byte)
{
byte b = (byte)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)b, false));
<>1__state = 3;
return true;
}
if (tokenlike is sbyte)
{
sbyte b2 = (sbyte)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)b2, false));
<>1__state = 4;
return true;
}
if (tokenlike is short)
{
short num = (short)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)num, false));
<>1__state = 5;
return true;
}
if (tokenlike is ushort)
{
ushort num2 = (ushort)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)num2, false));
<>1__state = 6;
return true;
}
if (tokenlike is int)
{
int num3 = (int)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)num3, false));
<>1__state = 7;
return true;
}
if (tokenlike is uint)
{
uint num4 = (uint)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new IntVariant((long)num4, false));
<>1__state = 8;
return true;
}
if (tokenlike is long)
{
long num5 = (long)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new IntVariant(num5, false));
<>1__state = 9;
return true;
}
if (tokenlike is double)
{
double num6 = (double)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new RealVariant(num6, false));
<>1__state = 10;
return true;
}
if (tokenlike is float)
{
float num7 = (float)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new RealVariant((double)num7, false));
<>1__state = 11;
return true;
}
if (tokenlike is bool)
{
bool flag = (bool)tokenlike;
<>2__current = (Token)new ConstantToken((Variant)new BoolVariant(flag));
<>1__state = 12;
return true;
}
if (tokenlike is string text)
{
<>2__current = (Token)new ConstantToken((Variant)new StringVariant(text));
<>1__state = 13;
return true;
}
if (tokenlike == null)
{
<>2__current = (Token)new ConstantToken((Variant)new NilVariant());
<>1__state = 14;
return true;
}
if (tokenlike is NiceScriptMod.Identifier)
{
<>2__current = (Token)new IdentifierToken(((NiceScriptMod.Identifier)tokenlike).name);
<>1__state = 15;
return true;
}
if (tokenlike is NiceScriptMod.Wrapped)
{
<wrap>5__2 = (NiceScriptMod.Wrapped)tokenlike;
<>2__current = <wrap>5__2.start;
<>1__state = 16;
return true;
}
if (tokenlike is NiceScriptMod.Delimited)
{
<delim>5__6 = (NiceScriptMod.Delimited)tokenlike;
<>7__wrap4 = ToTokens(<delim>5__6.val).GetEnumerator();
current2 = <>7__wrap4.Current;
goto IL_067f;
}
throw new NotImplementedException($"Attempted to convert object ({tokenlike?.GetType()}) to token");
}
case 1:
<>1__state = -1;
break;
case 2:
<>1__state = -1;
break;
case 3:
<>1__state = -1;
break;
case 4:
<>1__state = -1;
break;
case 5:
<>1__state = -1;
break;
case 6:
<>1__state = -1;
break;
case 7:
<>1__state = -1;
break;
case 8:
<>1__state = -1;
break;
case 9:
<>1__state = -1;
break;
case 10:
<>1__state = -1;
break;
case 11:
<>1__state = -1;
break;
case 12:
<>1__state = -1;
break;
case 13:
<>1__state = -1;
break;
case 14:
<>1__state = -1;
break;
case 15:
<>1__state = -1;
break;
case 16:
<>1__state = -1;
<>7__wrap2 = <wrap>5__2.val;
<>7__wrap3 = 0;
goto IL_0555;
case 17:
<>1__state = -3;
goto IL_052d;
case 18:
<>1__state = -1;
goto IL_0707;
case 19:
<>1__state = -1;
<>7__wrap6 = ToTokens(<delim>5__6.delimiter).GetEnumerator();
<>1__state = -4;
goto IL_0658;
case 20:
<>1__state = -4;
goto IL_0658;
case 21:
{
<>1__state = -1;
<>7__wrap4 = null;
<delim>5__6 = default(NiceScriptMod.Delimited);
goto IL_0707;
}
IL_0658:
if (((global::System.Collections.IEnumerator)<>7__wrap6).MoveNext())
{
Token current = <>7__wrap6.Current;
<>2__current = current;
<>1__state = 20;
return true;
}
<>m__Finally2();
<>7__wrap6 = null;
current2 = <>7__wrap4.Current;
goto IL_067f;
IL_0707:
<wrap>5__2 = default(NiceScriptMod.Wrapped);
break;
IL_0555:
if (<>7__wrap3 < <>7__wrap2.Length)
{
object obj = <>7__wrap2[<>7__wrap3];
<>7__wrap4 = ToTokens(obj).GetEnumerator();
<>1__state = -3;
goto IL_052d;
}
<>7__wrap2 = null;
<>2__current = <wrap>5__2.end;
<>1__state = 18;
return true;
IL_052d:
if (((global::System.Collections.IEnumerator)<>7__wrap4).MoveNext())
{
Token current3 = <>7__wrap4.Current;
<>2__current = current3;
<>1__state = 17;
return true;
}
<>m__Finally1();
<>7__wrap4 = null;
<>7__wrap3++;
goto IL_0555;
IL_067f:
if (((global::System.Collections.IEnumerator)<>7__wrap4).MoveNext())
{
<>2__current = current2;
<>1__state = 19;
return true;
}
<>2__current = current2;
<>1__state = 21;
return true;
}
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__wrap4 != null)
{
((global::System.IDisposable)<>7__wrap4).Dispose();
}
}
private void <>m__Finally2()
{
<>1__state = -1;
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()
{
<ToTokens>d__7 <ToTokens>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<ToTokens>d__ = this;
}
else
{
<ToTokens>d__ = new <ToTokens>d__7(0);
}
<ToTokens>d__.tokenlike = <>3__tokenlike;
return <ToTokens>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 LinkedList<Token> List;
public LinkedListNode<Token>? Head;
public TokenCursor(global::System.Collections.Generic.IEnumerable<Token> tokens)
{
List = new LinkedList<Token>((global::System.Collections.Generic.IEnumerable<Token>)Enumerable.ToArray<Token>(tokens));
Head = List.First;
}
public void MatchAhead(IWaiter waiter, string? label = null)
{
if (!TryMatchAhead(waiter))
{
throw new NoMatchException("Could not match pattern " + (label ?? "<unlabeled>"));
}
}
public bool TryMatchAhead(IWaiter waiter)
{
for (LinkedListNode<Token> val = Head; val != null; val = val.Next)
{
if (waiter.Check(val.Value))
{
Head = val;
return true;
}
}
return false;
}
public void MatchBehind(IWaiter waiter, string? label = null)
{
if (!TryMatchBehind(waiter))
{
throw new NoMatchException("Could not match pattern " + (label ?? "<unlabeled>"));
}
}
public bool TryMatchBehind(IWaiter waiter)
{
for (LinkedListNode<Token> val = Head; val != null; val = val.Next)
{
if (waiter.Check(val.Value))
{
Head = val;
return true;
}
}
return false;
}
[IteratorStateMachine(typeof(<ToTokens>d__7))]
private static global::System.Collections.Generic.IEnumerable<Token> ToTokens(object? tokenlike)
{
Token val = (Token)((tokenlike is Token) ? tokenlike : null);
if (val != null)
{
yield return val;
yield break;
}
if (tokenlike is TokenType val2)
{
yield return new Token(val2, (uint?)null);
yield break;
}
if (tokenlike is byte b)
{
yield return (Token)new ConstantToken((Variant)new IntVariant((long)b, false));
yield break;
}
if (tokenlike is sbyte b2)
{
yield return (Token)new ConstantToken((Variant)new IntVariant((long)b2, false));
yield break;
}
if (tokenlike is short num)
{
yield return (Token)new ConstantToken((Variant)new IntVariant((long)num, false));
yield break;
}
if (tokenlike is ushort num2)
{
yield return (Token)new ConstantToken((Variant)new IntVariant((long)num2, false));
yield break;
}
if (tokenlike is int num3)
{
yield return (Token)new ConstantToken((Variant)new IntVariant((long)num3, false));
yield break;
}
if (tokenlike is uint num4)
{
yield return (Token)new ConstantToken((Variant)new IntVariant((long)num4, false));
yield break;
}
if (tokenlike is long num5)
{
yield return (Token)new ConstantToken((Variant)new IntVariant(num5, false));
yield break;
}
if (tokenlike is double num6)
{
yield return (Token)new ConstantToken((Variant)new RealVariant(num6, false));
yield break;
}
if (tokenlike is float num7)
{
yield return (Token)new ConstantToken((Variant)new RealVariant((double)num7, false));
yield break;
}
if (tokenlike is bool flag)
{
yield return (Token)new ConstantToken((Variant)new BoolVariant(flag));
yield break;
}
if (tokenlike is string text)
{
yield return (Token)new ConstantToken((Variant)new StringVariant(text));
yield break;
}
if (tokenlike == null)
{
yield return (Token)new ConstantToken((Variant)new NilVariant());
yield break;
}
if (tokenlike is NiceScriptMod.Identifier identifier)
{
yield return (Token)new IdentifierToken(identifier.name);
yield break;
}
if (tokenlike is NiceScriptMod.Wrapped wrap)
{
yield return wrap.start;
object?[] val3 = wrap.val;
foreach (object tokenlike2 in val3)
{
global::System.Collections.Generic.IEnumerator<Token> enumerator = ToTokens(tokenlike2).GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
yield return enumerator.Current;
}
}
finally
{
((global::System.IDisposable)enumerator)?.Dispose();
}
}
yield return wrap.end;
yield break;
}
if (tokenlike is NiceScriptMod.Delimited delim)
{
global::System.Collections.Generic.IEnumerator<Token> enumerator = ToTokens(delim.val).GetEnumerator();
Token current = enumerator.Current;
while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
yield return current;
global::System.Collections.Generic.IEnumerator<Token> enumerator2 = ToTokens(delim.delimiter).GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
{
yield return enumerator2.Current;
}
}
finally
{
((global::System.IDisposable)enumerator2)?.Dispose();
}
current = enumerator.Current;
}
yield return current;
yield break;
}
throw new NotImplementedException($"Attempted to convert object ({tokenlike?.GetType()}) to token");
}
public void Patch(global::System.Collections.Generic.IEnumerable<object> tok_objs)
{
global::System.Collections.Generic.IEnumerator<object> enumerator = tok_objs.GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
global::System.Collections.Generic.IEnumerable<Token> enumerable = ToTokens(enumerator.Current);
if (Head == null)
{
List = new LinkedList<Token>(enumerable);
Head = List.Last;
break;
}
global::System.Collections.Generic.IEnumerator<Token> enumerator2 = enumerable.GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
{
LinkedListNode<Token> val = new LinkedListNode<Token>(enumerator2.Current);
List.AddAfter(Head, val);
Head = val;
}
}
finally
{
((global::System.IDisposable)enumerator2)?.Dispose();
}
}
}
finally
{
((global::System.IDisposable)enumerator)?.Dispose();
}
}
public Token? PopToNext()
{
if (Head == null)
{
return null;
}
List.Remove(Head);
LinkedListNode<Token>? head = Head;
Head = Head.Next;
return head.Value;
}
public Token? PopToPrevious()
{
if (Head == null)
{
return null;
}
List.Remove(Head);
LinkedListNode<Token>? head = Head;
Head = Head.Previous;
return head.Value;
}
public string Display()
{
return string.Join(" ", DisplayStrings());
}
[IteratorStateMachine(typeof(<DisplayStrings>d__12))]
private global::System.Collections.Generic.IEnumerable<string> DisplayStrings()
{
Enumerator<Token> enumerator = List.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Token tok = enumerator.Current;
ConstantToken val = (ConstantToken)(object)((tok is ConstantToken) ? tok : null);
if (val != null)
{
if (val.Value is NilVariant)
{
yield return "null";
continue;
}
Variant value = val.Value;
BoolVariant val2 = (BoolVariant)(object)((value is BoolVariant) ? value : null);
if (val2 != null)
{
yield return val2.Value ? "true" : "false";
continue;
}
Variant value2 = val.Value;
StringVariant val3 = (StringVariant)(object)((value2 is StringVariant) ? value2 : null);
if (val3 != null)
{
yield return "\"" + val3.Value + "\"";
}
else
{
yield return val.Value.GetValue().ToString();
}
continue;
}
IdentifierToken val4 = (IdentifierToken)(object)((tok is IdentifierToken) ? tok : null);
if (val4 != null)
{
yield return val4.Name;
continue;
}
TokenType type = tok.Type;
switch ((int)type)
{
case 3:
yield return "self";
break;
case 4:
yield return global::System.Enum.GetName<VariantType>((VariantType)tok.AssociatedData.GetValueOrDefault()) ?? "<type>";
break;
case 5:
yield return global::System.Enum.GetName<BuiltinFunction>((BuiltinFunction)tok.AssociatedData.GetValueOrDefault()) ?? "<fn>";
yield return "";
break;
case 6:
yield return "in";
break;
case 7:
yield return "==";
break;
case 8:
yield return "!=";
break;
case 9:
yield return "<";
break;
case 10:
yield return "<=";
break;
case 11:
yield return ">";
break;
case 12:
yield return ">=";
break;
case 13:
yield return "&&";
break;
case 14:
yield return "||";
break;
case 15:
yield return "!";
break;
case 16:
yield return "+";
break;
case 17:
yield return "-";
break;
case 18:
yield return "*";
break;
case 19:
yield return "/";
break;
case 20:
yield return "%";
break;
case 21:
yield return "<<";
break;
case 22:
yield return ">>";
break;
case 23:
yield return "=";
break;
case 24:
yield return "+=";
break;
case 25:
yield return "-=";
break;
case 26:
yield return "*=";
break;
case 27:
yield return "/=";
break;
case 28:
yield return "%=";
break;
case 29:
yield return "<<=";
break;
case 30:
yield return ">>=";
break;
case 31:
yield return "&=";
break;
case 32:
yield return "|=";
break;
case 33:
yield return "^=";
break;
case 34:
yield return "&";
break;
case 35:
yield return "|";
break;
case 36:
yield return "^";
break;
case 37:
yield return "~";
break;
case 38:
yield return "if";
break;
case 39:
yield return "elif";
break;
case 40:
yield return "else";
break;
case 41:
yield return "for";
break;
case 42:
yield return "while";
break;
case 43:
yield return "break";
break;
case 44:
yield return "continue";
break;
case 45:
yield return "pass";
break;
case 46:
yield return "return";
break;
case 47:
yield return "match";
break;
case 48:
yield return "func";
break;
case 49:
yield return "class";
break;
case 50:
yield return "<class name>";
break;
case 51:
yield return "extends";
break;
case 52:
yield return "is";
break;
case 53:
yield return "@onready";
break;
case 54:
yield return "@tool";
break;
case 55:
yield return "static";
break;
case 56:
yield return "@export";
break;
case 57:
yield return "setget";
break;
case 58:
yield return "const";
break;
case 59:
yield return "var";
break;
case 60:
yield return "as";
break;
case 61:
yield return "void";
break;
case 62:
yield return "enum";
break;
case 63:
yield return "preload";
break;
case 64:
yield return "assert";
break;
case 65:
yield return "yield";
break;
case 66:
yield return "signal";
break;
case 67:
yield return "breakpoint";
break;
case 68:
yield return "remote";
break;
case 69:
yield return "sync";
break;
case 70:
yield return "master";
break;
case 71:
case 72:
yield return "puppet";
break;
case 73:
yield return "remotesync";
break;
case 74:
yield return "mastersync";
break;
case 75:
yield return "puppetsync";
break;
case 76:
yield return "[";
break;
case 77:
yield return "]";
break;
case 78:
yield return "{";
break;
case 79:
yield return "}";
break;
case 80:
yield return "(";
break;
case 81:
yield return ")";
break;
case 82:
yield return ",";
break;
case 83:
yield return ":";
break;
case 84:
yield return ".";
break;
case 85:
yield return "?";
break;
case 86:
yield return ":";
break;
case 87:
yield return "$";
break;
case 88:
yield return "->";
break;
case 89:
{
yield return "\n";
for (int i = 0; i < tok.AssociatedData.GetValueOrDefault(); i++)
{
yield return "\t";
}
break;
}
case 90:
yield return "PI";
break;
case 91:
yield return "TAU";
break;
case 92:
yield return "*";
break;
case 93:
yield return "INF";
break;
case 94:
yield return "NAN";
break;
case 95:
yield return "Error";
break;
case 96:
yield return "";
break;
case 97:
yield return "";
break;
}
}
}
finally
{
((global::System.IDisposable)enumerator).Dispose();
}
}
}
public abstract class NiceScriptMod : IScriptMod
{
protected internal readonly struct Identifier
{
public readonly string name;
public Identifier(string name)
{
this.name = name;
}
}
protected internal readonly struct Wrapped
{
public readonly object?[] val;
public readonly Token start;
public readonly Token end;
public Wrapped(object?[] val, Token start, Token end)
{
this.val = val;
this.start = start;
this.end = end;
}
}
protected internal readonly struct Delimited
{
public readonly object? delimiter;
public readonly object?[] val;
public Delimited(object? delimiter, object?[] val)
{
this.delimiter = delimiter;
this.val = val;
}
}
[CompilerGenerated]
private Dictionary<string, OnMatch> <actions>P;
protected NiceScriptMod(Dictionary<string, OnMatch> actions)
{
<actions>P = actions;
base..ctor();
}
public bool ShouldRun(string path)
{
return <actions>P.ContainsKey(path);
}
public global::System.Collections.Generic.IEnumerable<Token> Modify(string path, global::System.Collections.Generic.IEnumerable<Token> tokens)
{
OnMatch onMatch = default(OnMatch);
if (<actions>P.TryGetValue(path, ref onMatch))
{
TokenCursor cur = new TokenCursor(tokens);
onMatch(ref cur);
return (global::System.Collections.Generic.IEnumerable<Token>)cur.List;
}
return tokens;
}
protected internal static Identifier Ident(string name)
{
return new Identifier(name);
}
protected internal static Wrapped Paren(params object?[] val)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
return new Wrapped(val, new Token((TokenType)80, (uint?)null), new Token((TokenType)81, (uint?)null));
}
protected internal static Wrapped Brack(params object?[] val)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
return new Wrapped(val, new Token((TokenType)76, (uint?)null), new Token((TokenType)77, (uint?)null));
}
protected internal static Wrapped Curly(params object?[] val)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
return new Wrapped(val, new Token((TokenType)78, (uint?)null), new Token((TokenType)79, (uint?)null));
}
protected internal static Delimited Delim(object? delimiter, params object?[] val)
{
return new Delimited(delimiter, val);
}
protected internal static Token Nl(uint tabs = 0u)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
return new Token((TokenType)89, (uint?)tabs);
}
}
public delegate void OnMatch(ref TokenCursor cur);