Decompiled source of Spawner Tweaks v1.29.0

SpawnerTweaks.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using Service;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SpawnerTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+276c43cb865b220c304857ddb8dc73d5b629214a")]
[assembly: AssemblyProduct("SpawnerTweaks")]
[assembly: AssemblyTitle("SpawnerTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
namespace Service
{
	public class ConfigWrapper
	{
		private readonly ConfigFile ConfigFile;

		private readonly ConfigSync ConfigSync;

		private readonly Dictionary<string, Action<Terminal, string>> SettingHandlers = new Dictionary<string, Action<Terminal, string>>();

		private static readonly HashSet<string> Truthies = new HashSet<string> { "1", "true", "yes", "on" };

		private static readonly HashSet<string> Falsies = new HashSet<string> { "0", "false", "no", "off" };

		public ConfigWrapper(string command, ConfigFile configFile, ConfigSync configSync)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_004a: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			ConfigFile = configFile;
			ConfigSync = configSync;
			new ConsoleCommand(command, "[key] [value] - Toggles or sets a config value.", (ConsoleEvent)delegate(ConsoleEventArgs args)
			{
				if (args.Length >= 2 && SettingHandlers.TryGetValue(args[1].ToLower(), out Action<Terminal, string> value))
				{
					if (args.Length == 2)
					{
						value(args.Context, "");
					}
					else
					{
						value(args.Context, string.Join(" ", args.Args.Skip(2)));
					}
				}
			}, false, false, false, false, false, (ConsoleOptionsFetcher)(() => SettingHandlers.Keys.ToList()), false, false, false);
		}

		public ConfigEntry<bool> BindLocking(string group, string name, bool value, ConfigDescription description)
		{
			ConfigEntry<bool> val = ConfigFile.Bind<bool>(group, name, value, description);
			Register(val);
			ConfigSync.AddLockingConfigEntry<bool>(val).SynchronizedConfig = true;
			return val;
		}

		public ConfigEntry<bool> BindLocking(string group, string name, bool value, string description)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			return BindLocking(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}

		public ConfigEntry<T> Bind<T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			ConfigEntry<T> val = ConfigFile.Bind<T>(group, name, value, description);
			Register<T>(val);
			ConfigSync.AddConfigEntry<T>(val).SynchronizedConfig = synchronizedSetting;
			return val;
		}

		public ConfigEntry<T> Bind<T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return Bind(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		private static void AddMessage(Terminal context, string message)
		{
			context.AddString(message);
			Player localPlayer = Player.m_localPlayer;
			if (localPlayer != null)
			{
				((Character)localPlayer).Message((MessageType)1, message, 0, (Sprite)null);
			}
		}

		private void Register(ConfigEntry<bool> setting)
		{
			ConfigEntry<bool> setting2 = setting;
			string name = ((ConfigEntryBase)setting2).Definition.Key;
			string key = name.ToLower().Replace(' ', '_');
			SettingHandlers.Add(key, delegate(Terminal terminal, string value)
			{
				Toggle(terminal, setting2, name, value);
			});
		}

		private void Register<T>(ConfigEntry<T> setting)
		{
			ConfigEntry<T> setting2 = setting;
			string name = ((ConfigEntryBase)setting2).Definition.Key;
			string key = name.ToLower().Replace(' ', '_');
			SettingHandlers.Add(key, delegate(Terminal terminal, string value)
			{
				SetValue<T>(terminal, setting2, name, value);
			});
		}

		private static string State(bool value)
		{
			if (!value)
			{
				return "disabled";
			}
			return "enabled";
		}

		private static bool IsTruthy(string value)
		{
			return Truthies.Contains(value);
		}

		private static bool IsFalsy(string value)
		{
			return Falsies.Contains(value);
		}

		private static void Toggle(Terminal context, ConfigEntry<bool> setting, string name, string value)
		{
			if (value == "")
			{
				setting.Value = !setting.Value;
			}
			else if (IsTruthy(value))
			{
				setting.Value = true;
			}
			else if (IsFalsy(value))
			{
				setting.Value = false;
			}
			AddMessage(context, name + " " + State(setting.Value) + ".");
		}

		public static int TryParseInt(string value, int defaultValue)
		{
			if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static int TryParseInt(ConfigEntry<string> setting)
		{
			if (int.TryParse(setting.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return TryParseInt((string)((ConfigEntryBase)setting).DefaultValue, 0);
		}

		private static float TryParseFloat(string value, float defaultValue)
		{
			if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static float TryParseFloat(ConfigEntry<string> setting)
		{
			if (float.TryParse(setting.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return TryParseFloat((string)((ConfigEntryBase)setting).DefaultValue, 0f);
		}

		private static void SetValue<T>(Terminal context, ConfigEntry<T> setting, string name, string value)
		{
			if (value == "")
			{
				AddMessage(context, $"{name}: {setting.Value}.");
				return;
			}
			setting.Value = (T)(object)value;
			AddMessage(context, name + " set to " + value + ".");
		}
	}
	public class Watcher
	{
		private static readonly Dictionary<string, byte[]> hashes = new Dictionary<string, byte[]>();

		private static byte[] GetHash(string path)
		{
			using MD5 mD = MD5.Create();
			using FileStream inputStream = File.OpenRead(path);
			return mD.ComputeHash(inputStream);
		}

		public static void Setup(string folder, string pattern, Action action)
		{
			Action action2 = action;
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(folder, pattern);
			fileSystemWatcher.Changed += delegate(object s, FileSystemEventArgs e)
			{
				byte[] hash = GetHash(e.FullPath);
				if (!hashes.ContainsKey(e.FullPath) || !hashes[e.FullPath].SequenceEqual(hash))
				{
					hashes[e.FullPath] = hash;
					action2();
				}
			};
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		public static void Setup(ConfigFile config, ManualLogSource logger)
		{
			ConfigFile config2 = config;
			ManualLogSource logger2 = logger;
			string configFilePath = config2.ConfigFilePath;
			string directoryName = Path.GetDirectoryName(configFilePath);
			string fileName = Path.GetFileName(configFilePath);
			Setup(directoryName, fileName, delegate
			{
				if (!File.Exists(config2.ConfigFilePath))
				{
					return;
				}
				try
				{
					logger2.LogDebug((object)"ReadConfigValues called");
					config2.Reload();
				}
				catch
				{
					logger2.LogError((object)("There was an issue loading your " + config2.ConfigFilePath));
					logger2.LogError((object)"Please check your config entries for spelling and format!");
				}
			});
		}
	}
	public class DataHelper
	{
		public static ZPackage? Deserialize(string data)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			if (data == "")
			{
				return null;
			}
			return new ZPackage(data);
		}

		public static void InitZDO(GameObject obj, Vector3 position, Quaternion rotation, ZPackage data)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			ZNetView val = default(ZNetView);
			if (obj.TryGetComponent<ZNetView>(ref val))
			{
				int stableHashCode = StringExtensionMethods.GetStableHashCode(val.GetPrefabName());
				ZNetView.m_initZDO = ZDOMan.instance.CreateNewZDO(position, stableHashCode);
				Load(data, ZNetView.m_initZDO);
				ZNetView.m_initZDO.m_rotation = ((Quaternion)(ref rotation)).eulerAngles;
				ZNetView.m_initZDO.Type = val.m_type;
				ZNetView.m_initZDO.Distant = val.m_distant;
				ZNetView.m_initZDO.Persistent = val.m_persistent;
				ZNetView.m_initZDO.m_prefab = stableHashCode;
				ZNetView.m_initZDO.DataRevision = 1u;
			}
		}

		private static void Load(ZPackage pkg, ZDO zdo)
		{
			//IL_0008: 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_0026: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			pkg.SetPos(0);
			ZDOID uid = zdo.m_uid;
			int num = pkg.ReadInt();
			if (((uint)num & (true ? 1u : 0u)) != 0)
			{
				byte b = pkg.ReadByte();
				ZDOHelper.Init<float>(ZDOExtraData.s_floats, uid);
				for (int i = 0; i < b; i++)
				{
					ZDOExtraData.Set(uid, pkg.ReadInt(), pkg.ReadSingle());
				}
			}
			if (((uint)num & 2u) != 0)
			{
				byte b2 = pkg.ReadByte();
				ZDOHelper.Init<Vector3>(ZDOExtraData.s_vec3, uid);
				for (int j = 0; j < b2; j++)
				{
					ZDOExtraData.Set(uid, pkg.ReadInt(), pkg.ReadVector3());
				}
			}
			if (((uint)num & 4u) != 0)
			{
				byte b3 = pkg.ReadByte();
				ZDOHelper.Init<Quaternion>(ZDOExtraData.s_quats, uid);
				for (int k = 0; k < b3; k++)
				{
					ZDOExtraData.Set(uid, pkg.ReadInt(), pkg.ReadQuaternion());
				}
			}
			if (((uint)num & 8u) != 0)
			{
				byte b4 = pkg.ReadByte();
				ZDOHelper.Init<int>(ZDOExtraData.s_ints, uid);
				for (int l = 0; l < b4; l++)
				{
					ZDOExtraData.Set(uid, pkg.ReadInt(), pkg.ReadInt());
				}
			}
			if (((uint)num & 0x40u) != 0)
			{
				byte b5 = pkg.ReadByte();
				ZDOHelper.Init<long>(ZDOExtraData.s_longs, uid);
				for (int m = 0; m < b5; m++)
				{
					ZDOExtraData.Set(uid, pkg.ReadInt(), pkg.ReadLong());
				}
			}
			if (((uint)num & 0x10u) != 0)
			{
				byte b6 = pkg.ReadByte();
				ZDOHelper.Init<string>(ZDOExtraData.s_strings, uid);
				for (int n = 0; n < b6; n++)
				{
					ZDOExtraData.Set(uid, pkg.ReadInt(), pkg.ReadString());
				}
			}
			if (((uint)num & 0x80u) != 0)
			{
				byte b7 = pkg.ReadByte();
				ZDOHelper.Init<byte[]>(ZDOExtraData.s_byteArrays, uid);
				for (int num2 = 0; num2 < b7; num2++)
				{
					ZDOExtraData.Set(uid, pkg.ReadInt(), pkg.ReadByteArray());
				}
			}
		}
	}
	public static class Hash
	{
		public static readonly int MaxAmount = StringExtensionMethods.GetStableHashCode("override_maximum_amount");

		public static readonly int Spawn = StringExtensionMethods.GetStableHashCode("override_spawn");

		public static readonly int Command = StringExtensionMethods.GetStableHashCode("override_command");

		public static readonly int Biome = StringExtensionMethods.GetStableHashCode("override_biome");

		public static readonly int Speed = StringExtensionMethods.GetStableHashCode("override_speed");

		public static readonly int MaxCover = StringExtensionMethods.GetStableHashCode("override_maximum_cover");

		public static readonly int SpawnCondition = StringExtensionMethods.GetStableHashCode("override_spawn_condition");

		public static readonly int CoverOffset = StringExtensionMethods.GetStableHashCode("override_cover_offset");

		public static readonly int SpawnOffset = StringExtensionMethods.GetStableHashCode("override_spawn_offset");

		public static readonly int SpawnEffect = StringExtensionMethods.GetStableHashCode("override_spawn_effect");

		public static readonly int TextBiome = StringExtensionMethods.GetStableHashCode("override_text_biome");

		public static readonly int TextSpace = StringExtensionMethods.GetStableHashCode("override_text_space");

		public static readonly int TextSleep = StringExtensionMethods.GetStableHashCode("override_text_sleep");

		public static readonly int TextHappy = StringExtensionMethods.GetStableHashCode("override_text_happy");

		public static readonly int TextCheck = StringExtensionMethods.GetStableHashCode("override_text_check");

		public static readonly int TextExtract = StringExtensionMethods.GetStableHashCode("override_text_extract");

		public static readonly int Name = StringExtensionMethods.GetStableHashCode("override_name");

		public static readonly int FactionLegacy = StringExtensionMethods.GetStableHashCode("override_faction");

		public static readonly int Faction = StringExtensionMethods.GetStableHashCode("faction");

		public static readonly int Boss = StringExtensionMethods.GetStableHashCode("override_boss");

		public static readonly int Resistances = StringExtensionMethods.GetStableHashCode("override_resistances");

		public static readonly int Items = StringExtensionMethods.GetStableHashCode("override_items");

		public static readonly int Attacks = StringExtensionMethods.GetStableHashCode("override_attacks");

		public static readonly int Component = StringExtensionMethods.GetStableHashCode("override_component");

		public static readonly int MinAmount = StringExtensionMethods.GetStableHashCode("override_minimum_amount");

		public static readonly int Respawn = StringExtensionMethods.GetStableHashCode("override_respawn");

		public static readonly int Changed = StringExtensionMethods.GetStableHashCode("override_changed");

		public static readonly int MinLevel = StringExtensionMethods.GetStableHashCode("override_minimum_level");

		public static readonly int MaxLevel = StringExtensionMethods.GetStableHashCode("override_maximum_level");

		public static readonly int TriggerDistance = StringExtensionMethods.GetStableHashCode("override_trigger_distance");

		public static readonly int TriggerNoise = StringExtensionMethods.GetStableHashCode("override_trigger_noise");

		public static readonly int LevelChance = StringExtensionMethods.GetStableHashCode("override_level_chance");

		public static readonly int Health = StringExtensionMethods.GetStableHashCode("override_health");

		public static readonly int Data = StringExtensionMethods.GetStableHashCode("override_data");

		public static readonly int Conversion = StringExtensionMethods.GetStableHashCode("override_conversion");

		public static readonly int InputEffect = StringExtensionMethods.GetStableHashCode("override_input_effect");

		public static readonly int UseEffect = StringExtensionMethods.GetStableHashCode("override_use_effect");

		public static readonly int OutputEffect = StringExtensionMethods.GetStableHashCode("override_output_effect");

		public static readonly int Item = StringExtensionMethods.GetStableHashCode("override_item");

		public static readonly int SpawnItem = StringExtensionMethods.GetStableHashCode("override_spawn_item");

		public static readonly int Amount = StringExtensionMethods.GetStableHashCode("override_amount");

		public static readonly int StartEffect = StringExtensionMethods.GetStableHashCode("override_start_effect");

		public static readonly int Text = StringExtensionMethods.GetStableHashCode("override_text");

		public static readonly int Delay = StringExtensionMethods.GetStableHashCode("override_delay");

		public static readonly int ItemOffset = StringExtensionMethods.GetStableHashCode("override_item_offset");

		public static readonly int SpawnMaxY = StringExtensionMethods.GetStableHashCode("override_spawn_max_y");

		public static readonly int SpawnRadius = StringExtensionMethods.GetStableHashCode("override_spawn_radius");

		public static readonly int ItemStandPrefix = StringExtensionMethods.GetStableHashCode("override_item_stand_prefix");

		public static readonly int ItemStandRange = StringExtensionMethods.GetStableHashCode("override_item_stand_range");

		public static readonly int SpawnTime = StringExtensionMethods.GetStableHashCode("spawn_time");

		public static readonly int PickableSpawn = StringExtensionMethods.GetStableHashCode("override_pickable_spawn");

		public static readonly int PickableRespawn = StringExtensionMethods.GetStableHashCode("override_pickable_respawn");

		public static readonly int RequiredGlobalKey = StringExtensionMethods.GetStableHashCode("override_required_globalkey");

		public static readonly int ForbiddenGlobalKey = StringExtensionMethods.GetStableHashCode("override_forbidden_globalkey");

		public static readonly int MaxFuel = StringExtensionMethods.GetStableHashCode("override_maximum_fuel");

		public static readonly int Fuel = StringExtensionMethods.GetStableHashCode("override_fuel");

		public static readonly int FuelUsage = StringExtensionMethods.GetStableHashCode("override_fuel_usage");

		public static readonly int FuelEffect = StringExtensionMethods.GetStableHashCode("override_fuel_effect");

		public static readonly int SpawnAreaSpawn = StringExtensionMethods.GetStableHashCode("override_spawnarea_spawn");

		public static readonly int SpawnAreaRespawn = StringExtensionMethods.GetStableHashCode("override_spawnarea_respawn");

		public static readonly int MaxNear = StringExtensionMethods.GetStableHashCode("override_max_near");

		public static readonly int MaxTotal = StringExtensionMethods.GetStableHashCode("override_max_total");

		public static readonly int NearRadius = StringExtensionMethods.GetStableHashCode("override_near_radius");

		public static readonly int FarRadius = StringExtensionMethods.GetStableHashCode("override_far_radius");
	}
	public class Helper
	{
		public static float Float(string arg, float defaultValue)
		{
			if (!float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return defaultValue;
			}
			return result;
		}

		public static float? Float(string arg)
		{
			if (!float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return null;
			}
			return result;
		}

		public static int Int(string arg, int defaultValue)
		{
			if (!int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return defaultValue;
			}
			return result;
		}

		public static int? Int(string arg)
		{
			if (!int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return null;
			}
			return result;
		}

		public static GameObject? GetPrefab(string hashStr)
		{
			if (int.TryParse(hashStr, out var result))
			{
				return GetPrefab(result);
			}
			return GetPrefab(StringExtensionMethods.GetStableHashCode(hashStr));
		}

		public static ItemDrop? GetItem(string hashStr)
		{
			if (int.TryParse(hashStr, out var result))
			{
				return GetItem(result);
			}
			return GetItem(StringExtensionMethods.GetStableHashCode(hashStr));
		}

		public static ItemDrop? GetItem(int hash)
		{
			GameObject? prefab = GetPrefab(hash);
			if (prefab == null)
			{
				return null;
			}
			return prefab.GetComponent<ItemDrop>();
		}

		public static GameObject? GetAttack(string hashStr)
		{
			if (int.TryParse(hashStr, out var result))
			{
				return GetAttack(result);
			}
			return GetAttack(StringExtensionMethods.GetStableHashCode(hashStr));
		}

		public static GameObject GetAttack(int hash)
		{
			return ObjectDB.instance.GetItemPrefab(hash);
		}

		public static GameObject? GetPrefab(int hash)
		{
			if (hash == 0)
			{
				return null;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(hash);
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				return null;
			}
			return prefab;
		}

		public static EffectData? ParseEffect(string data)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			string[] array = data.Split(new char[1] { ',' });
			EffectData val = new EffectData
			{
				m_prefab = GetPrefab(array[0])
			};
			if ((Object)(object)val.m_prefab == (Object)null)
			{
				return null;
			}
			if (array.Length > 1 && int.TryParse(array[1], out var result))
			{
				val.m_randomRotation = (result & 1) > 0;
				val.m_inheritParentRotation = (result & 2) > 0;
				val.m_scale = (result & 4) > 0;
				val.m_inheritParentScale = (result & 8) > 0;
				val.m_attach = (result & 0x10) > 0;
			}
			if (array.Length > 2 && int.TryParse(array[2], out var result2))
			{
				val.m_variant = result2;
			}
			if (array.Length > 3)
			{
				val.m_childTransform = array[3];
			}
			return val;
		}

		public static DamageModifiers ParseDamageModifiers(string data)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0057: Invalid comparison between Unknown and I4
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			//IL_005b: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Invalid comparison between Unknown and I4
			//IL_0069: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Invalid comparison between Unknown and I4
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Invalid comparison between Unknown and I4
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00c4: Invalid comparison between Unknown and I4
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Invalid comparison between Unknown and I4
			//IL_00c8: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Invalid comparison between Unknown and I4
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			DamageModifiers result = default(DamageModifiers);
			string[] array = data.Split(new char[1] { '|' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { ',' });
				if (array2.Length >= 2)
				{
					DamageType val = (DamageType)Int(array2[0], 0);
					DamageModifier val2 = (DamageModifier)Int(array2[1], 0);
					if ((int)val == 1)
					{
						result.m_blunt = val2;
					}
					if ((int)val == 8)
					{
						result.m_chop = val2;
					}
					if ((int)val == 32)
					{
						result.m_fire = val2;
					}
					if ((int)val == 64)
					{
						result.m_frost = val2;
					}
					if ((int)val == 128)
					{
						result.m_lightning = val2;
					}
					if ((int)val == 16)
					{
						result.m_pickaxe = val2;
					}
					if ((int)val == 4)
					{
						result.m_pierce = val2;
					}
					if ((int)val == 256)
					{
						result.m_poison = val2;
					}
					if ((int)val == 2)
					{
						result.m_slash = val2;
					}
					if ((int)val == 512)
					{
						result.m_spirit = val2;
					}
				}
			}
			return result;
		}

		public static EffectList ParseEffects(string data)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			IEnumerable<EffectData> source = from effect in data.Split(new char[1] { '|' })
				select ParseEffect(effect) into effect
				where effect != null
				select effect;
			return new EffectList
			{
				m_effectPrefabs = source.ToArray()
			};
		}

		public static ItemConversion? ParseSmelterConversion(string data)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			string[] array = data.Split(new char[1] { ',' });
			if (array.Length != 2)
			{
				return null;
			}
			return new ItemConversion
			{
				m_from = GetItem(array[0]),
				m_to = GetItem(array[1])
			};
		}

		public static ItemConversion? ParseFermenterConversion(string data)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			string[] array = data.Split(new char[1] { ',' });
			if (array.Length < 2)
			{
				return null;
			}
			return new ItemConversion
			{
				m_from = GetItem(array[0]),
				m_to = GetItem(array[1]),
				m_producedItems = ((array.Length <= 2) ? 1 : Int(array[2], 1))
			};
		}

		public static List<ItemConversion> ParseSmelterConversions(string data)
		{
			return (from conversion in data.Split(new char[1] { '|' })
				select ParseSmelterConversion(conversion) into conversion
				where conversion != null
				select conversion).ToList();
		}

		public static List<ItemConversion> ParseFermenterConversions(string data)
		{
			return (from conversion in data.Split(new char[1] { '|' })
				select ParseFermenterConversion(conversion) into conversion
				where conversion != null
				select conversion).ToList();
		}

		public static SpawnData? ParseSpawnData(string data)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			string[] array = data.Split(new char[1] { ',' });
			SpawnData val = new SpawnData
			{
				m_prefab = GetPrefab(array[0])
			};
			if ((Object)(object)val.m_prefab == (Object)null)
			{
				return null;
			}
			val.m_weight = 1f;
			val.m_minLevel = 1;
			val.m_maxLevel = 1;
			if (array.Length > 1)
			{
				val.m_weight = Float(array[1], 1f);
			}
			if (array.Length > 2)
			{
				val.m_minLevel = Int(array[2], 1);
				val.m_maxLevel = Int(array[2], 1);
			}
			if (array.Length > 3)
			{
				val.m_maxLevel = Int(array[3], 1);
			}
			return val;
		}

		public static List<SpawnData> ParseSpawnsData(string data)
		{
			return (from spawn in data.Split(new char[1] { '|' })
				select ParseSpawnData(spawn) into spawn
				where spawn != null
				select spawn).ToList();
		}

		public static DropData ParseDropData(string data)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			string[] array = data.Split(new char[1] { ',' });
			DropData val = default(DropData);
			val.m_item = GetPrefab(array[0]);
			val.m_weight = 1f;
			val.m_stackMin = 1;
			val.m_stackMax = 1;
			DropData result = val;
			if (array.Length > 1)
			{
				result.m_weight = Float(array[1], 1f);
			}
			if (array.Length > 2)
			{
				result.m_stackMin = Int(array[2], 1);
				result.m_stackMax = Int(array[2], 1);
			}
			if (array.Length > 3)
			{
				result.m_stackMax = Int(array[3], 1);
			}
			return result;
		}

		public static Drop ParseCharacterDropData(string data)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_003f: Expected O, but got Unknown
			string[] array = data.Split(new char[1] { ',' });
			Drop val = new Drop
			{
				m_prefab = GetPrefab(array[0]),
				m_chance = 1f,
				m_amountMin = 1,
				m_amountMax = 1
			};
			if (array.Length > 1)
			{
				val.m_chance = Float(array[1], 1f);
			}
			if (array.Length > 2)
			{
				val.m_amountMin = Int(array[2], 1);
				val.m_amountMax = Int(array[2], 1) + 1;
			}
			if (array.Length > 3)
			{
				val.m_amountMax = Int(array[3], 1) + 1;
			}
			if (array.Length > 4)
			{
				val.m_levelMultiplier = (Int(array[4], 0) & 1) > 0;
				val.m_onePerPlayer = (Int(array[4], 0) & 2) > 0;
			}
			return val;
		}

		public static List<DropData> ParseDropsData(string data)
		{
			return (from drop in data.Split(new char[1] { '|' }).Select(ParseDropData)
				where (Object)(object)drop.m_item != (Object)null
				select drop).ToList();
		}

		public static List<Drop> ParseCharacterDropsData(string data)
		{
			return (from drop in data.Split(new char[1] { '|' }).Select(ParseCharacterDropData)
				where (Object)(object)drop.m_prefab != (Object)null
				select drop).ToList();
		}

		public static ItemSet ParseItemSet(string data)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			ItemSet val = new ItemSet();
			val.m_name = "";
			val.m_items = (from item in data.Split(new char[1] { ',' }).Select(GetAttack)
				where Object.op_Implicit((Object)(object)item)
				select item).ToArray();
			return val;
		}

		public static ItemSet[] ParseCharacterItemSets(string data)
		{
			return (from set in data.Split(new char[1] { '|' }).Select(ParseItemSet)
				where set.m_items.Length != 0
				select set).ToArray();
		}

		public static bool Float(ZNetView view, int hash, Action<float> action)
		{
			if ((Object)(object)view == (Object)null || !view.IsValid())
			{
				return false;
			}
			float @float = view.GetZDO().GetFloat(hash, 0f);
			if (@float == 0f)
			{
				return false;
			}
			action(@float);
			return true;
		}

		public static void Float(ZNetView view, int hash, int legagyHash, Action<float> action)
		{
			if (!Float(view, hash, action))
			{
				Float(view, legagyHash, action);
			}
		}

		public static void Long(ZNetView view, int hash, Action<long> action)
		{
			if (!((Object)(object)view == (Object)null) && view.IsValid())
			{
				long @long = view.GetZDO().GetLong(hash, 0L);
				if (@long != 0L)
				{
					action(@long);
				}
			}
		}

		public static void Int(ZNetView view, int hash, Action<int> action)
		{
			if (!((Object)(object)view == (Object)null) && view.IsValid())
			{
				int @int = view.GetZDO().GetInt(hash, 0);
				if (@int != 0)
				{
					action(@int);
				}
			}
		}

		public static void Bool(ZNetView view, int hash, Action action)
		{
			if (!((Object)(object)view == (Object)null) && view.IsValid() && view.GetZDO().GetBool(hash, false))
			{
				action();
			}
		}

		public static bool String(ZNetView view, int hash, Action<string> action)
		{
			if ((Object)(object)view == (Object)null || !view.IsValid())
			{
				return false;
			}
			string @string = view.GetZDO().GetString(hash, "");
			if (@string == "")
			{
				return false;
			}
			action(@string);
			return true;
		}

		public static bool HashList(ZNetView view, int hash, Action<int[]> action)
		{
			if ((Object)(object)view == (Object)null || !view.IsValid())
			{
				return false;
			}
			string @string = view.GetZDO().GetString(hash, "");
			if (@string == "")
			{
				return false;
			}
			int[] obj = (from s in @string.Split(new char[1] { ',' })
				select StringExtensionMethods.GetStableHashCode(s)).ToArray();
			action(obj);
			return true;
		}

		public static void String(ZNetView view, int hash, int legacyHash, Action<string> action)
		{
			if (!String(view, hash, action))
			{
				String(view, legacyHash, action);
			}
		}

		public static bool Prefab(ZNetView view, int hash, Action<GameObject> action)
		{
			if ((Object)(object)view == (Object)null || !view.IsValid())
			{
				return false;
			}
			int num = view.GetZDO().GetInt(hash, 0);
			if (num == 0)
			{
				num = StringExtensionMethods.GetStableHashCode(view.GetZDO().GetString(hash, ""));
			}
			GameObject prefab = GetPrefab(num);
			if ((Object)(object)prefab == (Object)null)
			{
				return false;
			}
			action(prefab);
			return true;
		}

		public static void Prefab(ZNetView view, int hash, int legacyHash, Action<GameObject> action)
		{
			if (!Prefab(view, hash, action))
			{
				Prefab(view, legacyHash, action);
			}
		}

		public static void Item(ZNetView view, int hash, Action<ItemDrop> action)
		{
			if (!((Object)(object)view == (Object)null) && view.IsValid())
			{
				int num = view.GetZDO().GetInt(hash, 0);
				if (num == 0)
				{
					num = StringExtensionMethods.GetStableHashCode(view.GetZDO().GetString(hash, ""));
				}
				ItemDrop item = GetItem(num);
				if (!((Object)(object)item == (Object)null))
				{
					action(item);
				}
			}
		}

		public static void Offset(ZNetView view, int hash, Transform initial, Action<Transform> action)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			Transform initial2 = initial;
			if (!Object.op_Implicit((Object)(object)initial2))
			{
				GameObject val = new GameObject();
				val.transform.parent = ((Component)view).transform;
				val.transform.localPosition = Vector3.zero;
				val.transform.localRotation = Quaternion.identity;
				initial2 = val.transform;
			}
			String(view, hash, delegate(string value)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: 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_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: 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)
				string[] array = value.Split(new char[1] { ',' });
				Vector3 localPosition = initial2.localPosition;
				localPosition.x = Float(array[0], localPosition.x);
				if (array.Length > 1)
				{
					localPosition.z = Float(array[1], localPosition.z);
				}
				if (array.Length > 2)
				{
					localPosition.y = Float(array[2], localPosition.y);
				}
				initial2.localPosition = localPosition;
			});
			action(initial2);
		}

		public static int RollLevel(int min, int max, float chance)
		{
			int i;
			for (i = min; i < max; i++)
			{
				if (!(Random.Range(0f, 100f) <= chance))
				{
					break;
				}
			}
			return i;
		}

		public static bool Owner(ZNetView view)
		{
			if (Object.op_Implicit((Object)(object)view) && view.IsValid())
			{
				return view.IsOwner();
			}
			return false;
		}
	}
}
namespace SpawnerTweaks
{
	[HarmonyPatch(typeof(Beehive))]
	public class BeehivePatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Setup(Beehive __instance)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			if (!Configuration.configBeehive.Value)
			{
				return;
			}
			Beehive obj = __instance;
			ZNetView nview = obj.m_nview;
			if (Object.op_Implicit((Object)(object)nview) && nview.IsValid())
			{
				if (!Object.op_Implicit((Object)(object)__instance.m_beeEffect))
				{
					__instance.m_beeEffect = new GameObject();
				}
				Helper.Int(nview, Hash.MaxAmount, delegate(int value)
				{
					obj.m_maxHoney = value;
				});
				Helper.Int(nview, Hash.Biome, delegate(int value)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					obj.m_biome = (Biome)value;
				});
				Helper.Int(nview, Hash.SpawnCondition, delegate(int value)
				{
					obj.m_effectOnlyInDaylight = value != 1;
				});
				Helper.Item(nview, Hash.Spawn, delegate(ItemDrop value)
				{
					obj.m_honeyItem = value;
				});
				Helper.Float(nview, Hash.Speed, delegate(float value)
				{
					obj.m_secPerUnit = value;
				});
				Helper.Float(nview, Hash.MaxCover, delegate(float value)
				{
					obj.m_maxCover = value;
				});
				Helper.Offset(nview, Hash.CoverOffset, obj.m_coverPoint, delegate(Transform value)
				{
					obj.m_coverPoint = value;
				});
				Helper.Offset(nview, Hash.SpawnOffset, obj.m_spawnPoint, delegate(Transform value)
				{
					obj.m_spawnPoint = value;
				});
				Helper.String(nview, Hash.TextBiome, delegate(string value)
				{
					obj.m_areaText = value;
				});
				Helper.String(nview, Hash.TextSpace, delegate(string value)
				{
					obj.m_freespaceText = value;
				});
				Helper.String(nview, Hash.TextSleep, delegate(string value)
				{
					obj.m_sleepText = value;
				});
				Helper.String(nview, Hash.TextHappy, delegate(string value)
				{
					obj.m_happyText = value;
				});
				Helper.String(nview, Hash.TextCheck, delegate(string value)
				{
					obj.m_checkText = value;
				});
				Helper.String(nview, Hash.TextExtract, delegate(string value)
				{
					obj.m_extractText = value;
				});
				Helper.String(nview, Hash.Name, delegate(string value)
				{
					obj.m_name = value;
				});
			}
		}
	}
	[HarmonyPatch(typeof(Character))]
	public class CharacterPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Setup(Character __instance)
		{
			Character __instance2 = __instance;
			if (!Configuration.configCharacter.Value)
			{
				return;
			}
			Helper.String(__instance2.m_nview, Hash.Faction, Hash.FactionLegacy, delegate(string value)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (Enum.TryParse<Faction>(value, ignoreCase: true, out Faction result))
				{
					__instance2.m_faction = result;
				}
			});
			Helper.Int(__instance2.m_nview, Hash.Boss, delegate(int value)
			{
				__instance2.m_boss = value > 0;
			});
			Helper.String(__instance2.m_nview, Hash.Name, delegate(string value)
			{
				__instance2.m_name = value;
			});
			Helper.String(__instance2.m_nview, Hash.Resistances, delegate(string value)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				__instance2.m_damageModifiers = Helper.ParseDamageModifiers(value);
			});
			CharacterDrop drop = default(CharacterDrop);
			if (((Component)__instance2).TryGetComponent<CharacterDrop>(ref drop))
			{
				Helper.String(__instance2.m_nview, Hash.Items, delegate(string value)
				{
					drop.m_drops = Helper.ParseCharacterDropsData(value);
				});
			}
			Humanoid humanoid = default(Humanoid);
			if (!((Component)__instance2).TryGetComponent<Humanoid>(ref humanoid))
			{
				return;
			}
			Helper.String(__instance2.m_nview, Hash.Attacks, delegate(string value)
			{
				ItemSet[] array = Helper.ParseCharacterItemSets(value);
				if (array.Length != 0)
				{
					humanoid.m_randomWeapon = (GameObject[])(object)new GameObject[0];
					humanoid.m_randomShield = (GameObject[])(object)new GameObject[0];
					((Terminal)Console.instance).AddString($"SpawnerTweaks: {__instance2.m_name} has {array.Length} item sets");
					if (array.Length == 1)
					{
						humanoid.m_randomSets = (ItemSet[])(object)new ItemSet[0];
						humanoid.m_defaultItems = array[0].m_items;
					}
					else
					{
						humanoid.m_randomSets = array;
						humanoid.m_defaultItems = (GameObject[])(object)new GameObject[0];
					}
				}
			});
		}

		[HarmonyPatch("Awake")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DisableMaxHealthSetup(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Character), "SetupMaxHealth", (Type[])null, (Type[])null), (string)null)
			}).Set(OpCodes.Call, Transpilers.EmitDelegate<Action<Character>>((Action<Character>)delegate
			{
			}).operand).InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(ZNetView))]
	public class ComponentPatches
	{
		private static void AddComponent<T>(ZNetView view) where T : MonoBehaviour
		{
			Interactable component = ((Component)view).GetComponent<Interactable>();
			Object.Destroy((Object)(object)((component is MonoBehaviour) ? component : null));
			((Component)view).gameObject.AddComponent<T>();
		}

		private static void HandleComponent(ZNetView view)
		{
			string text = view.GetZDO().GetString(Hash.Component, "").ToLower();
			if (text == "")
			{
				return;
			}
			string[] array = text.Split(new char[1] { ',' });
			foreach (string obj in array)
			{
				if (obj == "altar" && !Object.op_Implicit((Object)(object)((Component)view).gameObject.GetComponent<OfferingBowl>()))
				{
					AddComponent<OfferingBowl>(view);
				}
				if (obj == "pickable" && !Object.op_Implicit((Object)(object)((Component)view).gameObject.GetComponent<Pickable>()))
				{
					AddComponent<Pickable>(view);
				}
				if (obj == "spawnpoint" && !Object.op_Implicit((Object)(object)((Component)view).gameObject.GetComponent<CreatureSpawner>()))
				{
					((Component)view).gameObject.AddComponent<CreatureSpawner>();
				}
				if (obj == "spawner" && !Object.op_Implicit((Object)(object)((Component)view).gameObject.GetComponent<SpawnArea>()))
				{
					((Component)view).gameObject.AddComponent<SpawnArea>();
				}
				if (obj == "chest" && !Object.op_Implicit((Object)(object)((Component)view).gameObject.GetComponent<Container>()))
				{
					AddComponent<Container>(view);
				}
				if (obj == "itemstand" && !Object.op_Implicit((Object)(object)((Component)view).gameObject.GetComponent<ItemStand>()))
				{
					AddComponent<ItemStand>(view);
				}
				if (obj == "beehive" && !Object.op_Implicit((Object)(object)((Component)view).gameObject.GetComponent<Beehive>()))
				{
					AddComponent<Beehive>(view);
				}
			}
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Setup(ZNetView __instance)
		{
			if (Configuration.configComponent.Value && Object.op_Implicit((Object)(object)__instance) && __instance.IsValid())
			{
				HandleComponent(__instance);
			}
		}
	}
	public class Configuration
	{
		public static ConfigEntry<bool> configOfferingBowl;

		public static ConfigEntry<bool> configComponent;

		public static ConfigEntry<bool> configPickable;

		public static ConfigEntry<bool> configContainer;

		public static ConfigEntry<bool> configItemStand;

		public static ConfigEntry<bool> configSpawnArea;

		public static ConfigEntry<bool> configCharacter;

		public static ConfigEntry<bool> configCreatureSpawner;

		public static ConfigEntry<bool> configSmelter;

		public static ConfigEntry<bool> configBeehive;

		public static ConfigEntry<bool> configFermenter;

		public static ConfigEntry<bool> configNoCreatureSpawnerSuppression;

		public static ConfigEntry<bool> configNoCreatureRespawnerSuppression;

		public static void Init(ConfigWrapper wrapper)
		{
			string group = "1. General";
			configNoCreatureSpawnerSuppression = wrapper.Bind(group, "No spawn point suppression (one time)", value: false, "One time spawn points can't be suppressed with player base (even when configured to respawn).");
			configNoCreatureSpawnerSuppression.SettingChanged += delegate
			{
				NoSuppression.Update();
			};
			configNoCreatureRespawnerSuppression = wrapper.Bind(group, "No spawn point suppression (respawning)", value: false, "Respawning spawn points can't be suppressed with player base (even when configured to one time).");
			configNoCreatureRespawnerSuppression.SettingChanged += delegate
			{
				NoSuppression.Update();
			};
			configCreatureSpawner = wrapper.Bind(group, "Spawn points", value: true, "Spawn point properties can be overridden.");
			configSmelter = wrapper.Bind(group, "Smelters", value: true, "Smelter properties can be overridden.");
			configBeehive = wrapper.Bind(group, "Beehives", value: true, "Beehive properties can be overridden.");
			configFermenter = wrapper.Bind(group, "Fermenters", value: true, "Fermenter properties can be overridden.");
			configComponent = wrapper.Bind(group, "Components", value: true, "Altars, pickables, spawners, etc. can be attached to any object.");
			configPickable = wrapper.Bind(group, "Pickables", value: true, "Pickable properties can be overridden.");
			configCharacter = wrapper.Bind(group, "Creatures", value: true, "Creature properties can be overridden.");
			configContainer = wrapper.Bind(group, "Chests", value: true, "Chest properties can be overridden.");
			configItemStand = wrapper.Bind(group, "Item stands", value: true, "Item stand properties can be overridden.");
			configSpawnArea = wrapper.Bind(group, "Spawners", value: true, "Spawner properties can be overridden.");
			configOfferingBowl = wrapper.Bind(group, "Boss altars", value: true, "Boss altar properties can be overridden.");
		}
	}
	[HarmonyPatch(typeof(Container))]
	public class ContainerPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Setup(Container __instance)
		{
			Container __instance2 = __instance;
			if (Configuration.configContainer.Value)
			{
				Helper.String(__instance2.m_nview, Hash.Name, delegate(string value)
				{
					__instance2.m_name = value;
				});
			}
		}

		[HarmonyPatch("AddDefaultItems")]
		[HarmonyPrefix]
		private static void ReplaceDefaultItems(Container __instance)
		{
			if (Configuration.configContainer.Value)
			{
				Container obj = __instance;
				Helper.Int(obj.m_nview, Hash.MinAmount, delegate(int value)
				{
					obj.m_defaultItems.m_dropMin = value;
				});
				Helper.Int(obj.m_nview, Hash.MaxAmount, delegate(int value)
				{
					obj.m_defaultItems.m_dropMax = value;
				});
				Helper.String(obj.m_nview, Hash.Items, delegate(string value)
				{
					obj.m_defaultItems.m_drops = Helper.ParseDropsData(value);
					obj.m_defaultItems.m_oneOfEach = true;
				});
			}
		}

		[HarmonyPatch("CheckForChanges")]
		[HarmonyPostfix]
		private static void RespawnItems(Container __instance)
		{
			if (!Configuration.configContainer.Value)
			{
				return;
			}
			Container obj = __instance;
			if (!Helper.Owner(__instance.m_nview))
			{
				return;
			}
			bool respawnContents = false;
			Helper.Float(obj.m_nview, Hash.Respawn, delegate(float respawn)
			{
				respawnContents = true;
				Helper.Long(obj.m_nview, Hash.Changed, delegate(long changed)
				{
					DateTime dateTime = new DateTime(changed);
					respawnContents = (ZNet.instance.GetTime() - dateTime).TotalMinutes >= (double)respawn;
				});
			});
			if (respawnContents)
			{
				ZDO zDO = obj.m_nview.GetZDO();
				int changed2 = Hash.Changed;
				DateTime maxValue = DateTime.MaxValue;
				zDO.Set(changed2, maxValue.Ticks / 2);
				obj.m_nview.GetZDO().Set(ZDOVars.s_addedDefaultItems, false);
				obj.m_inventory.RemoveAll();
				obj.AddDefaultItems();
				obj.m_nview.GetZDO().Set(ZDOVars.s_addedDefaultItems, true);
			}
		}

		[HarmonyPatch("OnContainerChanged")]
		[HarmonyPostfix]
		private static void TriggerRespawn(Container __instance)
		{
			Container __instance2 = __instance;
			if (__instance2.m_loading || !Configuration.configContainer.Value)
			{
				return;
			}
			Helper.Bool(__instance2.m_nview, ZDOVars.s_addedDefaultItems, delegate
			{
				Helper.Float(__instance2.m_nview, Hash.Respawn, delegate
				{
					__instance2.m_nview.GetZDO().Set(Hash.Changed, ZNet.instance.GetTime().Ticks);
				});
			});
		}
	}
	[HarmonyPatch(typeof(CreatureSpawner))]
	public class CreatureSpawnerPatches
	{
		private static ZPackage? SpawnData;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		[HarmonyPriority(300)]
		private static void Setup(CreatureSpawner __instance)
		{
			if (!Configuration.configCreatureSpawner.Value)
			{
				return;
			}
			CreatureSpawner obj = __instance;
			ZNetView nview = obj.m_nview;
			if (!Object.op_Implicit((Object)(object)nview) || !nview.IsValid())
			{
				return;
			}
			Helper.Float(nview, Hash.Respawn, delegate(float value)
			{
				obj.m_respawnTimeMinuts = value;
			});
			Helper.Prefab(nview, Hash.Spawn, delegate(GameObject value)
			{
				obj.m_creaturePrefab = value;
			});
			Helper.Int(nview, Hash.MaxLevel, delegate(int value)
			{
				obj.m_maxLevel = value;
			});
			Helper.Int(nview, Hash.MinLevel, delegate(int value)
			{
				obj.m_minLevel = value;
			});
			Helper.Int(nview, Hash.SpawnCondition, delegate(int value)
			{
				obj.m_spawnAtNight = true;
				obj.m_spawnAtDay = true;
				if (value == 1)
				{
					obj.m_spawnAtNight = false;
				}
				if (value == 2)
				{
					obj.m_spawnAtDay = false;
				}
			});
			Helper.Float(nview, Hash.TriggerDistance, delegate(float value)
			{
				obj.m_triggerDistance = value;
			});
			Helper.Float(nview, Hash.TriggerNoise, delegate(float value)
			{
				obj.m_triggerNoise = value;
			});
			Helper.Float(nview, Hash.LevelChance, delegate(float value)
			{
				obj.m_levelupChance = value;
			});
			Helper.String(nview, Hash.SpawnEffect, delegate(string value)
			{
				obj.m_spawnEffects = Helper.ParseEffects(value);
			});
		}

		[HarmonyPatch("Spawn")]
		[HarmonyPrefix]
		private static void GetValues(CreatureSpawner __instance)
		{
			SpawnData = null;
			Helper.String(__instance.m_nview, Hash.Data, delegate(string value)
			{
				SpawnData = DataHelper.Deserialize(value);
			});
		}

		[HarmonyPatch("Spawn")]
		[HarmonyPostfix]
		private static void SetupSpawn(CreatureSpawner __instance, ZNetView __result)
		{
			if (!Configuration.configCreatureSpawner.Value || !Object.op_Implicit((Object)(object)__result))
			{
				return;
			}
			Character obj = ((Component)__result).GetComponent<Character>();
			if (!Object.op_Implicit((Object)(object)obj))
			{
				return;
			}
			OverrideLevel(__instance, obj);
			ZNetView nview = __instance.m_nview;
			Helper.Float(nview, Hash.Health, (Action<float>)obj.SetMaxHealth);
			Helper.String(nview, Hash.Faction, Hash.FactionLegacy, delegate(string value)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				obj.m_nview.GetZDO().Set(Hash.Faction, value);
				if (Enum.TryParse<Faction>(value, ignoreCase: true, out Faction result))
				{
					obj.m_faction = result;
				}
			});
		}

		private static void OverrideLevel(CreatureSpawner spawner, Character obj)
		{
			ZNetView nview = spawner.m_nview;
			bool setupLevel = false;
			Helper.Int(nview, Hash.MaxLevel, delegate
			{
				setupLevel = true;
			});
			if (!setupLevel)
			{
				Helper.Int(nview, Hash.MinLevel, delegate
				{
					setupLevel = true;
				});
			}
			if (!setupLevel)
			{
				Helper.Float(nview, Hash.LevelChance, delegate
				{
					setupLevel = true;
				});
			}
			if (setupLevel)
			{
				obj.SetLevel(Helper.RollLevel(spawner.m_minLevel, spawner.m_maxLevel, spawner.m_levelupChance));
			}
		}

		private static GameObject Instantiate(GameObject prefab, Vector3 position, Quaternion rotation)
		{
			//IL_0015: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (SpawnData != null)
			{
				DataHelper.InitZDO(prefab, position, rotation, SpawnData);
			}
			return Object.Instantiate<GameObject>(prefab, position, rotation);
		}

		[HarmonyPatch("Spawn")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SetupData(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(CreatureSpawner), "m_creaturePrefab"), (string)null)
			}).Advance(3).Set(OpCodes.Call, Transpilers.EmitDelegate<Func<GameObject, Vector3, Quaternion, GameObject>>((Func<GameObject, Vector3, Quaternion, GameObject>)Instantiate).operand)
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(CreatureSpawner), "UpdateSpawner")]
	public class CreatureSpawnerUpdateSpawner
	{
		private static void Prefix(CreatureSpawner __instance, ref float __state)
		{
			__state = 0f;
			if (__instance.m_respawnTimeMinuts != 0f && __instance.m_nview.GetZDO().GetConnection() == null)
			{
				__state = __instance.m_respawnTimeMinuts;
				__instance.m_respawnTimeMinuts = 0f;
			}
		}

		private static void Postfix(CreatureSpawner __instance, float __state)
		{
			if (__state != 0f)
			{
				__instance.m_respawnTimeMinuts = __state;
			}
		}
	}
	[HarmonyPatch(typeof(Fermenter))]
	public class FermenterPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Setup(Fermenter __instance)
		{
			if (!Configuration.configFermenter.Value)
			{
				return;
			}
			Fermenter obj = __instance;
			ZNetView nview = obj.m_nview;
			if (Object.op_Implicit((Object)(object)nview) && nview.IsValid())
			{
				Helper.Float(nview, Hash.Speed, delegate(float value)
				{
					obj.m_fermentationDuration = value;
				});
				Helper.String(nview, Hash.InputEffect, delegate(string value)
				{
					obj.m_addedEffects = Helper.ParseEffects(value);
				});
				Helper.String(nview, Hash.UseEffect, delegate(string value)
				{
					obj.m_tapEffects = Helper.ParseEffects(value);
				});
				Helper.String(nview, Hash.OutputEffect, delegate(string value)
				{
					obj.m_spawnEffects = Helper.ParseEffects(value);
				});
				Helper.String(nview, Hash.Conversion, delegate(string value)
				{
					obj.m_conversion = Helper.ParseFermenterConversions(value);
				});
			}
		}
	}
	[HarmonyPatch(typeof(ItemStand))]
	public class ItemStandPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Setup(ItemStand __instance)
		{
			ItemStand __instance2 = __instance;
			if (Configuration.configItemStand.Value)
			{
				Helper.String(__instance2.m_nview, Hash.Name, delegate(string value)
				{
					__instance2.m_name = value;
				});
			}
		}

		[HarmonyPatch("UpdateVisual")]
		[HarmonyPrefix]
		private static void RespawnItem(ItemStand __instance)
		{
			if (!Configuration.configItemStand.Value)
			{
				return;
			}
			ItemStand obj = __instance;
			ZNetView view = obj.m_nview;
			if (!Helper.Owner(view))
			{
				return;
			}
			bool respawnContents = false;
			Helper.Float(obj.m_nview, Hash.Respawn, delegate(float respawn)
			{
				respawnContents = true;
				Helper.Long(obj.m_nview, Hash.Changed, delegate(long changed)
				{
					DateTime dateTime = new DateTime(changed);
					respawnContents = (ZNet.instance.GetTime() - dateTime).TotalMinutes >= (double)respawn;
				});
			});
			if (!respawnContents)
			{
				return;
			}
			if (obj.HaveAttachment())
			{
				obj.DropItem();
			}
			ZDO zDO = view.GetZDO();
			int changed2 = Hash.Changed;
			DateTime maxValue = DateTime.MaxValue;
			zDO.Set(changed2, maxValue.Ticks / 2);
			Helper.String(view, Hash.Item, delegate(string value)
			{
				string[] array = value.Split(new char[1] { ',' });
				view.GetZDO().Set(ZDOVars.s_item, array[0]);
				if (array.Length > 1 && int.TryParse(array[1], out var result))
				{
					view.GetZDO().Set(ZDOVars.s_variant, result, false);
				}
				else
				{
					view.GetZDO().Set(ZDOVars.s_variant, 0, false);
				}
			});
		}

		[HarmonyPatch("DropItem")]
		[HarmonyPrefix]
		private static void TriggerRespawn(ItemStand __instance)
		{
			if (!Configuration.configItemStand.Value)
			{
				return;
			}
			ZNetView view = __instance.m_nview;
			if (Helper.Owner(view) && __instance.HaveAttachment())
			{
				Helper.Float(view, Hash.Respawn, delegate
				{
					view.GetZDO().Set(Hash.Changed, ZNet.instance.GetTime().Ticks);
				});
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	public class NoSuppression
	{
		private static readonly Dictionary<int, bool> Originals = new Dictionary<int, bool>();

		public static void Update()
		{
			Update(ZNetScene.instance);
		}

		public static void Update(int prefab, CreatureSpawner obj)
		{
			bool flag = obj.m_respawnTimeMinuts <= 0f;
			bool value;
			if (flag && Configuration.configNoCreatureSpawnerSuppression.Value)
			{
				obj.m_spawnInPlayerBase = true;
			}
			else if (!flag && Configuration.configNoCreatureRespawnerSuppression.Value)
			{
				obj.m_spawnInPlayerBase = true;
			}
			else if (Originals.TryGetValue(prefab, out value))
			{
				obj.m_spawnInPlayerBase = value;
			}
		}

		public static void Update(ZNetScene scene)
		{
			Dictionary<int, bool> dictionary = new Dictionary<int, bool>();
			foreach (KeyValuePair<int, GameObject> namedPrefab in scene.m_namedPrefabs)
			{
				CreatureSpawner component = namedPrefab.Value.GetComponent<CreatureSpawner>();
				if (component != null)
				{
					Update(namedPrefab.Key, component);
					dictionary[namedPrefab.Key] = component.m_spawnInPlayerBase;
				}
			}
			foreach (KeyValuePair<ZDO, ZNetView> instance in scene.m_instances)
			{
				int prefab = instance.Key.GetPrefab();
				if (dictionary.ContainsKey(prefab))
				{
					CreatureSpawner component2 = ((Component)instance.Value).GetComponent<CreatureSpawner>();
					if (component2 != null)
					{
						component2.m_spawnInPlayerBase = dictionary[prefab];
					}
				}
			}
		}

		[HarmonyPriority(0)]
		private static void Postfix(ZNetScene __instance)
		{
			foreach (KeyValuePair<int, GameObject> namedPrefab in __instance.m_namedPrefabs)
			{
				if (!Originals.ContainsKey(namedPrefab.Key))
				{
					CreatureSpawner component = namedPrefab.Value.GetComponent<CreatureSpawner>();
					if (component != null)
					{
						Originals[namedPrefab.Key] = component.m_spawnInPlayerBase;
					}
				}
			}
			Update(__instance);
		}
	}
	[HarmonyPatch(typeof(OfferingBowl))]
	public class OfferingBowlPatches
	{
		private static ZPackage? SpawnData;

		private static void SetSpawn(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Prefab(view, Hash.Spawn, delegate(GameObject value)
			{
				ItemDrop component = value.GetComponent<ItemDrop>();
				obj2.m_bossPrefab = null;
				obj2.m_itemPrefab = null;
				if (Object.op_Implicit((Object)(object)component))
				{
					obj2.m_itemPrefab = component;
				}
				else
				{
					obj2.m_bossPrefab = value;
				}
			});
		}

		private static void SetSpawnItem(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Prefab(view, Hash.SpawnItem, delegate(GameObject value)
			{
				ItemDrop component = value.GetComponent<ItemDrop>();
				if (Object.op_Implicit((Object)(object)component))
				{
					obj2.m_bossItem = component;
				}
			});
		}

		private static void SetAmount(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Int(view, Hash.Amount, delegate(int value)
			{
				obj2.m_bossItems = value;
				obj2.m_useItemStands = value < 0;
			});
		}

		private static void SetDelay(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Float(view, Hash.Delay, delegate(float value)
			{
				obj2.m_spawnBossDelay = value;
			});
		}

		private static void SetName(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.String(view, Hash.Name, delegate(string value)
			{
				obj2.m_name = value;
			});
		}

		private static void SetText(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.String(view, Hash.Text, delegate(string value)
			{
				obj2.m_useItemText = value;
			});
		}

		private static void SetItemStandPrefix(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.String(view, Hash.ItemStandPrefix, delegate(string value)
			{
				obj2.m_useItemStands = true;
				obj2.m_itemStandPrefix = value;
			});
		}

		private static void SetItemStandRange(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Float(view, Hash.ItemStandRange, delegate(float value)
			{
				obj2.m_useItemStands = true;
				obj2.m_itemstandMaxRange = value;
			});
		}

		private static void SetSpawnOffset(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Float(view, Hash.SpawnOffset, delegate(float value)
			{
				obj2.m_spawnYOffset = value;
			});
		}

		private static void SetSpawnRadius(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Float(view, Hash.SpawnRadius, delegate(float value)
			{
				obj2.m_spawnBossMaxDistance = value;
			});
		}

		private static void SetSpawnMaxY(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Float(view, Hash.SpawnMaxY, delegate(float value)
			{
				obj2.m_spawnBossMaxYDistance = value;
			});
		}

		private static void SetItemOffset(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.Offset(view, Hash.ItemOffset, obj2.m_itemSpawnPoint, delegate(Transform value)
			{
				obj2.m_itemSpawnPoint = value;
			});
		}

		private static void SetStartEffect(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.String(view, Hash.StartEffect, delegate(string value)
			{
				obj2.m_spawnBossStartEffects = Helper.ParseEffects(value);
			});
		}

		private static void SetSpawnEffect(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.String(view, Hash.SpawnEffect, delegate(string value)
			{
				obj2.m_spawnBossDoneffects = Helper.ParseEffects(value);
			});
		}

		private static void SetUseEffect(OfferingBowl obj, ZNetView view)
		{
			OfferingBowl obj2 = obj;
			Helper.String(view, Hash.UseEffect, delegate(string value)
			{
				obj2.m_fuelAddedEffects = Helper.ParseEffects(value);
			});
		}

		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		[HarmonyPriority(700)]
		public static void Setup(OfferingBowl __instance)
		{
			if (Configuration.configOfferingBowl.Value)
			{
				ZNetView componentInParent = ((Component)__instance).GetComponentInParent<ZNetView>();
				if (Object.op_Implicit((Object)(object)componentInParent) && componentInParent.IsValid())
				{
					SetSpawn(__instance, componentInParent);
					SetAmount(__instance, componentInParent);
					SetSpawnItem(__instance, componentInParent);
					SetName(__instance, componentInParent);
					SetText(__instance, componentInParent);
					SetItemStandPrefix(__instance, componentInParent);
					SetItemStandRange(__instance, componentInParent);
					SetDelay(__instance, componentInParent);
					SetItemOffset(__instance, componentInParent);
					SetSpawnRadius(__instance, componentInParent);
					SetSpawnMaxY(__instance, componentInParent);
					SetSpawnOffset(__instance, componentInParent);
					SetStartEffect(__instance, componentInParent);
					SetSpawnEffect(__instance, componentInParent);
					SetUseEffect(__instance, componentInParent);
				}
			}
		}

		public static bool CanRespawn(OfferingBowl obj)
		{
			if (!Configuration.configOfferingBowl.Value)
			{
				return true;
			}
			ZNetView view = ((Component)obj).GetComponentInParent<ZNetView>();
			bool ret = true;
			Helper.Float(view, Hash.Respawn, delegate(float respawn)
			{
				Helper.Long(view, Hash.SpawnTime, delegate(long spawnTime)
				{
					DateTime time = ZNet.instance.GetTime();
					DateTime dateTime = new DateTime(spawnTime);
					ret = respawn > 0f && (time - dateTime).TotalMinutes >= (double)respawn;
				});
			});
			return ret;
		}

		[HarmonyPatch("Interact")]
		[HarmonyPrefix]
		private static bool CheckBossRespawn(OfferingBowl __instance, bool hold, ref bool __result)
		{
			OfferingBowl __instance2 = __instance;
			if (!CanRespawn(__instance2))
			{
				return false;
			}
			if (hold || __instance2.IsBossSpawnQueued() || !__instance2.m_useItemStands)
			{
				return true;
			}
			if (Object.op_Implicit((Object)(object)__instance2.m_bossPrefab))
			{
				return true;
			}
			ZNetView componentInParent = ((Component)__instance2).GetComponentInParent<ZNetView>();
			bool result = false;
			Helper.String(componentInParent, Hash.Command, delegate(string value)
			{
				//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_0021: 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)
				Vector3 position = ((Component)__instance2).transform.position;
				Quaternion rotation = ((Component)__instance2).transform.rotation;
				ServerExecution.Send(value, position, ((Quaternion)(ref rotation)).eulerAngles);
				result = true;
			});
			__result = result;
			return false;
		}

		[HarmonyPatch("UseItem")]
		[HarmonyPrefix]
		private static bool CheckItemRespawn(OfferingBowl __instance)
		{
			return CanRespawn(__instance);
		}

		[HarmonyPatch("UseItem")]
		[HarmonyPostfix]
		private static bool UseItem(bool result, ItemData item, Humanoid user, OfferingBowl __instance)
		{
			Humanoid user2 = user;
			ItemData item2 = item;
			OfferingBowl __instance2 = __instance;
			if (!result)
			{
				return result;
			}
			OfferingBowl obj = __instance2;
			if (Object.op_Implicit((Object)(object)obj.m_bossPrefab) || Object.op_Implicit((Object)(object)obj.m_itemPrefab))
			{
				return result;
			}
			if (obj.IsBossSpawnQueued())
			{
				return result;
			}
			if (!Object.op_Implicit((Object)(object)obj.m_bossItem))
			{
				return result;
			}
			if (item2.m_shared.m_name != obj.m_bossItem.m_itemData.m_shared.m_name)
			{
				return result;
			}
			if (user2.GetInventory().CountItems(obj.m_bossItem.m_itemData.m_shared.m_name, -1, true) < obj.m_bossItems)
			{
				return result;
			}
			Helper.String(((Component)obj).GetComponentInParent<ZNetView>(), Hash.Command, delegate(string value)
			{
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: 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)
				user2.GetInventory().RemoveItem(item2.m_shared.m_name, obj.m_bossItems, -1, true);
				((Character)user2).ShowRemovedMessage(obj.m_bossItem.m_itemData, obj.m_bossItems);
				((Character)user2).Message((MessageType)2, "$msg_offerdone", 0, (Sprite)null);
				if (Object.op_Implicit((Object)(object)obj.m_itemSpawnPoint))
				{
					obj.m_fuelAddedEffects.Create(obj.m_itemSpawnPoint.position, ((Component)obj).transform.rotation, (Transform)null, 1f, -1);
				}
				Vector3 position = ((Component)__instance2).transform.position;
				Quaternion rotation = ((Component)__instance2).transform.rotation;
				ServerExecution.Send(value, position, ((Quaternion)(ref rotation)).eulerAngles);
			});
			return result;
		}

		[HarmonyPatch("SpawnBoss")]
		[HarmonyPostfix]
		private static void SetSpawnTime(OfferingBowl __instance)
		{
			ZNetView componentInParent = ((Component)__instance).GetComponentInParent<ZNetView>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				componentInParent.GetZDO().Set(Hash.SpawnTime, ZNet.instance.GetTime().Ticks);
			}
		}

		[HarmonyPatch("DelayedSpawnBoss")]
		[HarmonyPrefix]
		private static void GetValues(OfferingBowl __instance)
		{
			SpawnData = null;
			Helper.String(((Component)__instance).GetComponentInParent<ZNetView>(), Hash.Data, delegate(string value)
			{
				SpawnData = DataHelper.Deserialize(value);
			});
		}

		private static void SetupSpawn(BaseAI baseAI, OfferingBowl bowl)
		{
			if (!Configuration.configOfferingBowl.Value)
			{
				return;
			}
			Character obj = ((Component)baseAI).GetComponent<Character>();
			if (!Object.op_Implicit((Object)(object)obj))
			{
				return;
			}
			ZNetView componentInParent = ((Component)bowl).GetComponentInParent<ZNetView>();
			float levelChance = 10f;
			int minLevel = 1;
			int maxLevel = 1;
			Helper.Float(componentInParent, Hash.LevelChance, delegate(float value)
			{
				levelChance = value;
			});
			Helper.Int(componentInParent, Hash.MinLevel, delegate(int value)
			{
				minLevel = value;
			});
			Helper.Int(componentInParent, Hash.MaxLevel, delegate(int value)
			{
				maxLevel = value;
			});
			int num = Helper.RollLevel(minLevel, maxLevel, levelChance);
			if (num > 1)
			{
				obj.SetLevel(num);
			}
			Helper.Float(componentInParent, Hash.Health, (Action<float>)obj.SetMaxHealth);
			Helper.String(componentInParent, Hash.Faction, Hash.FactionLegacy, delegate(string value)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				obj.m_nview.GetZDO().Set(Hash.Faction, value);
				if (Enum.TryParse<Faction>(value, ignoreCase: true, out Faction result))
				{
					obj.m_faction = result;
				}
			});
		}

		private static GameObject Instantiate(GameObject prefab, Vector3 position, Quaternion rotation)
		{
			//IL_0015: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (SpawnData != null)
			{
				DataHelper.InitZDO(prefab, position, rotation, SpawnData);
			}
			return Object.Instantiate<GameObject>(prefab, position, rotation);
		}

		[HarmonyPatch("DelayedSpawnBoss")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SetData(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(OfferingBowl), "m_bossSpawnPoint"), (string)null)
			}).Advance(2).Set(OpCodes.Call, Transpilers.EmitDelegate<Func<GameObject, Vector3, Quaternion, GameObject>>((Func<GameObject, Vector3, Quaternion, GameObject>)Instantiate).operand)
				.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(BaseAI), "SetPatrolPoint", (Type[])null, (Type[])null), (string)null)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, Transpilers.EmitDelegate<Action<BaseAI, OfferingBowl>>((Action<BaseAI, OfferingBowl>)SetupSpawn).operand)
				})
				.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Ldloc_1, (object)null)
				})
				.InstructionEnumeration();
		}

		[HarmonyPatch("SpawnItem")]
		[HarmonyPostfix]
		public static bool SpawnItem(bool result, OfferingBowl __instance)
		{
			OfferingBowl __instance2 = __instance;
			if (result)
			{
				Helper.String(((Component)__instance2).GetComponentInParent<ZNetView>(), Hash.Command, delegate(string value)
				{
					//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_0021: 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)
					Vector3 position = ((Component)__instance2).transform.position;
					Quaternion rotation = ((Component)__instance2).transform.rotation;
					ServerExecution.Send(value, position, ((Quaternion)(ref rotation)).eulerAngles);
				});
			}
			return result;
		}

		[HarmonyPatch("DelayedSpawnBoss")]
		[HarmonyPostfix]
		public static void DelayedSpawnBoss(OfferingBowl __instance)
		{
			OfferingBowl __instance2 = __instance;
			Helper.String(((Component)__instance2).GetComponentInParent<ZNetView>(), Hash.Command, delegate(string value)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: 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_001f: Unknown result type (might be due to invalid IL or missing references)
				Vector3 bossSpawnPoint = __instance2.m_bossSpawnPoint;
				Quaternion rotation = ((Component)__instance2).transform.rotation;
				ServerExecution.Send(value, bossSpawnPoint, ((Quaternion)(ref rotation)).eulerAngles);
			});
		}
	}
	[HarmonyPatch(typeof(LocationProxy), "SpawnLocation")]
	public class UpdateOfferingBowls
	{
		private static void Postfix(LocationProxy __instance, bool __result)
		{
			if (__result && Configuration.configOfferingBowl.Value)
			{
				GameObject instance = __instance.m_instance;
				OfferingBowl val = ((instance != null) ? instance.GetComponentInChildren<OfferingBowl>() : null);
				if ((Object)(object)val != (Object)null)
				{
					OfferingBowlPatches.Setup(val);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Pickable))]
	public class PickablePatches
	{
		private static void SetSpawn(Pickable obj, ZNetView view)
		{
			Pickable obj2 = obj;
			Helper.Prefab(view, Hash.PickableSpawn, Hash.Spawn, delegate(GameObject value)
			{
				obj2.m_itemPrefab = value;
			});
		}

		private static void SetRespawn(Pickable obj, ZNetView view)
		{
			Pickable obj2 = obj;
			Helper.Float(view, Hash.PickableRespawn, Hash.Respawn, delegate(float value)
			{
				obj2.m_respawnTimeMinutes = value;
			});
		}

		private static void SetAmount(Pickable obj, ZNetView view)
		{
			Pickable obj2 = obj;
			Helper.Int(view, Hash.Amount, delegate(int value)
			{
				obj2.m_amount = value;
			});
		}

		private static void SetName(Pickable obj, ZNetView view)
		{
			Pickable obj2 = obj;
			Helper.String(view, Hash.Name, delegate(string value)
			{
				obj2.m_overrideName = value;
			});
		}

		private static void SetSpawnOffset(Pickable obj, ZNetView view)
		{
			Pickable obj2 = obj;
			Helper.Float(view, Hash.SpawnOffset, delegate(float value)
			{
				obj2.m_spawnOffset = value;
			});
		}

		private static void SetUseEffect(Pickable obj, ZNetView view)
		{
			Pickable obj2 = obj;
			Helper.String(view, Hash.UseEffect, delegate(string value)
			{
				obj2.m_pickEffector = Helper.ParseEffects(value);
			});
		}

		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void Setup(Pickable __instance)
		{
			if (Configuration.configPickable.Value)
			{
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if (Object.op_Implicit((Object)(object)component) && component.IsValid())
				{
					SetRespawn(__instance, component);
					SetSpawn(__instance, component);
					SetAmount(__instance, component);
					SetName(__instance, component);
					SetSpawnOffset(__instance, component);
					SetUseEffect(__instance, component);
				}
			}
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void StartRespawnLoop(Pickable __instance)
		{
			if (!Configuration.configPickable.Value)
			{
				return;
			}
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if (Object.op_Implicit((Object)(object)component) && component.IsValid() && __instance.m_respawnTimeMinutes != 0f)
			{
				bool checkPickable = false;
				Helper.Int(component, Hash.SpawnCondition, delegate
				{
					checkPickable = true;
				});
				Helper.String(component, Hash.RequiredGlobalKey, delegate
				{
					checkPickable = true;
				});
				Helper.String(component, Hash.ForbiddenGlobalKey, delegate
				{
					checkPickable = true;
				});
				if (checkPickable)
				{
					((MonoBehaviour)__instance).InvokeRepeating("CheckCondition", Random.Range(1f, 5f), 30f);
				}
			}
		}

		private static void SetStack(ItemDrop obj, int amount)
		{
			if (obj != null)
			{
				obj.SetStack(amount);
			}
		}

		[HarmonyPatch("Drop")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SetStackAmount(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(ItemDrop), "SetStack", (Type[])null, (Type[])null), (string)null)
			}).Set(OpCodes.Call, Transpilers.EmitDelegate<Action<ItemDrop, int>>((Action<ItemDrop, int>)SetStack).operand).InstructionEnumeration();
		}

		[HarmonyPatch("GetHoverName")]
		[HarmonyPrefix]
		private static bool GetHoverName(Pickable __instance, ref string __result)
		{
			if (string.IsNullOrEmpty(__instance.m_overrideName) && !Object.op_Implicit((Object)(object)__instance.m_itemPrefab))
			{
				__result = Utils.GetPrefabName(((Component)__instance).gameObject);
				return false;
			}
			return true;
		}
	}
	public static class PickableExtensions
	{
		private static readonly int SpawnCondition = StringExtensionMethods.GetStableHashCode("override_spawn_condition");

		private static readonly int RequiredGlobalKey = StringExtensionMethods.GetStableHashCode("override_required_globalkey");

		private static readonly int ForbiddenGlobalKey = StringExtensionMethods.GetStableHashCode("override_forbidden_globalkey");

		private static void SetPicked(Pickable obj, bool value)
		{
			obj.m_picked = value;
			if (Object.op_Implicit((Object)(object)obj.m_hideWhenPicked))
			{
				obj.m_hideWhenPicked.SetActive(!value);
			}
		}

		public static void CheckCondition(this Pickable obj)
		{
			ZNetView nview = obj.m_nview;
			if (!Object.op_Implicit((Object)(object)nview) || !nview.IsValid())
			{
				return;
			}
			bool picked = nview.GetZDO().GetBool(ZDOVars.s_picked, false);
			if (picked)
			{
				return;
			}
			Helper.Int(nview, SpawnCondition, delegate(int value)
			{
				if (value == 1 && EnvMan.IsNight())
				{
					picked = true;
				}
				if (value == 2 && EnvMan.IsDay())
				{
					picked = true;
				}
			});
			if (!picked)
			{
				Helper.HashList(nview, RequiredGlobalKey, delegate(int[] value)
				{
					HashSet<int> hashSet2 = (from s in ZoneSystem.instance.GetGlobalKeys()
						select StringExtensionMethods.GetStableHashCode(s)).ToHashSet();
					foreach (int item2 in value)
					{
						if (!hashSet2.Contains(item2))
						{
							picked = true;
						}
					}
				});
			}
			if (!picked)
			{
				Helper.HashList(nview, ForbiddenGlobalKey, delegate(int[] value)
				{
					HashSet<int> hashSet = (from s in ZoneSystem.instance.GetGlobalKeys()
						select StringExtensionMethods.GetStableHashCode(s)).ToHashSet();
					foreach (int item in value)
					{
						if (hashSet.Contains(item))
						{
							picked = true;
						}
					}
				});
			}
			SetPicked(obj, picked);
		}
	}
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public class ServerExecution
	{
		public static string RPC_Command = "SpawnerTweaks_Command";

		public static void Send(string command, Vector3 center, Vector3 rot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			string text = Parse(command, center, rot);
			if (!Object.op_Implicit((Object)(object)ZNet.instance) || ZNet.instance.IsServer())
			{
				((Terminal)Console.instance).TryRunCommand(text, false, false);
				return;
			}
			ZRpc serverRPC = ZNet.instance.GetServerRPC();
			if (serverRPC != null)
			{
				string rPC_Command = RPC_Command;
				object[] array = new string[1] { text };
				serverRPC.Invoke(rPC_Command, array);
			}
		}

		private static void RPC_Do_Command(ZRpc rpc, string command)
		{
			((Terminal)Console.instance).TryRunCommand(command, false, false);
		}

		private static void Postfix(ZNet __instance, ZRpc rpc)
		{
			if (__instance.IsDedicated())
			{
				rpc.Register<string>(RPC_Command, (Action<ZRpc, string>)RPC_Do_Command);
			}
		}

		private static string Parse(string command, Vector3 center, Vector3 rot)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//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)
			Vector2i zone = ZoneSystem.GetZone(center);
			string text = command.Replace("$$x", center.x.ToString(NumberFormatInfo.InvariantInfo)).Replace("$$y", center.y.ToString(NumberFormatInfo.InvariantInfo)).Replace("$$z", center.z.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("$$i", zone.x.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("$$j", zone.y.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("$$a", rot.y.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("<x>", center.x.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("<y>", center.y.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("<z>", center.z.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("<i>", zone.x.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("<j>", zone.y.ToString(NumberFormatInfo.InvariantInfo))
				.Replace("<a>", rot.y.ToString(NumberFormatInfo.InvariantInfo));
			string[] array = (from s in text.Split(new char[1] { ' ' })
				select s.Split(new char[1] { '=' }) into a
				select a[^1].Trim()).SelectMany((string s) => s.Split(new char[1] { ',' })).ToArray();
			foreach (string text2 in array)
			{
				if (Enumerable.Contains(text2, '*') || Enumerable.Contains(text2, '/') || Enumerable.Contains(text2, '+') || Enumerable.Contains(text2, '-'))
				{
					text = text.Replace(text2, Evaluate(text2).ToString(NumberFormatInfo.InvariantInfo));
				}
			}
			return text;
		}

		private static float Evaluate(string expression)
		{
			string[] array = expression.Split(new char[1] { '*' });
			if (array.Length > 1)
			{
				float num = 1f;
				string[] array2 = array;
				foreach (string expression2 in array2)
				{
					num *= Evaluate(expression2);
				}
				return num;
			}
			string[] array3 = expression.Split(new char[1] { '/' });
			if (array3.Length > 1)
			{
				float num2 = Evaluate(array3[0]);
				for (int j = 1; j < array3.Length; j++)
				{
					num2 /= Evaluate(array3[j]);
				}
				return num2;
			}
			string[] array4 = expression.Split(new char[1] { '+' });
			if (array4.Length > 1)
			{
				float num3 = 0f;
				string[] array2 = array4;
				foreach (string expression3 in array2)
				{
					num3 += Evaluate(expression3);
				}
				return num3;
			}
			string[] array5 = expression.Split(new char[1] { '-' });
			if (array5.Where((string s) => s != "").Count() > 1)
			{
				float num4 = Evaluate(array5[0]);
				for (int k = 1; k < array5.Length; k++)
				{
					if (array5[k] == "" && k + 1 < array5.Length)
					{
						array5[k + 1] = "-" + array5[k + 1];
					}
					else
					{
						num4 -= Evaluate(array5[k]);
					}
				}
				return num4;
			}
			try
			{
				return float.Parse(expression.Trim(), NumberFormatInfo.InvariantInfo);
			}
			catch
			{
				throw new Exception("Failed to parse expression: " + expression);
			}
		}
	}
	[HarmonyPatch(typeof(Smelter))]
	public class SmelterPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Setup(Smelter __instance)
		{
			if (!Configuration.configSmelter.Value)
			{
				return;
			}
			Smelter obj = __instance;
			ZNetView nview = obj.m_nview;
			if (Object.op_Implicit((Object)(object)nview) && nview.IsValid())
			{
				Helper.Int(nview, Hash.FuelUsage, delegate(int value)
				{
					obj.m_fuelPerProduct = value;
				});
				Helper.Int(nview, Hash.MaxAmount, delegate(int value)
				{
					obj.m_maxOre = value;
				});
				Helper.Int(nview, Hash.MaxFuel, delegate(int value)
				{
					obj.m_maxFuel = value;
				});
				Helper.Item(nview, Hash.Fuel, delegate(ItemDrop value)
				{
					obj.m_fuelItem = value;
				});
				Helper.Float(nview, Hash.Speed, delegate(float value)
				{
					obj.m_secPerProduct = value;
				});
				Helper.String(nview, Hash.InputEffect, delegate(string value)
				{
					obj.m_oreAddedEffects = Helper.ParseEffects(value);
				});
				Helper.String(nview, Hash.FuelEffect, delegate(string value)
				{
					obj.m_fuelAddedEffects = Helper.ParseEffects(value);
				});
				Helper.String(nview, Hash.OutputEffect, delegate(string value)
				{
					obj.m_produceEffects = Helper.ParseEffects(value);
				});
				Helper.String(nview, Hash.Conversion, delegate(string value)
				{
					obj.m_conversion = Helper.ParseSmelterConversions(value);
				});
			}
		}
	}
	[HarmonyPatch(typeof(SpawnArea))]
	public class SpawnAreaPatches
	{
		private static float? SpawnHealth;

		private static string? SpawnFaction;

		private static int? SpawnLevel;

		private static ZPackage? SpawnData;

		private static Character? Spawned = null;

		private static readonly int Tamed = StringExtensionMethods.GetStableHashCode("Tamed");

		private static readonly int Stack = StringExtensionMethods.GetStableHashCode("stack");

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Setup(SpawnArea __instance)
		{
			if (!Configuration.configSpawnArea.Value)
			{
				return;
			}
			SpawnArea obj = __instance;
			ZNetView nview = obj.m_nview;
			if (Object.op_Implicit((Object)(object)nview) && nview.IsValid())
			{
				Helper.Float(nview, Hash.LevelChance, delegate(float value)
				{
					obj.m_levelupChance = value;
				});
				Helper.Float(nview, Hash.SpawnRadius, delegate(float value)
				{
					obj.m_spawnRadius = value;
				});
				Helper.Float(nview, Hash.NearRadius, delegate(float value)
				{
					obj.m_nearRadius = value;
				});
				Helper.Float(nview, Hash.FarRadius, delegate(float value)
				{
					obj.m_farRadius = value;
				});
				Helper.Float(nview, Hash.TriggerDistance, delegate(float value)
				{
					obj.m_triggerDistance = value;
				});
				Helper.Int(nview, Hash.MaxNear, delegate(int value)
				{
					obj.m_maxNear = value;
				});
				Helper.Int(nview, Hash.MaxTotal, delegate(int value)
				{
					obj.m_maxTotal = value;
				});
				Helper.Float(nview, Hash.SpawnAreaRespawn, Hash.Respawn, delegate(float value)
				{
					obj.m_spawnIntervalSec = value;
				});
				Helper.String(nview, Hash.SpawnEffect, delegate(string value)
				{
					obj.m_spawnEffects = Helper.ParseEffects(value);
				});
				Helper.String(nview, Hash.SpawnAreaSpawn, Hash.Spawn, delegate(string value)
				{
					obj.m_prefabs = Helper.ParseSpawnsData(value);
				});
				Helper.Int(nview, Hash.SpawnCondition, delegate(int value)
				{
					obj.m_onGroundOnly = (value & 4) > 0;
				});
			}
		}

		[HarmonyPatch("UpdateSpawn")]
		[HarmonyPrefix]
		private static bool PickableCheck(SpawnArea __instance)
		{
			Pickable component = ((Component)__instance).GetComponent<Pickable>();
			if (component == null)
			{
				return true;
			}
			return !component.m_picked;
		}

		[HarmonyPatch("SelectWeightedPrefab")]
		[HarmonyPostfix]
		private static void GetSpawnedData(SpawnArea __instance, SpawnData __result)
		{
			SpawnArea __instance2 = __instance;
			SpawnData __result2 = __result;
			Spawned = null;
			SpawnHealth = null;
			SpawnFaction = null;
			SpawnLevel = null;
			SpawnData = null;
			int? minLevel = null;
			int? maxLevel = null;
			Helper.Float(__instance2.m_nview, Hash.Health, delegate(float value)
			{
				SpawnHealth = value;
			});
			Helper.String(__instance2.m_nview, Hash.Faction, delegate(string value)
			{
				SpawnFaction = value;
			});
			Helper.Int(__instance2.m_nview, Hash.MinLevel, delegate(int value)
			{
				minLevel = value;
			});
			Helper.Int(__instance2.m_nview, Hash.MaxLevel, delegate(int value)
			{
				maxLevel = value;
			});
			Helper.String(__instance2.m_nview, Hash.SpawnAreaSpawn, Hash.Spawn, delegate(string value)
			{
				int num = __instance2.m_prefabs.IndexOf(__result2);
				string[] array = value.Split(new char[1] { '|' })[num].Split(new char[1] { ',' });
				if (array.Length > 2)
				{
					minLevel = Helper.Int(array[2]);
				}
				if (array.Length > 3)
				{
					maxLevel = Helper.Int(array[3]);
				}
				if (array.Length > 4)
				{
					float? spawnHealth = Helper.Float(array[4]);
					if (spawnHealth.HasValue)
					{
						SpawnHealth = spawnHealth;
						if (array.Length > 5)
						{
							SpawnData = DataHelper.Deserialize(array[5]);
						}
					}
					else
					{
						if (Enum.TryParse<Faction>(array[4], ignoreCase: true, out Faction _))
						{
							SpawnFaction = array[4];
						}
						else
						{
							SpawnData = DataHelper.Deserialize(array[4]);
						}
						if (array.Length > 5)
						{
							SpawnHealth = Helper.Float(array[5]);
						}
					}
				}
			});
			if (minLevel.HasValue && maxLevel.HasValue)
			{
				SpawnLevel = Helper.RollLevel(minLevel.Value, maxLevel.Value, __instance2.m_levelupChance);
			}
		}

		[HarmonyPatch("SpawnOne")]
		[HarmonyPrefix]
		private static bool CheckTime(SpawnArea __instance)
		{
			if (!Configuration.configSpawnArea.Value)
			{
				return true;
			}
			int @int = __instance.m_nview.GetZDO().GetInt(Hash.SpawnCondition, 0);
			if (@int <= 0)
			{
				return true;
			}
			if ((@int & 1) > 0 && EnvMan.IsNight())
			{
				return false;
			}
			if ((@int & 2) > 0 && EnvMan.IsDay())
			{
				return false;
			}
			return true;
		}

		private static Vector3 GetCenterPoint(Character character, GameObject obj)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Spawned = character;
			if (character == null)
			{
				return obj.transform.position;
			}
			return character.GetCenterPoint();
		}

		[HarmonyPatch("SpawnOne")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> FixCenterPoint(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Character), "GetCenterPoint", (Type[])null, (Type[])null), (string)null)
			}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldloc_S, (object)4)
			}).Set(OpCodes.Call, Transpilers.EmitDelegate<Func<Character, GameObject, Vector3>>((Func<Character, GameObject, Vector3>)GetCenterPoint).operand)
				.InstructionEnumeration();
		}

		private static GameObject Instantiate(GameObject prefab, Vector3 position, Quaternion rotation)
		{
			//IL_0015: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (SpawnData != null)
			{
				DataHelper.InitZDO(prefab, position, rotation, SpawnData);
			}
			return Object.Instantiate<GameObject>(prefab, position, rotation);
		}

		[HarmonyPatch("SpawnOne")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SetData(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldc_I4, (object)360, (string)null)
			}).Advance(5).Set(OpCodes.Call, Transpilers.EmitDelegate<Func<GameObject, Vector3, Quaternion, GameObject>>((Func<GameObject, Vector3, Quaternion, GameObject>)Instantiate).operand)
				.InstructionEnumeration();
		}

		[HarmonyPatch("SpawnOne")]
		[HarmonyPostfix]
		[HarmonyPriority(100)]
		private static void ApplyChanges()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Spawned == (Object)null))
			{
				if (SpawnFaction != null && Enum.TryParse<Faction>(SpawnFaction, ignoreCase: true, out Faction result))
				{
					Spawned.m_faction = result;
					Spawned.m_nview.GetZDO().Set(Hash.Faction, SpawnFaction);
				}
				if (SpawnLevel.HasValue)
				{
					Spawned.SetLevel(SpawnLevel.Value);
				}
				if (SpawnHealth.HasValue)
				{
					Spawned.SetMaxHealth(SpawnHealth.Value);
				}
			}
		}

		[HarmonyPatch("GetInstances")]
		[HarmonyPrefix]
		private static bool GetInstances(SpawnArea __instance, out int near, out int total)
		{
			//IL_000c: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			near = 0;
			total = 0;
			Vector3 position = ((Component)__instance).transform.position;
			HashSet<int> hashSet = __instance.m_prefabs.Select((SpawnData x) => StringExtensionMethods.GetStableHashCode(((Object)x.m_prefab).name)).ToHashSet();
			foreach (ZDO key in ZNetScene.instance.m_instances.Keys)
			{
				if (hashSet.Contains(key.GetPrefab()) && !key.GetBool(Tamed, false))
				{
					float num = Utils.DistanceXZ(position, key.GetPosition());