Decompiled source of RadRefinements v1.1.3

RadRefinements\RadRefinements.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ModSaveBackups;
using UnityEngine;
using cakeslice;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RadRefinements")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("raddude")]
[assembly: AssemblyProduct("RadRefinements")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c0c6b307-93f0-4209-8594-7f911e48e709")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.3.0")]
[module: UnverifiableCode]
namespace RadRefinements
{
	internal class PipePatches
	{
		[HarmonyPatch(typeof(ShipItem), "OnAltActivate")]
		private class ShipItemPatches
		{
			[CompilerGenerated]
			private sealed class <MovePipe>d__1 : IEnumerator<object>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private object <>2__current;

				public ShipItemPipe pipe;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <MovePipe>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						break;
					case 1:
						<>1__state = -1;
						break;
					}
					if (Object.op_Implicit((Object)(object)((PickupableItem)pipe).held) && (double)((PickupableItem)pipe).holdDistance > 0.25 && _clickedCount % 2 != 0 && ((ShipItem)pipe).amount > 0f)
					{
						((PickupableItem)pipe).holdDistance = Mathf.Lerp(((PickupableItem)pipe).holdDistance, 0.25f, Time.deltaTime * 4.44f);
						((PickupableItem)pipe).holdHeight = Mathf.Lerp(((PickupableItem)pipe).holdHeight, pipe.height, Time.deltaTime * 4.44f);
						((PickupableItem)pipe).heldRotationOffset = Mathf.Lerp(((PickupableItem)pipe).heldRotationOffset, 0f - pipe.maxRot, Time.deltaTime * pipe.rotRate);
						pipe.SetPrivateField("inhaling", !PipeExhaleEffect.instance.exhaling);
						pipe.SetPrivateField("drinking", true);
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					if (!Object.op_Implicit((Object)(object)((PickupableItem)pipe).held) || ((ShipItem)pipe).amount <= 0f)
					{
						_clickedCount = 0;
					}
					return false;
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			public static void Postfix(ShipItem __instance)
			{
				if (Configs.enableSingleClickSmoking.Value)
				{
					ShipItemPipe val = (ShipItemPipe)(object)((__instance is ShipItemPipe) ? __instance : null);
					if (val != null && ((ShipItem)val).sold)
					{
						_clickedCount++;
						((MonoBehaviour)__instance).StartCoroutine(MovePipe(val));
					}
				}
			}

			[IteratorStateMachine(typeof(<MovePipe>d__1))]
			private static IEnumerator MovePipe(ShipItemPipe pipe)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <MovePipe>d__1(0)
				{
					pipe = pipe
				};
			}
		}

		[HarmonyPatch(typeof(ShipItemPipe), "OnAltHeld")]
		public class ShipItemPipePatches
		{
			public static bool Prefix()
			{
				if (Configs.enableSingleClickSmoking.Value)
				{
					return false;
				}
				return true;
			}
		}

		private static int _clickedCount;
	}
	internal class Crate
	{
		public static string GetCrateInventory(ShipItemCrate crate)
		{
			CrateInventory privateField = crate.GetPrivateField<CrateInventory>("crateInventory");
			if ((Object)(object)privateField == (Object)null)
			{
				return string.Empty;
			}
			List<ShipItem> containedItems = privateField.containedItems;
			if (containedItems == null || containedItems.Count() == 0)
			{
				return string.Empty;
			}
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (ShipItem item in containedItems)
			{
				string description = ((GoPointerButton)item).description;
				description = (Enumerable.Contains(description, '<') ? description.Substring(0, description.IndexOf('<')) : description);
				description = (Enumerable.Contains(description, '%') ? item.name : description);
				description = (item.name.Equals("fishing hook") ? item.name : description);
				description = (item.name.Equals("knife") ? item.name : description);
				description = (Utility.IsNullOrWhiteSpace(description) ? item.name : description);
				if (!dictionary.ContainsKey(description))
				{
					dictionary[description] = 1;
				}
				else
				{
					dictionary[description]++;
				}
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("crate");
			foreach (KeyValuePair<string, int> item2 in dictionary.OrderBy((KeyValuePair<string, int> p) => p.Key))
			{
				stringBuilder.AppendLine($"{item2.Key}: {item2.Value}");
			}
			return stringBuilder.ToString();
		}
	}
	internal class KnifeWood : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <MakeLocalPosTracker>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public KnifeWood <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <MakeLocalPosTracker>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)CrateInventoryUI.instance.GetPrivateField<Transform>("localPosTracker") == (Object)null)
					{
						CrateInventoryUI.instance.SetPrivateField("localPosTracker", Object.Instantiate<GameObject>(new GameObject()).transform);
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private KnifeWoodCollider _knifeWoodCol;

		public void RegisterKnifeWoodCol(KnifeWoodCollider col)
		{
			_knifeWoodCol = col;
		}

		internal void CutContainer(ShipItem container)
		{
			//IL_00c2: 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_00d4: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			if ((container is ShipItemBottle && container.health > 0f) || (!(container is ShipItemBottle) && container.amount > 0f))
			{
				return;
			}
			ShipItemCrate val = (ShipItemCrate)(object)((container is ShipItemCrate) ? container : null);
			if (val == null || val.GetPrivateField<CrateInventory>("crateInventory").containedItems.Count() <= 0)
			{
				string key = ((Component)container).gameObject.GetComponent<Good>()?.sizeDescription ?? container.name;
				int num = Knife.WoodPiecesPerContainer[key];
				float num2 = -0.01f * (float)num;
				for (int i = 0; i < num; i++)
				{
					GameObject val2 = Object.Instantiate<GameObject>(PrefabsDirectory.instance.directory[71]);
					val2.transform.position = ((Component)container).transform.position + ((Component)container).transform.right * num2;
					val2.transform.rotation = ((Component)container).transform.rotation * Quaternion.Euler(0f, 90f, 0f);
					num2 += 0.02f;
					ShipItemStoveFuel component = val2.GetComponent<ShipItemStoveFuel>();
					((ShipItem)component).sold = true;
					val2.GetComponent<SaveablePrefab>().RegisterToSave();
				}
				((Component)container).GetComponent<ShipItem>().DestroyItem();
				((MonoBehaviour)this).StartCoroutine(MakeLocalPosTracker());
			}
		}

		[IteratorStateMachine(typeof(<MakeLocalPosTracker>d__3))]
		internal IEnumerator MakeLocalPosTracker()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <MakeLocalPosTracker>d__3(0)
			{
				<>4__this = this
			};
		}
	}
	internal class KnifeWoodCollider : MonoBehaviour
	{
		public ShipItem CurrentWood { get; private set; }

		private void Awake()
		{
			((Component)((Component)this).transform.parent).GetComponent<KnifeWood>().RegisterKnifeWoodCol(this);
		}

		public void OnTriggerEnter(Collider other)
		{
			ShipItem component = ((Component)other).GetComponent<ShipItem>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			RR_Plugin.LogDebug("KnifeCollider: entering wood col: " + component.name);
			if (!(component is ShipItemBottle) || !(component.health <= 0f))
			{
				if (!(component is ShipItemCrate))
				{
					return;
				}
				ShipItemCrate component2 = ((Component)component).gameObject.GetComponent<ShipItemCrate>();
				if (component2 == null || !(component2.GetPrivateField<CrateInventory>("crateInventory")?.containedItems.Count() <= 0))
				{
					return;
				}
			}
			CurrentWood = component;
		}

		public void OnTriggerExit(Collider other)
		{
			if ((Object)(object)((Component)other).GetComponent<ShipItem>() == (Object)(object)CurrentWood)
			{
				CurrentWood = null;
			}
		}
	}
	public class Knife
	{
		private static readonly Dictionary<string, int> _woodPiecesPerContainer = new Dictionary<string, int>
		{
			{ "small crate", 4 },
			{ "standard crate", 6 },
			{ "large crate", 8 },
			{ "very large crate", 10 },
			{ "standard barrel", 6 },
			{ "firewood", 4 },
			{ "fishing hooks", 4 },
			{ "lantern candles", 2 },
			{ "green tobacco", 2 },
			{ "blue tobacco", 2 },
			{ "black tobacco", 2 },
			{ "brown tobacco", 2 },
			{ "white tobacco", 2 },
			{ "empty crate", 6 },
			{ "sealing nails", 2 },
			{ "spoon lures", 2 },
			{ "swimbait lures", 2 },
			{ "topwater lures", 2 }
		};

		public static Dictionary<string, int> WoodPiecesPerContainer => _woodPiecesPerContainer;
	}
	internal class QuickSlots
	{
		public static void GetInventoryItem(int slotIndex, PickupableItem heldItem, GoPointer goPointer)
		{
			if (!Object.op_Implicit((Object)(object)heldItem) || (!heldItem.big && Configs.enableInventorySwap.Value))
			{
				GPButtonInventorySlot val = GPButtonInventorySlot.inventorySlots[slotIndex];
				if (!Object.op_Implicit((Object)(object)heldItem))
				{
					((GoPointerButton)val).OnActivate(goPointer);
				}
				else
				{
					((GoPointerButton)val).OnItemClick(heldItem);
				}
			}
		}

		public static void StowItem(int slotIndex, PickupableItem heldItem, GoPointer goPointer)
		{
			GPButtonInventorySlot val = GPButtonInventorySlot.inventorySlots[slotIndex];
			((GoPointerButton)val).OnActivate();
			((GoPointerButton)val).OnItemClick(heldItem);
			goPointer.GetHeldItem().OnDrop();
			goPointer.DropItem();
		}

		public static void ToggleInventoryItem(int slotIndex)
		{
			GoPointer goPntr = SwapSlot.GoPntr;
			PickupableItem heldItem = goPntr.GetHeldItem();
			if (Object.op_Implicit((Object)(object)heldItem))
			{
				StowItem(slotIndex, heldItem, goPntr);
			}
			else
			{
				GetInventoryItem(slotIndex, heldItem, goPntr);
			}
		}
	}
	internal class SwapSlot : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <GrabItem>d__14 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public ShipItem item;

			public SwapSlot <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GrabItem>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					GoPntr.SetPrivateField("heldItem", item);
					((Component)item).gameObject.layer = 2;
					GoPntr.GetPrivateField<PickupableItem>("heldItem").held = GoPntr;
					GoPntr.SetPrivateField("heldItemRot", Vector3.zero);
					GoPntr.SetPrivateField("timerAfterPickup", 0f);
					((PickupableItem)item).OnPickup();
					((Component)((Component)GoPntr).transform.parent).GetComponent<LookUI>().SetPrivateField("currentButton", ((Component)item).gameObject);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static SwapSlot Instance { get; private set; }

		internal static GPButtonInventorySlot Slot { get; private set; }

		internal static GoPointer GoPntr { get; set; }

		private void Awake()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Slot = new GPButtonInventorySlot();
		}

		public void SwapItems(PickupableItem item, GPButtonInventorySlot invSlot)
		{
			ShipItem component = ((Component)item).GetComponent<ShipItem>();
			if (!component.sold || !Object.op_Implicit((Object)(object)component) || ((PickupableItem)component).big)
			{
				return;
			}
			ShipItemBottle component2 = ((Component)item).GetComponent<ShipItemBottle>();
			if (!Object.op_Implicit((Object)(object)component2) || !(component2.GetCapacity() > 10f))
			{
				RR_Plugin.LogDebug("Inserting " + component.name + " into swap slot.");
				Slot.currentItem = component;
				item.held = null;
				((Component)component).GetComponent<Collider>().enabled = false;
				((Component)Slot.currentItem).gameObject.layer = 5;
				Transform[] componentsInChildren = ((Component)Slot.currentItem).GetComponentsInChildren<Transform>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Component)componentsInChildren[i]).gameObject.layer = 5;
				}
				ShipItem currentItem = invSlot.currentItem;
				RR_Plugin.LogDebug("Withdrawing " + currentItem.name + " from inventory slot.");
				GoPntr.PickUpItem((PickupableItem)(object)currentItem);
				((MonoBehaviour)this).StartCoroutine(GrabItem(currentItem));
				RR_Plugin.LogDebug("Moving " + Slot.currentItem.name + " from swap slot to inventory slot.");
				Debug.Log((object)"Inserting item.");
				Slot.currentItem.GetItemRigidbody().EnterInventorySlot(((Component)invSlot).transform);
				invSlot.currentItem = Slot.currentItem;
				UISoundPlayer.instance.PlayUISound((UISounds)4, 0.2f, 1.36f);
				Slot.currentItem = null;
				RR_Plugin.LogDebug("Items Swapped");
			}
		}

		[IteratorStateMachine(typeof(<GrabItem>d__14))]
		private IEnumerator GrabItem(ShipItem item)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GrabItem>d__14(0)
			{
				<>4__this = this,
				item = item
			};
		}

		internal static bool IsItemHeld()
		{
			return (Object)(object)GoPntr.GetHeldItem() != (Object)null;
		}

		internal void WithdrawFromSwapSlot()
		{
			ShipItem currentItem = Slot.currentItem;
			RR_Plugin.LogDebug("Withdrawing " + currentItem.name + " from inventory slot.");
			GoPntr.PickUpItem((PickupableItem)(object)currentItem);
			((MonoBehaviour)this).StartCoroutine(GrabItem(currentItem));
		}

		internal void SwapSlotToOpenInvSlot()
		{
			GPButtonInventorySlot val = ((IEnumerable<GPButtonInventorySlot>)GPButtonInventorySlot.inventorySlots).FirstOrDefault((Func<GPButtonInventorySlot, bool>)((GPButtonInventorySlot s) => (Object)(object)s.currentItem == (Object)null));
			Slot.currentItem.GetItemRigidbody().EnterInventorySlot(((Component)val).transform);
			val.currentItem = Slot.currentItem;
			Slot.currentItem = null;
		}
	}
	internal class ViewMap
	{
		public static string[] MapNames = new string[5] { "ocean map", "Al'Ankh map", "Emerald Archipelago map", "Aestrin map", "Fire Fish Lagoon map" };

		private static int _mapSlotIndex = 4;

		public static int MapSlotIndex
		{
			get
			{
				return _mapSlotIndex;
			}
			set
			{
				_mapSlotIndex = value;
			}
		}

		public static bool GetMapSlotIndex()
		{
			GPButtonInventorySlot val = ((IEnumerable<GPButtonInventorySlot>)GPButtonInventorySlot.inventorySlots).FirstOrDefault((Func<GPButtonInventorySlot, bool>)((GPButtonInventorySlot s) => Object.op_Implicit((Object)(object)s.currentItem) && MapNames.Contains(s.currentItem.name)));
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			_mapSlotIndex = val.slotIndex;
			return true;
		}

		public static void ToggleMap()
		{
			GoPointer goPntr = SwapSlot.GoPntr;
			PickupableItem heldItem = goPntr.GetHeldItem();
			string text = ((heldItem == null) ? null : ((Component)heldItem).GetComponent<ShipItem>()?.name);
			if (Object.op_Implicit((Object)(object)heldItem) && MapNames.Contains(text))
			{
				RR_Plugin.LogDebug("Stowing map: " + text);
				QuickSlots.StowItem(_mapSlotIndex, heldItem, goPntr);
			}
			else if (GetMapSlotIndex())
			{
				RR_Plugin.LogDebug("Displaying map: " + GPButtonInventorySlot.inventorySlots[_mapSlotIndex].currentItem.name);
				QuickSlots.GetInventoryItem(_mapSlotIndex, heldItem, goPntr);
				ShipItemFoldable component = ((Component)goPntr.GetHeldItem()).GetComponent<ShipItemFoldable>();
				if (((ShipItem)component).amount > 0f)
				{
					component.InvokePrivateMethod("Unfold");
				}
			}
		}
	}
	internal class ClockPatches
	{
		[HarmonyPatch(typeof(ShipItem))]
		private class ShipItemPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch("Awake")]
			public static void AddTextMesh(ShipItem __instance)
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				if (!(__instance.name != "chronometer"))
				{
					Transform val = Object.Instantiate<Transform>(((Component)DayLogs.instance).transform.parent.GetChild(0).GetChild(1));
					((Object)val).name = "clock_reading_text";
					val.SetParent(((Component)__instance).transform);
					((Component)val).gameObject.layer = 0;
					val.localEulerAngles = new Vector3(0f, 0f, 0f);
					val.localPosition = new Vector3(0f, 0.3f, -0.2f);
					((Component)val).GetComponent<TextMesh>().color = Color32.op_Implicit(new Color32((byte)219, (byte)214, (byte)201, (byte)136));
					((Component)val).GetComponent<TextMesh>().fontSize = 55;
					((Component)val).GetComponent<TextMesh>().fontStyle = (FontStyle)1;
					((Component)val).GetComponent<TextMesh>().anchor = (TextAnchor)1;
					((Component)val).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(ShipItemClock))]
		private class ShipItemClockPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("ExtraLateUpdate")]
			public static void AddReading(ShipItemClock __instance)
			{
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: 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)
				if ((!Configs.enableClockGlobalText.Value && !Configs.enableClockLocalText.Value) || !GameState.playing || GameState.currentlyLoading || GameState.loadingBoatLocalItems)
				{
					return;
				}
				Transform val = ((IEnumerable<Transform>)((Component)((Component)__instance).transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "clock_reading_text"));
				if (!((Object)(object)val == (Object)null))
				{
					if ((Object)(object)((PickupableItem)__instance).held != (Object)null || !((ShipItem)__instance).sold || ((Component)__instance).gameObject.layer == 5 || (Object)(object)((ShipItem)__instance).currentActualBoat == (Object)null || Vector3.Distance(((Component)Refs.observerMirror).transform.position, ((Component)__instance).transform.position) > Configs.clockViewableDistance.Value || Vector3.Angle(-((Component)__instance).transform.forward, ((Component)Refs.observerMirror).transform.position - ((Component)__instance).transform.position) > 85f || SpyglassPatches.HeldAndUp)
					{
						((Component)val).gameObject.SetActive(false);
						return;
					}
					((Component)val).GetComponent<TextMesh>().text = GetReading();
					((Component)val).gameObject.SetActive(true);
				}
			}
		}

		private static string GetReading()
		{
			float globalTime = Sun.sun.globalTime;
			float localTime = Sun.sun.localTime;
			if (!Configs.enableClockLocalText.Value)
			{
				return GetTime(globalTime);
			}
			if (!Configs.enableClockGlobalText.Value)
			{
				return GetTime(localTime);
			}
			return GetTime(globalTime) + "\n\n\n\n" + GetTime(localTime);
		}

		private static string GetTime(float time)
		{
			int num = (int)time;
			double num2 = Math.Round(time % 1f * 60f) % 60.0;
			return $"{num:00}:{num2:00}";
		}
	}
	internal class CompassPatches
	{
		[HarmonyPatch(typeof(ShipItemCompass))]
		private class ShipItemCompassPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch("OnLoad")]
			public static void AddTextMesh(ShipItemCompass __instance)
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				if (!(((ShipItem)__instance).name != "compass"))
				{
					Transform val = Object.Instantiate<Transform>(((Component)DayLogs.instance).transform.parent.GetChild(0).GetChild(1));
					((Object)val).name = "compass_reading_text";
					val.SetParent(((Component)__instance).transform);
					((Component)val).gameObject.layer = 0;
					val.localEulerAngles = new Vector3(0f, 0f, 0f);
					val.localPosition = new Vector3(0f, 0.02f, 0f);
					((Component)val).GetComponent<TextMesh>().color = Color32.op_Implicit(new Color32((byte)219, (byte)214, (byte)201, (byte)136));
					((Component)val).GetComponent<TextMesh>().fontSize = 55;
					((Component)val).GetComponent<TextMesh>().fontStyle = (FontStyle)0;
					((Component)val).GetComponent<TextMesh>().anchor = (TextAnchor)7;
					((Component)val).GetComponent<TextMesh>().lineSpacing = 0.7f;
					((Component)val).gameObject.SetActive(false);
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("ExtraLateUpdate")]
			public static void AddReading(ShipItemCompass __instance)
			{
				//IL_011b: 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_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				if ((!Configs.enableCompassDegreesText.Value && !Configs.enableCompassCardinalText.Value) || !GameState.playing || GameState.currentlyLoading || GameState.loadingBoatLocalItems || ((ShipItem)__instance).name != "compass")
				{
					return;
				}
				Transform val = ((IEnumerable<Transform>)((Component)((Component)__instance).transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "compass_reading_text"));
				if (!((Object)(object)val == (Object)null))
				{
					if (((Object)(object)((PickupableItem)__instance).held != (Object)null && !Configs.enableCompassReadingHeld.Value) || !((ShipItem)__instance).sold || ((Component)__instance).gameObject.layer == 5 || (Object)(object)((ShipItem)__instance).currentActualBoat == (Object)null || Vector3.Distance(((Component)Refs.observerMirror).transform.position, ((Component)__instance).transform.position) > Configs.compassViewableDistance.Value || SpyglassPatches.HeldAndUp)
					{
						((Component)val).gameObject.SetActive(false);
						return;
					}
					float num = Vector3.SignedAngle(-((Component)__instance).transform.forward, ((Component)Refs.observerMirror).transform.position - ((Component)__instance).transform.position, Vector3.up);
					num = (((Object)(object)((PickupableItem)__instance).held != (Object)null) ? 0f : num);
					val.localEulerAngles = new Vector3(0f, num, 0f);
					((Component)val).GetComponent<TextMesh>().fontSize = (((Object)(object)((PickupableItem)__instance).held != (Object)null) ? 25 : 55);
					((Component)val).GetComponent<TextMesh>().text = GetReading(((Component)__instance).transform.eulerAngles.y);
					((Component)val).gameObject.SetActive(true);
				}
			}

			private static string GetReading(float reading)
			{
				if (!Configs.enableCompassCardinalText.Value)
				{
					return $"{Math.Round(reading)}°";
				}
				if (!Configs.enableCompassDegreesText.Value)
				{
					return CompassRose.GetAbbreviatedDirection(reading, Configs.compassCardinalPrecisionLevel.Value);
				}
				return $"{CompassRose.GetAbbreviatedDirection(reading, Configs.compassCardinalPrecisionLevel.Value)}\n{Math.Round(reading)}°";
			}
		}
	}
	internal class FishingHookPatches
	{
		[HarmonyPatch(typeof(ShipItem))]
		private class ShipItemFishingHookPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnLoad")]
			public static void OnLoadRemoveDescription(ShipItem __instance)
			{
				if (Configs.removeItemHints.Value && __instance.sold && __instance is ShipItemFishingHook)
				{
					((GoPointerButton)__instance).description = "";
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("EnterBoat")]
			public static void EnterBoatRemoveDescription(ShipItem __instance)
			{
				if (Configs.removeItemHints.Value && __instance.sold && __instance is ShipItemFishingHook)
				{
					((GoPointerButton)__instance).description = "";
				}
			}
		}
	}
	internal class InventoryPatches
	{
		[HarmonyPatch(typeof(LookUI))]
		private class LookUIPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch("RegisterPointer")]
			public static void GetPointer(GoPointer goPointer)
			{
				SwapSlot.GoPntr = goPointer;
			}

			[HarmonyPostfix]
			[HarmonyPatch("LateUpdate")]
			public static void ToggleQuickMap()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				if (Configs.enableQuickMap.Value && !GameState.wasInSettingsMenu && Input.GetKeyDown(Configs.quickMapKey.Value))
				{
					ViewMap.ToggleMap();
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("LateUpdate")]
			public static void ToggleQuickSlot()
			{
				//IL_0023: 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_005b: 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_0095: Unknown result type (might be due to invalid IL or missing references)
				if (Configs.enableQuickSlots.Value && !GameState.wasInSettingsMenu)
				{
					if (Input.GetKeyDown(Configs.quickSlot1Key.Value))
					{
						QuickSlots.ToggleInventoryItem(0);
					}
					if (Input.GetKeyDown(Configs.quickSlot2Key.Value))
					{
						QuickSlots.ToggleInventoryItem(1);
					}
					if (Input.GetKeyDown(Configs.quickSlot3Key.Value))
					{
						QuickSlots.ToggleInventoryItem(2);
					}
					if (Input.GetKeyDown(Configs.quickSlot4Key.Value))
					{
						QuickSlots.ToggleInventoryItem(3);
					}
					if (Input.GetKeyDown(Configs.quickSlot5Key.Value))
					{
						QuickSlots.ToggleInventoryItem(4);
					}
				}
			}
		}

		[HarmonyPatch(typeof(GPButtonInventorySlot))]
		private class GPButtonInventorySlotPatches
		{
			private static bool swapSlotMade;

			[HarmonyPrefix]
			[HarmonyPatch("Awake")]
			public static void Awake(GPButtonInventorySlot __instance)
			{
				if (!swapSlotMade)
				{
					swapSlotMade = true;
					Transform parent = ((Component)__instance).transform.parent;
					Transform val = Object.Instantiate<Transform>(parent.GetChild(0), parent);
					((Object)val).name = "inventory_slot_swap";
					Object.Destroy((Object)(object)((Component)val).GetComponent<MeshFilter>());
					Object.Destroy((Object)(object)((Component)val).GetComponent<MeshRenderer>());
					Object.Destroy((Object)(object)((Component)val).GetComponent<SphereCollider>());
					Object.Destroy((Object)(object)((Component)val).GetComponent<GPButtonInventorySlot>());
					Object.Destroy((Object)(object)((Component)val).GetComponent<Outline>());
					((Component)val).gameObject.AddComponent<SwapSlot>();
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch("OnItemClick")]
			public static void OnItemClickSwapItems(PickupableItem heldItem, ShipItem ___currentItem, GPButtonInventorySlot __instance)
			{
				if (Configs.enableInventorySwap.Value && Object.op_Implicit((Object)(object)___currentItem))
				{
					SwapSlot.Instance.SwapItems(heldItem, __instance);
				}
			}
		}

		[HarmonyPatch(typeof(CrateInventoryUI))]
		public class CrateInventoryUIPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("Update")]
			public static void AddItemDescription(CrateInventoryButton[] ___buttons)
			{
				if (Configs.enableCrateItemDescription.Value)
				{
					foreach (CrateInventoryButton val in ___buttons)
					{
						((GoPointerButton)val).description = ((GoPointerButton)(val.GetPrivateField<ShipItem>("currentItem")?)).description ?? "";
					}
				}
			}
		}
	}
	internal class KnifePatches
	{
		[HarmonyPatch(typeof(ShipItemKnife))]
		private class ShipItemKnifePatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnAltActivate")]
			public static void KnifeCutContainer(ShipItemKnife __instance, ref bool ___animating, ref float ___heldRotationOffset, ref float ___cutTimer)
			{
				if (Configs.enableWoodFromContainers.Value && ((ShipItem)__instance).sold)
				{
					ShipItem pointedAtItem = ((PickupableItem)__instance).held.GetPointedAtItem();
					Good component = ((Component)pointedAtItem).gameObject.GetComponent<Good>();
					if (Object.op_Implicit((Object)(object)pointedAtItem) && pointedAtItem.sold && (Knife.WoodPiecesPerContainer.ContainsKey(pointedAtItem.name) || ((Object)(object)component != (Object)null && Knife.WoodPiecesPerContainer.ContainsKey(component.sizeDescription))))
					{
						___animating = true;
						___heldRotationOffset = 0f;
						___cutTimer = 0.25f;
						KnifeWood component2 = ((Component)__instance).GetComponent<KnifeWood>();
						component2.CutContainer(((Component)pointedAtItem).GetComponent<ShipItem>());
					}
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("OnLoad")]
			public static void OnLoadPatch(ShipItemKnife __instance)
			{
				if (Configs.removeItemHints.Value && ((ShipItem)__instance).sold)
				{
					((GoPointerButton)__instance).description = "";
				}
				((Component)__instance).gameObject.AddComponent<KnifeWood>();
			}
		}

		[HarmonyPatch(typeof(LookUI))]
		private class LookUIPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch("ShowLookText")]
			public static bool AddKnifeControlsText(LookUI __instance, GoPointerButton button, GoPointer ___pointer, TextMesh ___textLicon, TextMesh ___textRIcon, ref bool ___showingIcon, TextMesh ___controlsText, TextMesh ___extraText)
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				if (!Configs.enableWoodFromContainers.Value)
				{
					return true;
				}
				___extraText.text = button.lookText;
				((Component)__instance).transform.position = ((Component)button).gameObject.transform.position;
				((Component)__instance).transform.LookAt(((Component)Camera.main).transform);
				((Component)___textLicon).gameObject.SetActive(false);
				((Component)___textRIcon).gameObject.SetActive(false);
				___showingIcon = false;
				Good component = ((Component)button).gameObject.GetComponent<Good>();
				ShipItem component2 = ((Component)button).gameObject.GetComponent<ShipItem>();
				if (Object.op_Implicit((Object)(object)___pointer.GetHeldItem()) && Object.op_Implicit((Object)(object)((Component)___pointer.GetHeldItem()).GetComponent<ShipItemKnife>()) && (((Object)(object)component2 != (Object)null && Knife.WoodPiecesPerContainer.ContainsKey(component2.name)) || ((Object)(object)component != (Object)null && Knife.WoodPiecesPerContainer.ContainsKey(component.sizeDescription))))
				{
					((Component)___textRIcon).gameObject.SetActive(true);
					___showingIcon = true;
					___controlsText.text = "\ncut";
					return false;
				}
				return true;
			}
		}
	}
	internal class LogBookPatches
	{
		[HarmonyPatch(typeof(MissionListUI))]
		private class MissionListUIPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("ToggleMenu")]
			public static void OpenLastOpenBookmark(MissionListUI __instance, bool ___UIActive)
			{
				if (Configs.enableLogbookLastSection.Value && ___UIActive)
				{
					__instance.SwitchMode((MissionListMode)_currentPage);
				}
			}
		}

		[HarmonyPatch(typeof(GPButtonLogMode))]
		private class GPButtonLogModePatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnActivate")]
			public static void GetLastActivatedBookmark(MissionListMode ___mode)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Expected I4, but got Unknown
				if (Configs.enableLogbookLastSection.Value)
				{
					_currentPage = (int)___mode;
				}
			}
		}

		private static int _currentPage;
	}
	internal class QuadrantPatches
	{
		[HarmonyPatch(typeof(ShipItemQuadrant))]
		private class ShipItemQuadrantPatches
		{
			[CompilerGenerated]
			private sealed class <Rotate180>d__4 : IEnumerator<object>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private object <>2__current;

				public Transform rotatingParent;

				private Quaternion <startRotation>5__1;

				private Quaternion <rotation180>5__2;

				private Quaternion <targetRotation>5__3;

				private float <elapsedTime>5__4;

				private float <t>5__5;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <Rotate180>d__4(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//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_0040: 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_004a: 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_0057: Unknown result type (might be due to invalid IL or missing references)
					//IL_005c: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
					//IL_0109: Unknown result type (might be due to invalid IL or missing references)
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						_rotating = true;
						<startRotation>5__1 = rotatingParent.rotation;
						<rotation180>5__2 = Quaternion.AngleAxis(180f, Vector3.up);
						<targetRotation>5__3 = <startRotation>5__1 * <rotation180>5__2;
						<elapsedTime>5__4 = 0f;
						break;
					case 1:
						<>1__state = -1;
						break;
					}
					if (<elapsedTime>5__4 < 0.3f)
					{
						<t>5__5 = <elapsedTime>5__4 / 0.3f;
						<t>5__5 = Mathf.SmoothStep(0f, 1f, <t>5__5);
						rotatingParent.rotation = Quaternion.Slerp(<startRotation>5__1, <targetRotation>5__3, <t>5__5);
						<elapsedTime>5__4 += Time.deltaTime;
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					rotatingParent.rotation = <targetRotation>5__3;
					_rotating = false;
					return false;
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			private static bool _rotating;

			[HarmonyPrefix]
			[HarmonyPatch("OnLoad")]
			public static void AddTextMesh(ShipItemQuadrant __instance)
			{
				//IL_0082: 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)
				//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)
				Transform val = Object.Instantiate<Transform>(((Component)DayLogs.instance).transform.parent.GetChild(0).GetChild(1));
				((Object)val).name = "quadrant_reading_text";
				val.SetParent(((IEnumerable<Transform>)((Component)((Component)__instance).transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "dial")));
				((Component)val).gameObject.layer = 2;
				val.localEulerAngles = new Vector3(0f, 90f, 270f);
				val.localPosition = new Vector3(-0.025f, -0.19f, -0.03f);
				((Component)val).GetComponent<TextMesh>().color = Color32.op_Implicit(new Color32((byte)219, (byte)214, (byte)201, (byte)136));
				((Component)val).GetComponent<TextMesh>().fontSize = 15;
				((Component)val).GetComponent<TextMesh>().fontStyle = (FontStyle)0;
				((Component)val).GetComponent<TextMesh>().richText = true;
				((Component)val).gameObject.SetActive(false);
			}

			[HarmonyPostfix]
			[HarmonyPatch("ExtraLateUpdate")]
			public static void AddReading(ShipItemQuadrant __instance)
			{
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				if (!Configs.enableQuadrantText.Value || !GameState.playing || GameState.currentlyLoading || GameState.loadingBoatLocalItems)
				{
					return;
				}
				Transform val = ((IEnumerable<Transform>)((Component)((Component)__instance).transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "quadrant_reading_text"));
				if (!((Object)(object)val == (Object)null))
				{
					if (!__instance.GetPrivateField<bool>("inspecting") || __instance.GetPrivateField<bool>("rotating"))
					{
						((Component)val).gameObject.SetActive(false);
						return;
					}
					Transform privateField = __instance.GetPrivateField<Transform>("dial");
					double num = Math.Round(privateField.localEulerAngles.x, 2);
					((Component)val).GetComponent<TextMesh>().text = $"{num}°";
					((Component)val).gameObject.SetActive(true);
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch("OnAltActivate")]
			public static bool ReverseLook(ShipItemQuadrant __instance, bool ___inspecting, Transform ___rotatingParent, ref Quaternion ___initialRot)
			{
				//IL_002c: 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_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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_004a: Unknown result type (might be due to invalid IL or missing references)
				if (Input.GetKey((KeyCode)101) && !___inspecting && !_rotating)
				{
					((MonoBehaviour)__instance).StartCoroutine(Rotate180(___rotatingParent));
					___initialRot *= Quaternion.Euler(Vector3.up * 180f);
					return false;
				}
				return true;
			}

			[IteratorStateMachine(typeof(<Rotate180>d__4))]
			private static IEnumerator Rotate180(Transform rotatingParent)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Rotate180>d__4(0)
				{
					rotatingParent = rotatingParent
				};
			}
		}
	}
	internal class SaveLoadPatches
	{
		[HarmonyPatch(typeof(SaveLoadManager))]
		private class SaveLoadManagerPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("SaveModData")]
			public static void DoSaveGamePatch()
			{
				RadRefinementsSaveContainer radRefinementsSaveContainer = new RadRefinementsSaveContainer
				{
					swapSlotHasItem = ((Object)(object)SwapSlot.Slot.currentItem != (Object)null),
					mapSlotIndex = ViewMap.MapSlotIndex
				};
				ModSave.Save(((BaseUnityPlugin)RR_Plugin.Instance).Info, (object)radRefinementsSaveContainer);
			}

			[HarmonyPostfix]
			[HarmonyPatch("LoadModData")]
			public static void LoadModDataPatch()
			{
				RadRefinementsSaveContainer radRefinementsSaveContainer = default(RadRefinementsSaveContainer);
				if (!ModSave.Load<RadRefinementsSaveContainer>(((BaseUnityPlugin)RR_Plugin.Instance).Info, ref radRefinementsSaveContainer))
				{
					RR_Plugin.LogWarning("Save file loading failed. If this is the first time loading this save with this mod, this is normal.");
					return;
				}
				ViewMap.MapSlotIndex = radRefinementsSaveContainer.mapSlotIndex;
				if (radRefinementsSaveContainer.swapSlotHasItem)
				{
					RR_Plugin.LogWarning("Loaded game with item in swap slot, moving it to held or open inventory slot");
					if (SwapSlot.IsItemHeld())
					{
						SwapSlot.Instance.SwapSlotToOpenInvSlot();
					}
					else
					{
						SwapSlot.Instance.WithdrawFromSwapSlot();
					}
				}
			}
		}
	}
	[Serializable]
	public class RadRefinementsSaveContainer
	{
		public bool swapSlotHasItem;

		public int mapSlotIndex;
	}
	internal class SpyglassPatches
	{
		[HarmonyPatch(typeof(ShipItemSpyglass))]
		private static class ShipItemSpyglassPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnAltActivate")]
			public static void DisableItemReadingsActivate(ShipItemSpyglass __instance, float ___heldRotationOffset)
			{
				if (((ShipItem)__instance).sold && ___heldRotationOffset == -22f)
				{
					HeldAndUp = true;
				}
				else
				{
					HeldAndUp = false;
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("OnPickup")]
			public static void DisableItemReadingsOnPickup(ShipItemSpyglass __instance, float ___heldRotationOffset)
			{
				if (((ShipItem)__instance).sold && ___heldRotationOffset == 0f)
				{
					HeldAndUp = true;
				}
				else
				{
					HeldAndUp = false;
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("OnEnterInventory")]
			public static void EnableItemReadingsInventory()
			{
				HeldAndUp = false;
			}

			[HarmonyPostfix]
			[HarmonyPatch("OnDrop")]
			public static void EnableItemReadingsDrop()
			{
				HeldAndUp = false;
			}
		}

		internal static bool HeldAndUp { get; private set; }
	}
	[BepInPlugin("com.raddude82.radrefinements", "RadRefinements", "1.1.3")]
	[BepInDependency("com.raddude82.modsavebackups", "1.1.1")]
	public class RR_Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "com.raddude82.radrefinements";

		public const string PLUGIN_NAME = "RadRefinements";

		public const string PLUGIN_VERSION = "1.1.3";

		public const string MODSAVEBACKUPS_GUID = "com.raddude82.modsavebackups";

		public const string MODSAVEBACKUPS_VERSION = "1.1.1";

		private static ManualLogSource _logger;

		internal static RR_Plugin Instance { get; private set; }

		internal static void LogDebug(string message)
		{
			_logger.LogDebug((object)message);
		}

		internal static void LogInfo(string message)
		{
			_logger.LogInfo((object)message);
		}

		internal static void LogWarning(string message)
		{
			_logger.LogWarning((object)message);
		}

		internal static void LogError(string message)
		{
			_logger.LogError((object)message);
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			_logger = ((BaseUnityPlugin)this).Logger;
			Configs.InitializeConfigs();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.raddude82.radrefinements");
		}
	}
	public static class CompassRose
	{
		public static string GetCardinalDirection(float degrees, int precision)
		{
			switch (precision)
			{
			case 4:
			{
				string[] array4 = new string[5] { "North", "East", "South", "West", "North" };
				int num4 = (int)Math.Round((double)degrees / 90.0) % 4;
				return array4[num4];
			}
			case 8:
			{
				string[] array3 = new string[9] { "North", "Northeast", "East", "Southeast", "South", "Southwest", "West", "Northwest", "North" };
				int num3 = (int)Math.Round((double)degrees / 45.0) % 8;
				return array3[num3];
			}
			case 16:
			{
				string[] array2 = new string[17]
				{
					"North", "North-northeast", "Northeast", "East-northeast", "East", "East-southeast", "Southeast", "South-southeast", "South", "South-southwest",
					"Southwest", "West-southwest", "West", "West-northwest", "Northwest", "North-northwest", "North"
				};
				int num2 = (int)Math.Round((double)degrees / 22.5) % 16;
				return array2[num2];
			}
			default:
			{
				string[] array = new string[33]
				{
					"North", "North by east", "North-northeast", "Northeast by north", "Northeast", "Northeast by east", "East-northeast", "East by north", "East", "East by south",
					"East-southeast", "Southeast by east", "Southeast", "Southeast by south", "South-southeast", "South by east", "South", "South by west", "South-southwest", "Southwest by south",
					"Southwest", "Southwest by west", "West-southwest", "West by south", "West", "West by north", "West-northwest", "Northwest by west", "Northwest", "Northwest by north",
					"North-northwest", "North by west", "North"
				};
				int num = (int)Math.Round((double)degrees / 11.25) % 32;
				return array[num];
			}
			}
		}

		public static string GetAbbreviatedDirection(float degrees, int precision)
		{
			string cardinalDirection = GetCardinalDirection(degrees, precision);
			return cardinalDirection.ToLower().Replace("north", "N").Replace("east", "E")
				.Replace("south", "S")
				.Replace("west", "W")
				.Replace("-", "")
				.Replace(" by ", "b");
		}
	}
	internal class Configs
	{
		internal static ConfigEntry<bool> enableInventorySwap;

		internal static ConfigEntry<bool> enableQuickMap;

		internal static ConfigEntry<KeyCode> quickMapKey;

		internal static ConfigEntry<bool> enableQuickSlots;

		internal static ConfigEntry<KeyCode> quickSlot1Key;

		internal static ConfigEntry<KeyCode> quickSlot2Key;

		internal static ConfigEntry<KeyCode> quickSlot3Key;

		internal static ConfigEntry<KeyCode> quickSlot4Key;

		internal static ConfigEntry<KeyCode> quickSlot5Key;

		internal static ConfigEntry<bool> enableCrateItemDescription;

		internal static ConfigEntry<bool> enableQuadrantText;

		internal static ConfigEntry<bool> enableCompassReadingHeld;

		internal static ConfigEntry<bool> enableCompassDegreesText;

		internal static ConfigEntry<bool> enableCompassCardinalText;

		internal static ConfigEntry<int> compassCardinalPrecisionLevel;

		internal static ConfigEntry<float> compassViewableDistance;

		internal static ConfigEntry<bool> enableClockGlobalText;

		internal static ConfigEntry<bool> enableClockLocalText;

		internal static ConfigEntry<float> clockViewableDistance;

		internal static ConfigEntry<bool> enableWoodFromContainers;

		internal static ConfigEntry<bool> enableCrateInvCountText;

		internal static ConfigEntry<KeyCode> crateInvCountTextKey;

		internal static ConfigEntry<bool> removeItemHints;

		internal static ConfigEntry<bool> enableElixirColors;

		internal static ConfigEntry<bool> enableLogbookLastSection;

		internal static ConfigEntry<bool> enableSingleClickSmoking;

		internal static void InitializeConfigs()
		{
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)RR_Plugin.Instance).Config;
			enableInventorySwap = config.Bind<bool>("Inventory Settings", "Enable inventory swap", true, "Allows you to swap the item you are holding with the item in your selected inventory slot.");
			enableQuickMap = config.Bind<bool>("Inventory Settings", "Enable quick map", true, "On quick map key press, causes your character to hold the leftmost map that is in your inventory slots or to put it back in the inventory slot it came from.");
			quickMapKey = config.Bind<KeyCode>("Inventory Settings", "Quick map key", (KeyCode)109, "Key that retrieves or stows your map when pressed");
			enableQuickSlots = config.Bind<bool>("Inventory Settings", "Enable quick slots", true, "Enables the ability to retrieve items from your inventory when a key is pressed.");
			quickSlot1Key = config.Bind<KeyCode>("Inventory Settings", "Quick slot 1 key", (KeyCode)49, "Key that retrieves from or stows to inventory slot 1 when pressed");
			quickSlot2Key = config.Bind<KeyCode>("Inventory Settings", "Quick slot 2 key", (KeyCode)50, "Key that retrieves from or stows to inventory slot 2 when pressed");
			quickSlot3Key = config.Bind<KeyCode>("Inventory Settings", "Quick slot 3 key", (KeyCode)51, "Key that retrieves from or stows to inventory slot 3 when pressed");
			quickSlot4Key = config.Bind<KeyCode>("Inventory Settings", "Quick slot 4 key", (KeyCode)52, "Key that retrieves from or stows to inventory slot 4 when pressed");
			quickSlot5Key = config.Bind<KeyCode>("Inventory Settings", "Quick slot 5 key", (KeyCode)53, "Key that retrieves from or stows to inventory slot 5 when pressed");
			enableCrateItemDescription = config.Bind<bool>("Inventory Settings", "Enable crate item description", true, "Allows you to see the text you would see when looking at the item out of the crate.");
			enableQuadrantText = config.Bind<bool>("Item Text Settings", "Enable quadrant reading text", true, "Enables the text that shows the quadrant reading value.");
			enableCompassReadingHeld = config.Bind<bool>("Item Text Settings", "Enable compass reading while held", false, "Enables the text that shows the compass reading while holding the compass.");
			enableCompassDegreesText = config.Bind<bool>("Item Text Settings", "Enable compass reading degrees text", true, "Enables the text that shows the compass reading value in degrees.");
			enableCompassCardinalText = config.Bind<bool>("Item Text Settings", "Enable compass reading cardinal text", true, "Enables the text that shows the compass reading value in cardinal directions.");
			compassCardinalPrecisionLevel = config.Bind<int>("Item Text Settings", "Number of compass ordinal directions", 16, new ConfigDescription("Number of ordinal directions given in the compass reading.", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[4] { 4, 8, 16, 32 }), Array.Empty<object>()));
			compassViewableDistance = config.Bind<float>("Item Text Settings", "Compass viewable distance", 3f, "Sets the how close player needs to be to see compass reading text");
			enableClockGlobalText = config.Bind<bool>("Item Text Settings", "Enable clock global time text", true, "Enables the text that shows the global time on the clock.");
			enableClockLocalText = config.Bind<bool>("Item Text Settings", "Enable clock local time text", true, "Enables the text that shows the clock time on the clock.");
			clockViewableDistance = config.Bind<float>("Item Text Settings", "Clock viewable distance", 7f, "Sets the how close player needs to be to see clock time text");
			enableWoodFromContainers = config.Bind<bool>("Other Settings", "Enable wood from breaking containers", true, "Allows you to get firewood by breaking containers with a knife.");
			enableCrateInvCountText = config.Bind<bool>("Other Settings", "Enable crate total count text", true, "Enables the look text that shows the number of items in a crate.");
			crateInvCountTextKey = config.Bind<KeyCode>("Other Settings", "Crate inventory count text key", (KeyCode)101, "Crate inventory count text will show when holding this key.");
			removeItemHints = config.Bind<bool>("Other Settings", "Remove item hints", false, "Removes the hint text that appears when you look at a common items (e.g., knife, fishing hook).");
			enableElixirColors = config.Bind<bool>("Other Settings", "Enable elixir colors", true, "Makes the bottles for Energy Elixir blue and Snake Oil brown.");
			enableLogbookLastSection = config.Bind<bool>("Other Settings", "Logbook remembers last section", true, "Makes the logbook remember the last section you had open so when you reopen it, it opens to that section.");
			enableSingleClickSmoking = config.Bind<bool>("Other Settings", "Enable single click smoking", false, "Allows you to smoke a pipe with a single click instead of having to hold the button down.");
		}
	}
	internal static class Extensions
	{
		public static T GetPrivateField<T>(this object obj, string field)
		{
			return (T)Traverse.Create(obj).Field(field).GetValue();
		}

		public static void SetPrivateField(this object obj, string field, object value)
		{
			Traverse.Create(obj).Field(field).SetValue(value);
		}

		public static void SetPrivateField<T>(string field, object value)
		{
			Traverse.Create(typeof(T)).Field(field).SetValue(value);
		}

		public static object InvokePrivateMethod(this object obj, string method, params object[] parameters)
		{
			return AccessTools.Method(obj.GetType(), method, (Type[])null, (Type[])null).Invoke(obj, parameters);
		}

		public static T InvokePrivateMethod<T>(this object obj, string method, params object[] parameters)
		{
			return (T)obj.InvokePrivateMethod(method, parameters);
		}

		public static object InvokePrivateMethod<T>(string method, params object[] parameters)
		{
			return AccessTools.Method(typeof(T), method, (Type[])null, (Type[])null).Invoke(null, parameters);
		}

		public static T InvokePrivateMethod<T, E>(string method, params object[] parameters)
		{
			return (T)InvokePrivateMethod<E>(method, parameters);
		}
	}
}
namespace RadRefinements.Patches
{
	internal class CratePatches
	{
		[HarmonyPatch(typeof(ShipItemCrate))]
		private class ShipItemCratePatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("UpdateLookText")]
			public static void AddNumItemsText(ShipItemCrate __instance, Good ___goodC, CrateInventory ___crateInventory)
			{
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				if (Configs.enableCrateInvCountText.Value && ((ShipItem)__instance).sold && !(((ShipItem)__instance).amount > 0f) && Object.op_Implicit((Object)(object)___crateInventory) && (!Object.op_Implicit((Object)(object)___goodC) || ___goodC.GetMissionIndex() <= -1))
				{
					string text = string.Empty;
					if (Input.GetKey(Configs.crateInvCountTextKey.Value))
					{
						text = Crate.GetCrateInventory(__instance);
					}
					((GoPointerButton)__instance).lookText = (Utility.IsNullOrWhiteSpace(text) ? $"{((GoPointerButton)__instance).lookText}\n{___crateInventory.containedItems.Count()} items" : text);
				}
			}
		}
	}
	internal class ElixirPatches
	{
		[HarmonyPatch(typeof(ShipItem), "Awake")]
		private static class ShipItemPatch
		{
			private static readonly Color32 snakeOilColor = new Color32(byte.MaxValue, byte.MaxValue, (byte)0, byte.MaxValue);

			private static readonly Color32 energyElixirColor = new Color32((byte)0, byte.MaxValue, byte.MaxValue, byte.MaxValue);

			[HarmonyPostfix]
			public static void Postfix(ShipItem __instance)
			{
				//IL_0045: 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_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)
				if (Configs.enableElixirColors.Value && __instance is ShipItemElixir)
				{
					MeshRenderer component = ((Component)__instance).GetComponent<MeshRenderer>();
					if (__instance.name == "snake oil")
					{
						((Renderer)component).materials[0].color = Color32.op_Implicit(snakeOilColor);
					}
					else if (__instance.name == "energy elixir")
					{
						((Renderer)component).materials[0].color = Color32.op_Implicit(energyElixirColor);
					}
				}
			}
		}
	}
}