Decompiled source of CustomDroptables v1.0.0

CustomDropTables.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CustomDropTables;
using CustomDropTables.Config;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Scripting;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CustomDropTables")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Created with VRising.ModTemplate, you should edit this.")]
[assembly: AssemblyFileVersion("0.1.10.0")]
[assembly: AssemblyInformationalVersion("0.1.10+1.Branch.main.Sha.c33d0879382e1a0da34861ec55914ba7e637a80e.eb8dea68e3d4ee83d4c2c72c06b1ef309a03b879")]
[assembly: AssemblyProduct("CustomDropTables")]
[assembly: AssemblyTitle("CustomDropTables")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.10.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal static class Core
{
	private static bool hasInitialized;

	public static World Server { get; } = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");


	public static EntityManager EntityManager { get; } = Server.EntityManager;


	public static GameDataSystem GameDataSystem { get; } = Server.GetExistingSystemManaged<GameDataSystem>();


	public static PrefabCollectionSystem PrefabCollectionSystem { get; internal set; }

	public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; }

	public static ServerScriptMapper ServerScriptMapper { get; internal set; }

	public static DebugEventsSystem DebugEventsSystem { get; internal set; }

	public static double ServerTime => ServerGameManager.ServerTime;

	public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager();

	public static void Initialize()
	{
		if (!hasInitialized)
		{
			PrefabCollectionSystem = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			ServerGameSettingsSystem = Server.GetExistingSystemManaged<ServerGameSettingsSystem>();
			DebugEventsSystem = Server.GetExistingSystemManaged<DebugEventsSystem>();
			ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
			hasInitialized = true;
		}
	}

	private static World GetWorld(string name)
	{
		Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
		while (enumerator.MoveNext())
		{
			World current = enumerator.Current;
			if (current.Name == name)
			{
				return current;
			}
		}
		return null;
	}
}
namespace CustomDroptables
{
	[HarmonyPatch(typeof(DropInInventoryOnSpawnSystem), "OnUpdate")]
	public class Patch_DropInInventoryOnSpawnSystem
	{
		private static HashSet<PrefabGUID> processedDropTables = new HashSet<PrefabGUID>();

		private static Dictionary<PrefabGUID, Configuration.DroptableData> DropTableGuids = Configuration.Instance.DropTableGuids;

		private static void Prefix(DropInInventoryOnSpawnSystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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)
			EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
			EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<ServerGameBalanceSettings>() });
			ServerGameBalanceSettings singleton = ((EntityQuery)(ref val)).GetSingleton<ServerGameBalanceSettings>();
			EntityQuery entityQuery = ((ComponentSystemBase)__instance).GetEntityQuery((ComponentType[])(object)new ComponentType[3]
			{
				ComponentType.ReadOnly<DropInInventoryOnSpawn>(),
				ComponentType.ReadOnly<SpawnTag>(),
				ComponentType.ReadWrite<DropTableBuffer>()
			});
			NativeArray<Entity> val2 = ((EntityQuery)(ref entityQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val2.GetEnumerator();
			DynamicBuffer<DropTableBuffer> val3 = default(DynamicBuffer<DropTableBuffer>);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				EntityManager entityManager2 = Core.EntityManager;
				if (((EntityManager)(ref entityManager2)).TryGetBuffer<DropTableBuffer>(current, ref val3))
				{
					PrefabGUID dropTableGuid = val3[0].DropTableGuid;
					if (DropTableGuids.TryGetValue(dropTableGuid, out var value) && !processedDropTables.Contains(dropTableGuid))
					{
						modifyDataBuffer(dropTableGuid, value, singleton.DropTableModifier_General);
						processedDropTables.Add(dropTableGuid);
					}
				}
			}
			val2.Dispose();
		}

		private static void modifyDataBuffer(PrefabGUID entityDroptableGuid, Configuration.DroptableData cfg, half modifier)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			Entity val = default(Entity);
			if (!Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(entityDroptableGuid, ref val))
			{
				return;
			}
			EntityManager entityManager = Core.EntityManager;
			DynamicBuffer<DropTableDataBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<DropTableDataBuffer>(val, false);
			if (cfg.ReplaceAll)
			{
				buffer.Clear();
			}
			Plugin.Logger.LogMessage((object)($"Modifying droptable {entityDroptableGuid} - buffer length before: " + buffer.Length));
			foreach (KeyValuePair<PrefabGUID, Configuration.ItemData> addItem in cfg.AddItems)
			{
				PrefabGUID key = addItem.Key;
				Configuration.ItemData value = addItem.Value;
				int num = ((!value.Quantity.IsRange) ? value.Quantity.Min : Random.Range(value.Quantity.Min, value.Quantity.Max + 1));
				int quantity = Mathf.RoundToInt((float)num / half.op_Implicit(modifier));
				buffer.Add(new DropTableDataBuffer
				{
					ItemGuid = key,
					Quantity = quantity,
					DropRate = value.SpawnChance,
					ItemType = (DropItemType)0
				});
			}
			Plugin.Logger.LogMessage((object)($"Finished modifying droptable {entityDroptableGuid} - buffer length after: " + buffer.Length));
		}
	}
}
namespace CustomDropTables
{
	[BepInPlugin("CustomDropTables", "CustomDropTables", "0.1.10")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		public static ManualLogSource Logger;

		private static Harmony _harmony;

		public static Harmony Harmony => _harmony;

		internal static Plugin Instance { get; private set; }

		public override void Load()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			Instance = this;
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CustomDropTables");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.10");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			Configuration.Instance.LoadConfiguration();
			((BasePlugin)this).Log.LogInfo((object)"Loaded configuration for custom droptables: ");
			foreach (KeyValuePair<PrefabGUID, Configuration.DroptableData> dropTableGuid in Configuration.Instance.DropTableGuids)
			{
				Logger.LogInfo((object)dropTableGuid.Key);
			}
			_harmony = new Harmony("CustomDropTables");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
		}

		public override bool Unload()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CustomDropTables";

		public const string PLUGIN_NAME = "CustomDropTables";

		public const string PLUGIN_VERSION = "0.1.10";
	}
}
namespace CustomDropTables.Patches
{
	[HarmonyPatch(typeof(SpawnTeamSystem_OnPersistenceLoad), "OnUpdate")]
	public static class InitializationPatch
	{
		[HarmonyPostfix]
		public static void OneShot_AfterLoad_InitializationPatch()
		{
			Core.Initialize();
			Plugin.Harmony.Unpatch((MethodBase)typeof(SpawnTeamSystem_OnPersistenceLoad).GetMethod("OnUpdate"), typeof(InitializationPatch).GetMethod("OneShot_AfterLoad_InitializationPatch"));
		}
	}
}
namespace CustomDropTables.Config
{
	public struct RangeInt
	{
		public int Min { get; set; }

		public int Max { get; set; }

		public bool IsRange => Min != Max;
	}
	public class Configuration
	{
		public class IntDroptableData
		{
			[JsonPropertyName("replace_all")]
			public bool ReplaceAll { get; set; }

			[JsonPropertyName("add_items")]
			public Dictionary<string, IntItemData> AddItems { get; set; } = new Dictionary<string, IntItemData>();

		}

		public class IntItemData
		{
			[JsonPropertyName("quantity")]
			[JsonConverter(typeof(JsonStringToRangeIntConverter))]
			public RangeInt Quantity { get; set; }

			[JsonPropertyName("spawnchance")]
			public float SpawnChance { get; set; }
		}

		public class DroptableData
		{
			[JsonPropertyName("replace_all")]
			public bool ReplaceAll { get; set; }

			[JsonPropertyName("add_items")]
			public Dictionary<PrefabGUID, ItemData> AddItems { get; set; } = new Dictionary<PrefabGUID, ItemData>();

		}

		public class ItemData
		{
			[JsonPropertyName("quantity")]
			[JsonConverter(typeof(JsonStringToRangeIntConverter))]
			public RangeInt Quantity { get; set; }

			[JsonPropertyName("spawnchance")]
			public float SpawnChance { get; set; }
		}

		private static readonly string CONFIG_PATH = Path.Combine(Paths.ConfigPath, "CustomDropTables");

		private static readonly string USERS_PATH = Path.Combine(CONFIG_PATH, "Configuration.json");

		private static readonly string CONFIG_RESOURCE = "CustomDropTables.Config.SampleConfiguration.json";

		private static Configuration _instance;

		[JsonPropertyName("droptable_guids")]
		public Dictionary<int, IntDroptableData> IntDropTableGuids { get; private set; } = new Dictionary<int, IntDroptableData>();


		public Dictionary<PrefabGUID, DroptableData> DropTableGuids { get; private set; } = new Dictionary<PrefabGUID, DroptableData>();


		private Configuration configuration { get; }

		public static Configuration Instance => _instance ?? (_instance = new Configuration());

		private Configuration()
		{
			LoadConfiguration();
		}

		public void LoadConfiguration()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			Directory.CreateDirectory(CONFIG_PATH);
			JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
			{
				WriteIndented = true,
				PropertyNameCaseInsensitive = true
			};
			jsonSerializerOptions.Converters.Add(new JsonStringToIntConverter());
			jsonSerializerOptions.Converters.Add(new JsonStringToFloatConverter());
			jsonSerializerOptions.Converters.Add(new JsonStringToPrefabGUIDConverter());
			jsonSerializerOptions.Converters.Add(new JsonStringToRangeIntConverter());
			if (!File.Exists(USERS_PATH) || new FileInfo(USERS_PATH).Length == 0L)
			{
				CreateSampleConfiguration(jsonSerializerOptions);
			}
			try
			{
				string json = File.ReadAllText(USERS_PATH);
				IntDropTableGuids = JsonSerializer.Deserialize<Dictionary<int, IntDroptableData>>(json, jsonSerializerOptions);
				if (IntDropTableGuids == null)
				{
					Plugin.Logger.LogError((object)"Deserialization failed. Creating sample configuration.");
					CreateSampleConfiguration(jsonSerializerOptions);
				}
				else
				{
					ConvertToPrefabGUIDData();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error loading configuration: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val);
				CreateSampleConfiguration(jsonSerializerOptions);
			}
		}

		private void CreateSampleConfiguration(JsonSerializerOptions options)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(CONFIG_RESOURCE);
				if (stream == null)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(43, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Sample configuration resource '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(CONFIG_RESOURCE);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found.");
					}
					logger.LogError(val);
					return;
				}
				using StreamReader streamReader = new StreamReader(stream);
				string text = streamReader.ReadToEnd();
				Plugin.Logger.LogMessage((object)"Created new sample config for droptables: ");
				Plugin.Logger.LogMessage((object)text);
				File.WriteAllText(USERS_PATH, text);
				IntDropTableGuids = JsonSerializer.Deserialize<Dictionary<int, IntDroptableData>>(text, options);
				if (IntDropTableGuids == null)
				{
					Plugin.Logger.LogError((object)"Error deserializing sample configuration.");
				}
				else
				{
					ConvertToPrefabGUIDData();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error creating sample configuration: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logger2.LogError(val);
			}
		}

		private void ConvertToPrefabGUIDData()
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			DropTableGuids = new Dictionary<PrefabGUID, DroptableData>();
			bool flag = default(bool);
			foreach (KeyValuePair<int, IntDroptableData> intDropTableGuid in IntDropTableGuids)
			{
				DroptableData droptableData = new DroptableData
				{
					ReplaceAll = intDropTableGuid.Value.ReplaceAll,
					AddItems = new Dictionary<PrefabGUID, ItemData>()
				};
				foreach (KeyValuePair<string, IntItemData> addItem in intDropTableGuid.Value.AddItems)
				{
					if (int.TryParse(addItem.Key, out var result))
					{
						droptableData.AddItems.Add(new PrefabGUID(result), new ItemData
						{
							Quantity = addItem.Value.Quantity,
							SpawnChance = addItem.Value.SpawnChance
						});
						continue;
					}
					ManualLogSource logger = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to parse item key '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(addItem.Key);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' to integer.");
					}
					logger.LogError(val);
				}
				DropTableGuids.Add(new PrefabGUID(intDropTableGuid.Key), droptableData);
			}
		}
	}
	public class JsonStringToIntConverter : JsonConverter<int>
	{
		public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			if (reader.TokenType == JsonTokenType.String && int.TryParse(reader.GetString(), out var result))
			{
				return result;
			}
			if (reader.TokenType == JsonTokenType.Number)
			{
				return reader.GetInt32();
			}
			throw new JsonException("Value is not an integer or numeric string.");
		}

		public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
		{
			writer.WriteNumberValue(value);
		}
	}
	public class JsonStringToFloatConverter : JsonConverter<float>
	{
		public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			if (reader.TokenType == JsonTokenType.String)
			{
				string @string = reader.GetString();
				if (float.TryParse(@string, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					return result;
				}
				throw new JsonException("Unable to convert \"" + @string + "\" to a float.");
			}
			if (reader.TokenType == JsonTokenType.Number)
			{
				return reader.GetSingle();
			}
			throw new JsonException("Unexpected token type when parsing float.");
		}

		public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
		{
			writer.WriteNumberValue(value);
		}
	}
	public class JsonStringToPrefabGUIDConverter : JsonConverter<PrefabGUID>
	{
		public override PrefabGUID Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (reader.TokenType == JsonTokenType.String && int.TryParse(reader.GetString(), out var result))
			{
				return new PrefabGUID(result);
			}
			if (reader.TokenType == JsonTokenType.Number)
			{
				return new PrefabGUID(reader.GetInt32());
			}
			throw new JsonException("Value is not an integer or numeric string.");
		}

		public override void Write(Utf8JsonWriter writer, PrefabGUID value, JsonSerializerOptions options)
		{
			writer.WriteStringValue(((object)(PrefabGUID)(ref value)).ToString());
		}
	}
	public class JsonStringToRangeIntConverter : JsonConverter<RangeInt>
	{
		public override RangeInt Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			if (reader.TokenType == JsonTokenType.Number)
			{
				int @int = reader.GetInt32();
				RangeInt result = default(RangeInt);
				result.Min = @int;
				result.Max = @int;
				return result;
			}
			if (reader.TokenType == JsonTokenType.String)
			{
				string @string = reader.GetString();
				int result4;
				if (@string.Contains("-"))
				{
					string[] array = @string.Split('-', StringSplitOptions.RemoveEmptyEntries);
					if (array.Length == 2 && int.TryParse(array[0], out var result2) && int.TryParse(array[1], out var result3))
					{
						RangeInt result = default(RangeInt);
						result.Min = result2;
						result.Max = result3;
						return result;
					}
				}
				else if (int.TryParse(@string, out result4))
				{
					RangeInt result = default(RangeInt);
					result.Min = result4;
					result.Max = result4;
					return result;
				}
			}
			throw new JsonException("Invalid format for RangeInt.");
		}

		public override void Write(Utf8JsonWriter writer, RangeInt value, JsonSerializerOptions options)
		{
			if (!value.IsRange)
			{
				writer.WriteNumberValue(value.Min);
				return;
			}
			writer.WriteStringValue($"{value.Min}-{value.Max}");
		}
	}
}