Decompiled source of WorkshopNoSpoil v1.0.1

BepInEx/plugins/WorkshopNoSpoil.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using WorkshopNoSpoil.Localization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("WorkshopNoSpoil")]
[assembly: AssemblyDescription("WorkshopNoSpoil mod for Old Market Simulator by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("WorkshopNoSpoil")]
[assembly: AssemblyCopyright("Copyright © 2025 Ice Box Studio")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("B4D9F9F2-0C1F-5C9F-0FBC-458E1C7E6342")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.1.0")]
namespace WorkshopNoSpoil
{
	[BepInPlugin("IceBoxStudio.WorkshopNoSpoil", "WorkshopNoSpoil", "1.0.1")]
	public class WorkshopNoSpoil : BaseUnityPlugin
	{
		private static WorkshopNoSpoil _instance;

		private Harmony _harmony;

		private bool patchesApplied;

		public static WorkshopNoSpoil Instance => _instance;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			_instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			try
			{
				Logger.LogInfo((object)"=============================================");
				Logger.LogInfo((object)("WorkshopNoSpoil " + LocalizationManager.Instance.GetLocalizedText("plugin.initializing")));
				Logger.LogInfo((object)(LocalizationManager.Instance.GetLocalizedText("plugin.author_prefix") + "Ice Box Studio(https://steamcommunity.com/id/ibox666/)"));
				ApplyPatches();
				Logger.LogInfo((object)("WorkshopNoSpoil " + LocalizationManager.Instance.GetLocalizedText("plugin.initialized")));
				Logger.LogInfo((object)"=============================================");
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("WorkshopNoSpoil 初始化错误: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private void ApplyPatches()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (!patchesApplied)
			{
				try
				{
					_harmony = new Harmony("IceBoxStudio.WorkshopNoSpoil");
					_harmony.PatchAll();
					patchesApplied = true;
					return;
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("WorkshopNoSpoil 应用补丁错误: " + ex.Message + "\n" + ex.StackTrace));
					return;
				}
			}
			Logger.LogInfo((object)LocalizationManager.Instance.GetLocalizedText("plugin.patches_skipped"));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IceBoxStudio.WorkshopNoSpoil";

		public const string PLUGIN_NAME = "WorkshopNoSpoil";

		public const string PLUGIN_VERSION = "1.0.1";

		public const string PLUGIN_AUTHOR = "Ice Box Studio";

		public const string PLUGIN_DESCRIPTION = "工作坊可以和地窖一样存放物品,不会让物品腐坏。";
	}
}
namespace WorkshopNoSpoil.Patches
{
	[HarmonyPatch]
	internal static class WorkshopSpoilPatchs
	{
		private const float DEFAULT_FREEZER_HEIGHT = 8f;

		private const float BOUNDS_MARGIN = 0.1f;

		private static readonly Dictionary<int, GameObject> FloorToTriggerMap = new Dictionary<int, GameObject>();

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameManager), "OnNetworkSpawn")]
		private static void GameManager_OnNetworkSpawn_Postfix()
		{
			TryEnsureWorkshopFreezerZones();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameManager), "OnActiveExpansionsChanged")]
		private static void GameManager_OnActiveExpansionsChanged_Postfix()
		{
			TryEnsureWorkshopFreezerZones();
		}

		private static void TryEnsureWorkshopFreezerZones()
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Object.op_Implicit((Object)(object)NetworkManager.Singleton) || !NetworkManager.Singleton.IsServer)
				{
					return;
				}
				int num = LayerMask.NameToLayer("WorkshopFloor");
				if (num < 0)
				{
					return;
				}
				Transform[] array = Object.FindObjectsOfType<Transform>(true);
				List<GameObject> list = new List<GameObject>();
				Transform[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					GameObject gameObject = ((Component)array2[i]).gameObject;
					if (gameObject.layer == num && gameObject.activeInHierarchy)
					{
						list.Add(gameObject);
					}
				}
				if (list.Count == 0)
				{
					return;
				}
				int num2 = 0;
				int num3 = 0;
				CleanupMissingFloorTriggers(list);
				foreach (GameObject item in list)
				{
					if (!TryGetLocalFloorBounds(item, num, out var localBounds))
					{
						continue;
					}
					int instanceID = ((Object)item).GetInstanceID();
					if (FloorToTriggerMap.TryGetValue(instanceID, out var value))
					{
						if (ShouldUpdateTrigger(value, localBounds, 8f, item.transform))
						{
							UpdateTrigger(value, localBounds, 8f, item.transform);
							num3++;
						}
					}
					else
					{
						GameObject value2 = CreateTrigger(localBounds, 8f, item.transform);
						FloorToTriggerMap[instanceID] = value2;
						num2++;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = WorkshopNoSpoil.Logger;
				if (logger != null)
				{
					logger.LogError((object)("创建时发生错误: " + ex.Message + "\n" + ex.StackTrace));
				}
			}
		}

		private static bool ShouldUpdateTrigger(GameObject trigger, Bounds localBounds, float height, Transform parent)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)trigger == (Object)null)
			{
				return true;
			}
			BoxCollider component = trigger.GetComponent<BoxCollider>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(Mathf.Max(((Bounds)(ref localBounds)).size.x - 0.2f, 0.01f), Mathf.Max(height, 0.01f), Mathf.Max(((Bounds)(ref localBounds)).size.z - 0.2f, 0.01f));
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Bounds)(ref localBounds)).center.x, ((Bounds)(ref localBounds)).min.y + height / 2f, ((Bounds)(ref localBounds)).center.z);
			Vector3 val3 = component.size - val;
			bool num = ((Vector3)(ref val3)).sqrMagnitude > 1.0000001E-06f;
			val3 = trigger.transform.localPosition - val2;
			bool flag = ((Vector3)(ref val3)).sqrMagnitude > 1.0000001E-06f;
			bool flag2 = (Object)(object)parent != (Object)null && (Object)(object)trigger.transform.parent != (Object)(object)parent;
			return num || flag || flag2;
		}

		private static GameObject CreateTrigger(Bounds localBounds, float height, Transform parent)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00c5: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			Vector3 size = default(Vector3);
			((Vector3)(ref size))..ctor(Mathf.Max(((Bounds)(ref localBounds)).size.x - 0.2f, 0.01f), Mathf.Max(height, 0.01f), Mathf.Max(((Bounds)(ref localBounds)).size.z - 0.2f, 0.01f));
			Vector3 localPosition = default(Vector3);
			((Vector3)(ref localPosition))..ctor(((Bounds)(ref localBounds)).center.x, ((Bounds)(ref localBounds)).min.y + height / 2f, ((Bounds)(ref localBounds)).center.z);
			GameObject val = new GameObject("WorkshopFreezerZone")
			{
				tag = "Freezer"
			};
			int num = LayerMask.NameToLayer("IgnoreBlockCollision");
			if (num >= 0)
			{
				val.layer = num;
			}
			if ((Object)(object)parent != (Object)null)
			{
				val.transform.SetParent(parent, false);
			}
			val.transform.localPosition = localPosition;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			BoxCollider obj = val.AddComponent<BoxCollider>();
			((Collider)obj).isTrigger = true;
			obj.size = size;
			obj.center = Vector3.zero;
			return val;
		}

		private static void UpdateTrigger(GameObject trigger, Bounds localBounds, float height, Transform parent)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)trigger == (Object)null))
			{
				BoxCollider val = trigger.GetComponent<BoxCollider>();
				if ((Object)(object)val == (Object)null)
				{
					val = trigger.AddComponent<BoxCollider>();
					((Collider)val).isTrigger = true;
				}
				Vector3 size = default(Vector3);
				((Vector3)(ref size))..ctor(Mathf.Max(((Bounds)(ref localBounds)).size.x - 0.2f, 0.01f), Mathf.Max(height, 0.01f), Mathf.Max(((Bounds)(ref localBounds)).size.z - 0.2f, 0.01f));
				trigger.tag = "Freezer";
				int num = LayerMask.NameToLayer("IgnoreBlockCollision");
				if (num >= 0)
				{
					trigger.layer = num;
				}
				if ((Object)(object)parent != (Object)null && (Object)(object)trigger.transform.parent != (Object)(object)parent)
				{
					trigger.transform.SetParent(parent, false);
				}
				trigger.transform.localPosition = new Vector3(((Bounds)(ref localBounds)).center.x, ((Bounds)(ref localBounds)).min.y + height / 2f, ((Bounds)(ref localBounds)).center.z);
				trigger.transform.localRotation = Quaternion.identity;
				trigger.transform.localScale = Vector3.one;
				((Collider)val).isTrigger = true;
				val.size = size;
				val.center = Vector3.zero;
			}
		}

		private static bool TryGetLocalFloorBounds(GameObject parent, int layer, out Bounds localBounds)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			localBounds = default(Bounds);
			List<Bounds> list = new List<Bounds>();
			Renderer[] componentsInChildren = parent.GetComponentsInChildren<Renderer>(true);
			Matrix4x4 worldToLocalMatrix = parent.transform.worldToLocalMatrix;
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.layer == layer)
				{
					Bounds localBounds2 = val.localBounds;
					Matrix4x4 localToTarget = worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix;
					list.Add(BoundsFromTransformedCorners(localBounds2, localToTarget));
				}
			}
			Collider[] componentsInChildren2 = parent.GetComponentsInChildren<Collider>(true);
			Bounds bounds = default(Bounds);
			Vector3 val7 = default(Vector3);
			foreach (Collider val2 in componentsInChildren2)
			{
				if ((Object)(object)val2 == (Object)null || ((Component)val2).gameObject.layer != layer)
				{
					continue;
				}
				Matrix4x4 localToTarget2 = worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix;
				BoxCollider val3 = (BoxCollider)(object)((val2 is BoxCollider) ? val2 : null);
				if (val3 != null)
				{
					((Bounds)(ref bounds))..ctor(val3.center, val3.size);
					list.Add(BoundsFromTransformedCorners(bounds, localToTarget2));
					continue;
				}
				MeshCollider val4 = (MeshCollider)(object)((val2 is MeshCollider) ? val2 : null);
				if (val4 != null && (Object)(object)val4.sharedMesh != (Object)null)
				{
					bounds = val4.sharedMesh.bounds;
					list.Add(BoundsFromTransformedCorners(bounds, localToTarget2));
					continue;
				}
				SphereCollider val5 = (SphereCollider)(object)((val2 is SphereCollider) ? val2 : null);
				if (val5 != null)
				{
					float num = val5.radius * 2f;
					((Bounds)(ref bounds))..ctor(val5.center, new Vector3(num, num, num));
					list.Add(BoundsFromTransformedCorners(bounds, localToTarget2));
					continue;
				}
				CapsuleCollider val6 = (CapsuleCollider)(object)((val2 is CapsuleCollider) ? val2 : null);
				if (val6 != null)
				{
					switch (val6.direction)
					{
					case 0:
						((Vector3)(ref val7))..ctor(val6.height, val6.radius * 2f, val6.radius * 2f);
						break;
					case 1:
						((Vector3)(ref val7))..ctor(val6.radius * 2f, val6.height, val6.radius * 2f);
						break;
					default:
						((Vector3)(ref val7))..ctor(val6.radius * 2f, val6.radius * 2f, val6.height);
						break;
					}
					((Bounds)(ref bounds))..ctor(val6.center, val7);
					list.Add(BoundsFromTransformedCorners(bounds, localToTarget2));
				}
			}
			if (list.Count == 0)
			{
				return false;
			}
			float num2 = float.PositiveInfinity;
			foreach (Bounds item in list)
			{
				Bounds current = item;
				if (((Bounds)(ref current)).min.y < num2)
				{
					num2 = ((Bounds)(ref current)).min.y;
				}
			}
			bool flag = false;
			foreach (Bounds item2 in list)
			{
				Bounds current2 = item2;
				if (((Bounds)(ref current2)).size.y <= 0.5f && ((Bounds)(ref current2)).min.y <= num2 + 0.2f)
				{
					if (!flag)
					{
						localBounds = current2;
						flag = true;
					}
					else
					{
						((Bounds)(ref localBounds)).Encapsulate(current2);
					}
				}
			}
			if (!flag)
			{
				foreach (Bounds item3 in list)
				{
					if (!flag)
					{
						localBounds = item3;
						flag = true;
					}
					else
					{
						((Bounds)(ref localBounds)).Encapsulate(item3);
					}
				}
			}
			return flag;
		}

		private static Bounds BoundsFromTransformedCorners(Bounds src, Matrix4x4 localToTarget)
		{
			//IL_0000: 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_0042: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] boundsCorners = GetBoundsCorners(src);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity);
			for (int i = 0; i < boundsCorners.Length; i++)
			{
				Vector3 val3 = ((Matrix4x4)(ref localToTarget)).MultiplyPoint3x4(boundsCorners[i]);
				val = Vector3.Min(val, val3);
				val2 = Vector3.Max(val2, val3);
			}
			Vector3 val4 = (val + val2) * 0.5f;
			Vector3 val5 = val2 - val;
			return new Bounds(val4, val5);
		}

		private static Vector3[] GetBoundsCorners(Bounds b)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0075: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a5: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 center = ((Bounds)(ref b)).center;
			Vector3 extents = ((Bounds)(ref b)).extents;
			return (Vector3[])(object)new Vector3[8]
			{
				center + new Vector3(extents.x, extents.y, extents.z),
				center + new Vector3(extents.x, extents.y, 0f - extents.z),
				center + new Vector3(extents.x, 0f - extents.y, extents.z),
				center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z),
				center + new Vector3(0f - extents.x, extents.y, extents.z),
				center + new Vector3(0f - extents.x, extents.y, 0f - extents.z),
				center + new Vector3(0f - extents.x, 0f - extents.y, extents.z),
				center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z)
			};
		}

		private static void CleanupMissingFloorTriggers(List<GameObject> currentFloors)
		{
			HashSet<int> hashSet = new HashSet<int>();
			foreach (GameObject currentFloor in currentFloors)
			{
				hashSet.Add(((Object)currentFloor).GetInstanceID());
			}
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, GameObject> item in FloorToTriggerMap)
			{
				if (!hashSet.Contains(item.Key) || (Object)(object)item.Value == (Object)null)
				{
					list.Add(item.Key);
				}
			}
			foreach (int item2 in list)
			{
				if (FloorToTriggerMap.TryGetValue(item2, out var value) && (Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
				FloorToTriggerMap.Remove(item2);
			}
		}
	}
}
namespace WorkshopNoSpoil.Localization
{
	public static class LocalizationHelper
	{
		public static Dictionary<string, string> GetDefaultTranslations(string language)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			switch (language)
			{
			case "zh":
				dictionary.Add("plugin.initializing", "开始初始化...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初始化成功!");
				dictionary.Add("plugin.patches_skipped", "补丁已应用,跳过...");
				break;
			case "zh-Hant":
				dictionary.Add("plugin.initializing", "開始初始化...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初始化成功!");
				dictionary.Add("plugin.patches_skipped", "補丁已應用,跳過...");
				break;
			case "en":
				dictionary.Add("plugin.initializing", "is initializing...");
				dictionary.Add("plugin.author_prefix", "Author: ");
				dictionary.Add("plugin.initialized", "initialized successfully!");
				dictionary.Add("plugin.patches_skipped", "Patches already applied, skipping...");
				break;
			case "fr":
				dictionary.Add("plugin.initializing", "initialisation...");
				dictionary.Add("plugin.author_prefix", "Auteur : ");
				dictionary.Add("plugin.initialized", "initialisé avec succès !");
				dictionary.Add("plugin.patches_skipped", "Correctifs déjà appliqués, ignoré...");
				break;
			case "de":
				dictionary.Add("plugin.initializing", "wird initialisiert...");
				dictionary.Add("plugin.author_prefix", "Autor: ");
				dictionary.Add("plugin.initialized", "erfolgreich initialisiert!");
				dictionary.Add("plugin.patches_skipped", "Patches bereits angewendet, überspringe...");
				break;
			case "ja":
				dictionary.Add("plugin.initializing", "初期化中...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初期化に成功しました!");
				dictionary.Add("plugin.patches_skipped", "パッチは既に適用されています。スキップします...");
				break;
			case "ko":
				dictionary.Add("plugin.initializing", "초기화 중...");
				dictionary.Add("plugin.author_prefix", "작성자: ");
				dictionary.Add("plugin.initialized", "초기화 성공!");
				dictionary.Add("plugin.patches_skipped", "패치가 이미 적용되었습니다. 건너뛰는 중...");
				break;
			case "pt":
				dictionary.Add("plugin.initializing", "inicializando...");
				dictionary.Add("plugin.author_prefix", "Autor: ");
				dictionary.Add("plugin.initialized", "inicializado com sucesso!");
				dictionary.Add("plugin.patches_skipped", "Patches já aplicados, pulando...");
				break;
			case "ru":
				dictionary.Add("plugin.initializing", "инициализация...");
				dictionary.Add("plugin.author_prefix", "Автор: ");
				dictionary.Add("plugin.initialized", "инициализация прошла успешно!");
				dictionary.Add("plugin.patches_skipped", "Патчи уже применены, пропуск...");
				break;
			case "es":
				dictionary.Add("plugin.initializing", "inicializando...");
				dictionary.Add("plugin.author_prefix", "Autor: ");
				dictionary.Add("plugin.initialized", "¡inicializado con éxito!");
				dictionary.Add("plugin.patches_skipped", "Parches ya aplicados, omitiendo...");
				break;
			case "tr":
				dictionary.Add("plugin.initializing", "başlatılıyor...");
				dictionary.Add("plugin.author_prefix", "Yazar: ");
				dictionary.Add("plugin.initialized", "başarıyla başlatıldı!");
				dictionary.Add("plugin.patches_skipped", "Yamalar zaten uygulandı, atlanıyor...");
				break;
			case "uk":
				dictionary.Add("plugin.initializing", "ініціалізація...");
				dictionary.Add("plugin.author_prefix", "Автор: ");
				dictionary.Add("plugin.initialized", "ініціалізація пройшла успішно!");
				dictionary.Add("plugin.patches_skipped", "Патчі вже застосовані, пропуск...");
				break;
			}
			return dictionary;
		}
	}
	public class LocalizationManager
	{
		private static LocalizationManager _instance;

		private readonly Dictionary<string, Dictionary<string, string>> _localizations = new Dictionary<string, Dictionary<string, string>>();

		private string _currentLocale = "zh";

		public static readonly string[] SupportedLanguages = new string[12]
		{
			"zh", "zh-Hant", "en", "fr", "de", "ja", "ko", "pt", "ru", "es",
			"tr", "uk"
		};

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

		private LocalizationManager()
		{
			Initialize();
		}

		public void Initialize()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)LocalizationSettings.SelectedLocale != (Object)null)
			{
				LocaleIdentifier identifier = LocalizationSettings.SelectedLocale.Identifier;
				_currentLocale = ((LocaleIdentifier)(ref identifier)).Code;
			}
			string[] supportedLanguages = SupportedLanguages;
			foreach (string text in supportedLanguages)
			{
				Dictionary<string, string> defaultTranslations = LocalizationHelper.GetDefaultTranslations(text);
				if (defaultTranslations != null && defaultTranslations.Count > 0)
				{
					_localizations[text] = defaultTranslations;
				}
			}
			LocalizationSettings.SelectedLocaleChanged += OnGameLanguageChanged;
		}

		private void OnGameLanguageChanged(Locale locale)
		{
			//IL_000a: 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)
			if ((Object)(object)locale != (Object)null)
			{
				LocaleIdentifier identifier = locale.Identifier;
				string code = ((LocaleIdentifier)(ref identifier)).Code;
				if (_localizations.ContainsKey(code))
				{
					_currentLocale = code;
				}
				else
				{
					_currentLocale = "en";
				}
			}
		}

		public string GetLocalizedText(string key, params object[] args)
		{
			if (string.IsNullOrEmpty(_currentLocale) || !_localizations.ContainsKey(_currentLocale))
			{
				_currentLocale = "en";
			}
			if (_localizations.ContainsKey(_currentLocale) && _localizations[_currentLocale].TryGetValue(key, out var value))
			{
				if (args.Length == 0)
				{
					return value;
				}
				return string.Format(value, args);
			}
			if (_currentLocale != "en" && _localizations.ContainsKey("en") && _localizations["en"].TryGetValue(key, out var value2))
			{
				if (args.Length == 0)
				{
					return value2;
				}
				return string.Format(value2, args);
			}
			if (_localizations.ContainsKey("zh") && _localizations["zh"].TryGetValue(key, out var value3))
			{
				if (args.Length == 0)
				{
					return value3;
				}
				return string.Format(value3, args);
			}
			return key;
		}
	}
}