Decompiled source of RadRefinements v1.0.13

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 Crest;
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.0.13.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.13.0")]
[module: UnverifiableCode]
namespace RadRefinements
{
	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 = (string.IsNullOrEmpty(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 FishMovement : MonoBehaviour
	{
		private static readonly Dictionary<string, float> fishForces = new Dictionary<string, float>
		{
			{ "31 templefish (A)", 10f },
			{ "32 sunspot fish (A)", 13f },
			{ "46 tuna (A)", 20f },
			{ "35 shimmertail (E)", 18f },
			{ "33 salmon (E)", 26f },
			{ "34 eel (E)", 30f },
			{ "38 blackfin hunter (M)", 20f },
			{ "36 trout (M)", 25f },
			{ "37 north fish (M)", 22f },
			{ "141 swamp fish 1 (snapper", 21f },
			{ "142 swamp fish 2 (bubbler)", 15f },
			{ "148 swamp fish 3", 28f }
		};

		private float t;

		private float force;

		internal FishingRodFish fish;

		private void Awake()
		{
			t = 0f;
			force = 0f;
		}

		private void Update()
		{
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			if (GameState.wasInSettingsMenu)
			{
				return;
			}
			bool privateField = fish.GetPrivateField<bool>("fishDead");
			float privateField2 = fish.GetPrivateField<float>("lastLineLength");
			float privateField3 = fish.GetPrivateField<float>("fishEnergy");
			SimpleFloatingObject privateField4 = fish.GetPrivateField<SimpleFloatingObject>("floater");
			Rigidbody privateField5 = fish.GetPrivateField<Rigidbody>("bobber");
			privateField = privateField && privateField2 <= 15f;
			fish.SetPrivateField("fishDead", privateField);
			if (privateField || fish.currentFish == null || privateField3 <= 0f || !((FloatingObjectBase)privateField4).InWater)
			{
				force = 0f;
				privateField4.SetPrivateField("_buoyancyCoeff", 3f);
				return;
			}
			if (force == 0f)
			{
				if (fishForces.ContainsKey(((Object)fish.currentFish).name))
				{
					force = fishForces[((Object)fish.currentFish).name];
				}
				else
				{
					force = 10f;
					Plugin.logger.LogDebug((object)(((Object)fish.currentFish).name + " not found"));
				}
			}
			if (t <= 0f)
			{
				force = 0f - force;
				t = 10f + Random.Range(0f, 0.3f * force);
			}
			privateField4.SetPrivateField("_buoyancyCoeff", 1f);
			privateField5.AddRelativeForce(Vector3.right * force);
			privateField5.AddRelativeForce(Vector3.forward * Random.Range(0f, 5f));
			privateField5.AddRelativeForce(Vector3.up * Random.Range(-3f, 0f));
			t -= 2f * Time.deltaTime;
		}
	}
	internal class KnifeWood : MonoBehaviour
	{
		private KnifeWoodCollider knifeWoodCol;

		internal static Dictionary<string, int> woodPiecesPerContainer = new Dictionary<string, int>
		{
			{ "small crate", 4 },
			{ "standard crate", 8 },
			{ "large crate", 12 },
			{ "very large crate", 16 },
			{ "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 }
		};

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

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

		internal IEnumerator MakeLocalPosTracker()
		{
			yield return (object)new WaitForEndOfFrame();
			if ((Object)(object)CrateInventoryUI.instance.GetPrivateField<Transform>("localPosTracker") == (Object)null)
			{
				CrateInventoryUI.instance.SetPrivateField("localPosTracker", Object.Instantiate<GameObject>(new GameObject()).transform);
			}
		}
	}
	internal class KnifeWoodCollider : MonoBehaviour
	{
		public ShipItem currentWood;

		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;
			}
			Plugin.logger.LogDebug((object)("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;
			}
		}
	}
	internal class QuickSlots
	{
		public static void GetInventoryItem(int slotIndex, PickupableItem heldItem, GoPointer goPointer)
		{
			if (!Object.op_Implicit((Object)(object)heldItem) || (!heldItem.big && Plugin.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
	{
		internal static GPButtonInventorySlot slot;

		internal static GoPointer goPntr;

		public static SwapSlot instance;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			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))
			{
				Plugin.logger.LogDebug((object)("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;
				Plugin.logger.LogDebug((object)("Withdrawing " + currentItem.name + " from inventory slot."));
				goPntr.PickUpItem((PickupableItem)(object)currentItem);
				((MonoBehaviour)this).StartCoroutine(GrabItem(currentItem));
				Plugin.logger.LogDebug((object)("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;
				Plugin.logger.LogDebug((object)"Items Swapped");
			}
		}

		private IEnumerator GrabItem(ShipItem item)
		{
			yield return (object)new WaitForEndOfFrame();
			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);
		}

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

		internal void WithdrawFromSwapSlot()
		{
			ShipItem currentItem = slot.currentItem;
			Plugin.logger.LogDebug((object)("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" };

		public static int mapSlotIndex = 4;

		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))
			{
				Debug.Log((object)("Stowing map: " + text));
				QuickSlots.StowItem(mapSlotIndex, heldItem, goPntr);
			}
			else if (GetMapSlotIndex())
			{
				Plugin.logger.LogDebug((object)("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 ((!Plugin.enableClockGlobalText.Value && !Plugin.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) > Plugin.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 (!Plugin.enableClockLocalText.Value)
			{
				return GetTime(globalTime);
			}
			if (!Plugin.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 ((!Plugin.enableCompassDegreesText.Value && !Plugin.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 && !Plugin.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) > Plugin.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 (!Plugin.enableCompassCardinalText.Value)
				{
					return $"{Math.Round(reading)}°";
				}
				if (!Plugin.enableCompassDegreesText.Value)
				{
					return CompassRose.GetAbbreviatedDirection(reading, Plugin.compassCardinalPrecisionLevel.Value);
				}
				return $"{CompassRose.GetAbbreviatedDirection(reading, Plugin.compassCardinalPrecisionLevel.Value)}\n{Math.Round(reading)}°";
			}
		}
	}
	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 (Plugin.enableQuickMap.Value && !GameState.wasInSettingsMenu && Input.GetKeyDown(Plugin.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 (Plugin.enableQuickSlots.Value && !GameState.wasInSettingsMenu)
				{
					if (Input.GetKeyDown(Plugin.quickSlot1Key.Value))
					{
						QuickSlots.ToggleInventoryItem(0);
					}
					if (Input.GetKeyDown(Plugin.quickSlot2Key.Value))
					{
						QuickSlots.ToggleInventoryItem(1);
					}
					if (Input.GetKeyDown(Plugin.quickSlot3Key.Value))
					{
						QuickSlots.ToggleInventoryItem(2);
					}
					if (Input.GetKeyDown(Plugin.quickSlot4Key.Value))
					{
						QuickSlots.ToggleInventoryItem(3);
					}
					if (Input.GetKeyDown(Plugin.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;
					Plugin.logger.LogDebug((object)"Creating swap slot.");
					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 (Plugin.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 (Plugin.enableCrateItemDescription.Value)
				{
					foreach (CrateInventoryButton val in ___buttons)
					{
						((GoPointerButton)val).description = ((GoPointerButton)(val.GetPrivateField<ShipItem>("currentItem")?)).description ?? "";
					}
				}
			}
		}
	}
	internal class QuadrantPatches
	{
		[HarmonyPatch(typeof(ShipItemQuadrant))]
		private class ShipItemQuadrantPatches
		{
			[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 (!Plugin.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);
				}
			}
		}
	}
	internal class SaveLoadPatches
	{
		[HarmonyPatch(typeof(SaveLoadManager))]
		private class SaveLoadManagerPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("SaveModData")]
			public static void DoSaveGamePatch()
			{
				RadRefinementsSaveContainer radRefinementsSaveContainer = new RadRefinementsSaveContainer();
				radRefinementsSaveContainer.swapSlotHasItem = (Object)(object)SwapSlot.slot.currentItem != (Object)null;
				radRefinementsSaveContainer.mapSlotIndex = ViewMap.mapSlotIndex;
				ModSave.Save(((BaseUnityPlugin)Plugin.instance).Info, (object)radRefinementsSaveContainer);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("LoadModData")]
		public static void LoadModDataPatch()
		{
			RadRefinementsSaveContainer radRefinementsSaveContainer = default(RadRefinementsSaveContainer);
			if (!ModSave.Load<RadRefinementsSaveContainer>(((BaseUnityPlugin)Plugin.instance).Info, ref radRefinementsSaveContainer))
			{
				Plugin.logger.LogWarning((object)"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)
			{
				Plugin.logger.LogWarning((object)"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;
	}
	[BepInPlugin("com.raddude82.radrefinements", "RadRefinements", "1.0.12")]
	[BepInDependency("com.raddude82.modsavebackups", "1.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "com.raddude82.radrefinements";

		public const string PLUGIN_NAME = "RadRefinements";

		public const string PLUGIN_VERSION = "1.0.12";

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

		public const string MODSAVEBACKUPS_VERSION = "1.1.1";

		internal static Plugin instance;

		internal static ManualLogSource logger;

		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> enableFishMovement;

		private void Awake()
		{
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			instance = this;
			logger = ((BaseUnityPlugin)this).Logger;
			enableInventorySwap = ((BaseUnityPlugin)this).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 = ((BaseUnityPlugin)this).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 = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Inventory Settings", "Quick map key", (KeyCode)109, "Key that retrieves or stows your map when pressed");
			enableQuickSlots = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory Settings", "Enable quick slots", true, "Enables the ability to retrieve items from your inventory when a key is pressed.");
			quickSlot1Key = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Inventory Settings", "Quick slot 1 key", (KeyCode)49, "Key that retrieves from or stows to inventory slot 1 when pressed");
			quickSlot2Key = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Inventory Settings", "Quick slot 2 key", (KeyCode)50, "Key that retrieves from or stows to inventory slot 2 when pressed");
			quickSlot3Key = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Inventory Settings", "Quick slot 3 key", (KeyCode)51, "Key that retrieves from or stows to inventory slot 3 when pressed");
			quickSlot4Key = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Inventory Settings", "Quick slot 4 key", (KeyCode)52, "Key that retrieves from or stows to inventory slot 4 when pressed");
			quickSlot5Key = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Inventory Settings", "Quick slot 5 key", (KeyCode)53, "Key that retrieves from or stows to inventory slot 5 when pressed");
			enableCrateItemDescription = ((BaseUnityPlugin)this).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 = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Text Settings", "Enable quadrant reading text", true, "Enables the text that shows the quadrant reading value.");
			enableCompassReadingHeld = ((BaseUnityPlugin)this).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 = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Text Settings", "Enable compass reading degrees text", true, "Enables the text that shows the compass reading value in degrees.");
			enableCompassCardinalText = ((BaseUnityPlugin)this).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 = ((BaseUnityPlugin)this).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 = ((BaseUnityPlugin)this).Config.Bind<float>("Item Text Settings", "Compass viewable distance", 3f, "Sets the how close player needs to be to see compass reading text");
			enableClockGlobalText = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Text Settings", "Enable clock global time text", true, "Enables the text that shows the global time on the clock.");
			enableClockLocalText = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Text Settings", "Enable clock local time text", true, "Enables the text that shows the clock time on the clock.");
			clockViewableDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Item Text Settings", "Clock viewable distance", 7f, "Sets the how close player needs to be to see clock time text");
			enableWoodFromContainers = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Settings", "Enable wood from breaking containers", true, "Allows you to get firewood by breaking containers with a knife.");
			enableCrateInvCountText = ((BaseUnityPlugin)this).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 = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Other Settings", "Crate inventory count text key", (KeyCode)101, "Crate inventory count text will show when holding this key.");
			removeItemHints = ((BaseUnityPlugin)this).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).");
			enableFishMovement = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Settings", "Enable fish movement", true, "Enables fish movement when fish caught. Fish will move around instead of just sitting still.");
			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 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 (Plugin.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(Plugin.crateInvCountTextKey.Value))
					{
						text = Crate.GetCrateInventory(__instance);
					}
					((GoPointerButton)__instance).lookText = (string.IsNullOrEmpty(text) ? $"{((GoPointerButton)__instance).lookText}\n{___crateInventory.containedItems.Count()} items" : text);
				}
			}
		}
	}
	internal class FishingPatches
	{
		[HarmonyPatch(typeof(ShipItem))]
		private class ShipItemFishingHookPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnLoad")]
			public static void OnLoadRemoveDescription(ShipItem __instance)
			{
				if (Plugin.removeItemHints.Value && __instance.sold && __instance is ShipItemFishingHook)
				{
					((GoPointerButton)__instance).description = "";
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("EnterBoat")]
			public static void EnterBoatRemoveDescription(ShipItem __instance)
			{
				if (Plugin.removeItemHints.Value && __instance.sold && __instance is ShipItemFishingHook)
				{
					((GoPointerButton)__instance).description = "";
				}
			}
		}

		[HarmonyPatch(typeof(FishingRodFish))]
		private class FishingRodFishPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("Awake")]
			public static void SetFishMovement(FishingRodFish __instance)
			{
				if (Plugin.enableFishMovement.Value)
				{
					FishMovement fishMovement = ((Component)__instance).gameObject.AddComponent<FishMovement>();
					fishMovement.fish = __instance;
				}
			}
		}
	}
	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 (Plugin.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 && (KnifeWood.woodPiecesPerContainer.ContainsKey(pointedAtItem.name) || ((Object)(object)component != (Object)null && KnifeWood.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 (Plugin.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_0038: Unknown result type (might be due to invalid IL or missing references)
				if (!Plugin.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 && KnifeWood.woodPiecesPerContainer.ContainsKey(component2.name)) || ((Object)(object)component != (Object)null && KnifeWood.woodPiecesPerContainer.ContainsKey(component.sizeDescription))))
				{
					((Component)___textRIcon).gameObject.SetActive(true);
					___showingIcon = true;
					___controlsText.text = "\ncut";
					return false;
				}
				return true;
			}
		}
	}
}