using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Crest;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("HooksHangMore")]
[assembly: AssemblyDescription("https://github.com/bryon82/SailwindHooksHangMore")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("raddude")]
[assembly: AssemblyProduct("HooksHangMore")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7fbc1d41-251b-4cf2-8ee9-13edaafcc6ee")]
[assembly: AssemblyFileVersion("2.2.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.1.0")]
[module: UnverifiableCode]
namespace HooksHangMore
{
[BepInPlugin("com.raddude.hookshangmore", "HooksHangMore", "2.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class HHM_Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.raddude.hookshangmore";
public const string PLUGIN_NAME = "HooksHangMore";
public const string PLUGIN_VERSION = "2.2.1";
public const string IDLE_FISHING_GUID = "com.isa_idlefishing.patch";
public const string COOKED_INFO_GUID = "pr0skynesis.cookedinfo";
public const string NAND_FIXES_GUID = "com.nandbrew.nandfixes";
private static ManualLogSource _logger;
internal static HHM_Plugin Instance { get; private set; }
internal static bool IdleFishingFound { get; private set; }
internal static Dictionary<PickupableItem, AttachableItemHolder> AttachedItems { get; 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;
AttachedItems = new Dictionary<PickupableItem, AttachableItemHolder>();
bool flag = false;
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
BepInPlugin metadata = pluginInfo.Value.Metadata;
if (metadata.GUID.Equals("com.isa_idlefishing.patch"))
{
LogInfo("Idle Fishing found");
IdleFishingFound = true;
}
if (metadata.GUID.Equals("pr0skynesis.cookedinfo"))
{
LogInfo("Cooked Info found");
HangableFoodPatches.GetNonBurnableDescription();
flag = true;
}
if (IdleFishingFound && flag)
{
break;
}
}
Configs.InitializeConfigs();
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.raddude.hookshangmore");
}
}
internal class AttachableAnchorPatches
{
[HarmonyPatch(typeof(Anchor))]
private class AnchorPatches
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
public static void AwakePatch(Anchor __instance, SaveableObject ___boatSaveable)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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)
_boatAnchors[___boatSaveable.sceneIndex] = __instance;
AttachableItem attachableItem = ((Component)__instance).gameObject.AddComponent<AttachableItem>();
if (Offsets.AttachedItems.TryGetOffset(((Object)__instance).name, out var offset))
{
attachableItem.PositionOffset = offset.Position;
attachableItem.RotationOffset = offset.Rotation;
}
else
{
HHM_Plugin.LogWarning("Attachable anchor offsets not found for " + ((Object)__instance).name + ". Using default offsets.");
attachableItem.PositionOffset = new Vector3(0f, 0.2f, -0.13f);
attachableItem.RotationOffset = new Vector3(270f, 0f, 0f);
}
}
[HarmonyPostfix]
[HarmonyPatch("ExtraFixedUpdate")]
public static void Postfix(Anchor __instance)
{
AttachableItem component = ((Component)__instance).GetComponent<AttachableItem>();
if (!((Object)(object)component != (Object)null) || component.IsAttached)
{
((Component)__instance).GetComponent<Rigidbody>().isKinematic = true;
((Collider)((Component)__instance).GetComponent<CapsuleCollider>()).isTrigger = true;
}
}
}
[HarmonyPatch(typeof(GoPointerButton))]
private class GoPointerButtonPatches
{
[HarmonyPostfix]
[HarmonyPatch("AllowOnItemClick")]
public static void AllowOnItemClick(GoPointerButton __instance, GoPointerButton lookedAtButton, ref bool __result)
{
if (__instance is Anchor && (Object)(object)((Component)__instance).GetComponent<AttachableItem>() != (Object)null && (Object)(object)((Component)lookedAtButton).GetComponent<AttachableItemHolder>() != (Object)null && !((Component)lookedAtButton).GetComponent<AttachableItemHolder>().IsOccupied)
{
__result = true;
}
}
}
[HarmonyPatch(typeof(GPButtonRopeWinch), "LimitTurning")]
private class GPButtonRopeWinchLimitTurningPatch
{
public static void Postfix(GPButtonRopeWinch __instance, ref float ___currentInput)
{
//IL_006c: 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)
if (!((Object)__instance).name.Contains("anchor"))
{
return;
}
RopeController rope = __instance.rope;
RopeControllerAnchor val = (RopeControllerAnchor)(object)((rope is RopeControllerAnchor) ? rope : null);
object obj;
if (val == null)
{
obj = null;
}
else
{
ConfigurableJoint joint = val.joint;
obj = ((joint != null) ? ((Component)joint).GetComponent<PickupableItem>() : null);
}
PickupableItem val2 = (PickupableItem)obj;
AttachableItemHolder attachableItemHolder = ((val2 == null) ? null : ((Component)val2).GetComponent<AttachableItem>()?.Holder);
if (!((Object)(object)attachableItemHolder == (Object)null))
{
float num = Vector3.Distance(((Component)val).transform.position, ((Component)attachableItemHolder).transform.position);
float num2 = Mathf.InverseLerp(0f, val.maxLength, num);
if (__instance.rope.currentLength - num2 < 0.02f && ___currentInput > 0f)
{
___currentInput = 0f;
}
}
}
}
[HarmonyPatch(typeof(SaveablePrefab))]
private class SaveablePrefabPatches
{
[HarmonyPostfix]
[HarmonyPatch("PrepareSaveData")]
public static void SaveAnchorAttached(ShipItem ___item, ref SavePrefabData __result)
{
if (!(___item is ShipItemLampHook))
{
return;
}
AttachableItemHolder component = ((Component)___item).GetComponent<AttachableItemHolder>();
if (!((Object)(object)component == (Object)null) && component.IsOccupied)
{
PickupableItem attachedItem = component.AttachedItem;
Anchor val = (Anchor)(object)((attachedItem is Anchor) ? attachedItem : null);
if (val != null && !((Object)(object)((Component)val).gameObject.GetComponent<SaveableObject>() == (Object)null))
{
__result.extraValue0 = val.GetPrivateField<SaveableObject>("boatSaveable").sceneIndex;
}
}
}
[HarmonyPrefix]
[HarmonyPatch("Load")]
public static void LoadAnchorAttached(SavePrefabData data, SaveablePrefab __instance)
{
ShipItemLampHook component = ((Component)__instance).GetComponent<ShipItemLampHook>();
if (!((Object)(object)component == (Object)null) && !(data.extraValue0 <= 0f))
{
HHM_Plugin.LogDebug("Loading attached anchor");
((MonoBehaviour)__instance).StartCoroutine(AttachAnchor(component, (int)data.extraValue0));
}
}
}
private static readonly Dictionary<int, Anchor> _boatAnchors = new Dictionary<int, Anchor>();
internal static IEnumerator AttachAnchor(ShipItemLampHook hook, int sceneIndex)
{
yield return (object)new WaitUntil((Func<bool>)(() => _boatAnchors.ContainsKey(sceneIndex) || !GameState.loadingBoatLocalItems));
if (!_boatAnchors.TryGetValue(sceneIndex, out var anchor))
{
HHM_Plugin.LogError($"Could not find anchor {sceneIndex} for hook");
yield break;
}
HHM_Plugin.LogDebug("Attaching " + ((Object)anchor).name + " to hook on " + ((Object)((Component)hook).transform.parent).name);
PickupableItem anchorPickupable = ((Component)anchor).GetComponent<PickupableItem>();
AttachableItemHolder holder = ((Component)hook).GetComponent<AttachableItemHolder>();
holder.AttachItem(anchorPickupable);
((Component)anchorPickupable).GetComponent<AttachableItem>().Holder = holder;
}
}
internal class AttachableChipLogPatches
{
[HarmonyPatch(typeof(ShipItemChipLog), "OnLoad")]
private class ShipItemChipLogPatches
{
public static void Postfix(ShipItemChipLog __instance)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
AttachableItem attachableItem = ((Component)__instance).gameObject.AddComponent<AttachableItem>();
attachableItem.PositionOffset = Offsets.AttachedItems.GetOffset(((ShipItem)__instance).name).Position;
}
}
}
internal class AttachableKnifePatches
{
[HarmonyPatch(typeof(ShipItemKnife))]
private class ShipItemKnifePatches
{
[HarmonyPostfix]
[HarmonyPatch("OnLoad")]
public static void AddComponent(ShipItemKnife __instance)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
AttachableItem attachableItem = ((Component)__instance).gameObject.AddComponent<AttachableItem>();
Offsets offset = Offsets.AttachedItems.GetOffset(((ShipItem)__instance).name);
attachableItem.PositionOffset = offset.Position;
attachableItem.RotationOffset = offset.Rotation;
if (Configs.flipKnifeRotation.Value)
{
attachableItem.PositionOffset = new Vector3(0f - attachableItem.PositionOffset.x, 0f - attachableItem.PositionOffset.y, attachableItem.PositionOffset.z);
attachableItem.RotationOffset = new Vector3(attachableItem.RotationOffset.x - 180f, attachableItem.RotationOffset.y, attachableItem.RotationOffset.z);
}
}
[HarmonyPrefix]
[HarmonyPatch("AllowOnItemClick")]
public static bool AllowOnItemClick(ShipItemKnife __instance, GoPointerButton lookedAtButton, ref bool __result)
{
if (!((ShipItem)__instance).sold)
{
return true;
}
if ((Object)(object)((Component)__instance).GetComponent<AttachableItem>() != (Object)null && (Object)(object)((Component)lookedAtButton).GetComponent<AttachableItemHolder>() != (Object)null && !((Component)lookedAtButton).GetComponent<AttachableItemHolder>().IsOccupied)
{
__result = true;
return false;
}
return true;
}
}
}
internal class HangableBottlePatches
{
[HarmonyPatch(typeof(ShipItemBottle))]
private class ShipItemBottlePatches
{
[HarmonyPrefix]
[HarmonyPatch("AllowOnItemClick")]
public static bool AllowOnItemClick(ShipItemBottle __instance, GoPointerButton lookedAtButton, ref bool __result)
{
if (!Offsets.HangingItems.IsHangable(((Object)((Component)__instance).transform).name) || !((ShipItem)__instance).sold)
{
return true;
}
if ((Object)(object)((Component)__instance).GetComponent<HangableItem>() != (Object)null && (Object)(object)((Component)lookedAtButton).GetComponent<AttachableItemHolder>() != (Object)null && !((Component)lookedAtButton).GetComponent<AttachableItemHolder>().IsOccupied)
{
__result = true;
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("OnItemClick")]
public static bool OnItemClick(ShipItemSoup __instance, PickupableItem heldItem, ref bool __result)
{
if (!Offsets.HangingItems.IsHangable(((Object)((Component)__instance).transform).name) || !((ShipItem)__instance).sold)
{
return true;
}
AttachableItem component = ((Component)__instance).GetComponent<AttachableItem>();
if ((Object)(object)component != (Object)null && component.IsAttached && Object.op_Implicit((Object)(object)((Component)heldItem).GetComponent<ShipItemBottle>()))
{
NotificationUi.instance.ShowNotification("Cannot fill\nwhile it is hanging");
__result = false;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Mug), "Update")]
private class MugPatches
{
public static void Postfix(Mug __instance)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (GameState.playing && ((Object)__instance).name.Contains("bucket"))
{
HangableItem component = ((Component)__instance).GetComponent<HangableItem>();
if ((Object)(object)component != (Object)null && component.IsHanging())
{
__instance.bucketHandle.localRotation = Quaternion.Euler(Vector3.zero);
}
}
}
}
[HarmonyPatch(typeof(SaveablePrefab))]
private class SaveablePrefabPatches
{
[HarmonyPostfix]
[HarmonyPatch("PrepareSaveData")]
public static void SaveBucketHanging(ShipItem ___item, ref SavePrefabData __result)
{
if (___item is ShipItemBottle && !(___item.name != "bucket"))
{
HangableItem component = ((Component)___item).GetComponent<HangableItem>();
if (!((Object)(object)component == (Object)null) && component.IsHanging())
{
__result.extraValue0 = 1f;
}
}
}
[HarmonyPrefix]
[HarmonyPatch("Load")]
public static void LoadBucketHanging(SavePrefabData data, SaveablePrefab __instance)
{
ShipItemBottle component = ((Component)__instance).GetComponent<ShipItemBottle>();
if (!((Object)(object)component == (Object)null) && !(((ShipItem)component).name != "bucket") && data.extraValue0 == 1f)
{
HHM_Plugin.LogDebug("Loading hanging bucket");
((MonoBehaviour)__instance).StartCoroutine(HangBucket(component));
}
}
}
internal static IEnumerator HangBucket(ShipItemBottle bucket)
{
HHM_Plugin.LogDebug("Shifting bucket box collider up");
BoxCollider col = ((Component)bucket).GetComponent<BoxCollider>();
col.center = new Vector3(col.center.x, 0.105417f, col.center.z);
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)((Component)bucket).GetComponent<HangableItem>() != (Object)null && ((Component)bucket).GetComponent<HangableItem>().IsHanging()));
col.center = new Vector3(col.center.x, -0.055417f, col.center.z);
HHM_Plugin.LogDebug("Shifted bucket box collider back down");
}
}
internal class HangableKettlePatches
{
[HarmonyPatch(typeof(ShipItemKettle))]
private class ShipItemKettlePatches
{
[HarmonyPrefix]
[HarmonyPatch("AllowOnItemClick")]
public static bool AllowOnItemClick(ShipItemKettle __instance, GoPointerButton lookedAtButton, ref bool __result)
{
if (!((ShipItem)__instance).sold)
{
return true;
}
if ((Object)(object)((Component)__instance).GetComponent<HangableItem>() != (Object)null && (Object)(object)((Component)lookedAtButton).GetComponent<AttachableItemHolder>() != (Object)null && !((Component)lookedAtButton).GetComponent<AttachableItemHolder>().IsOccupied)
{
__result = true;
return false;
}
return true;
}
}
}
internal class HangablePotPatches
{
[HarmonyPatch(typeof(ShipItemSoup))]
private class ShipItemSoupPatches
{
[HarmonyPostfix]
[HarmonyPatch("OnLoad")]
public static void AddComponent(ShipItemSoup __instance)
{
if (Offsets.HangingItems.IsHangable(((Object)((Component)__instance).transform).name))
{
((Component)__instance).gameObject.AddComponent<HangableItem>();
}
}
[HarmonyPrefix]
[HarmonyPatch("AllowOnItemClick")]
public static bool AllowOnItemClick(ShipItemSoup __instance, GoPointerButton lookedAtButton, ref bool __result)
{
if (!((ShipItem)__instance).sold)
{
return true;
}
if ((Object)(object)((Component)__instance).GetComponent<HangableItem>() != (Object)null && (Object)(object)((Component)lookedAtButton).GetComponent<AttachableItemHolder>() != (Object)null && !((Component)lookedAtButton).GetComponent<AttachableItemHolder>().IsOccupied)
{
__result = true;
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("OnItemClick")]
public static bool OnItemClick(ShipItemSoup __instance, PickupableItem heldItem, ref bool __result)
{
if (!((ShipItem)__instance).sold)
{
return true;
}
HangableItem component = ((Component)__instance).GetComponent<HangableItem>();
if ((Object)(object)component != (Object)null && component.IsHanging() && Object.op_Implicit((Object)(object)((Component)heldItem).GetComponent<ShipItemBottle>()))
{
NotificationUi.instance.ShowNotification("Cannot fill\nwhile it is hanging");
__result = false;
return false;
}
return true;
}
}
}
internal class ShipItemRotationPatches
{
[HarmonyPatch(typeof(ShipItem))]
private class ShipItemPatches
{
[HarmonyPostfix]
[HarmonyPatch("OnLoad")]
public static void RemoveDescription(ShipItem __instance)
{
if (__instance is ShipItemLampHook)
{
((Component)__instance).gameObject.AddComponent<PickupableItemAddOns>();
}
}
[HarmonyPrefix]
[HarmonyPatch("Update")]
public static bool RotateAttachments(ShipItem __instance, Transform ___itemRigidbody, ref bool ___inRangeOfWall, ref Vector3 ___attachPos, ref Quaternion ___attachRot)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)((PickupableItem)__instance).held) && __instance.wallAttachment)
{
PickupableItemAddOns component = ((Component)__instance).GetComponent<PickupableItemAddOns>();
if ((Object)(object)component == (Object)null)
{
return true;
}
float heldRotationYOffset = component.heldRotationYOffset;
Vector3 forward = ___itemRigidbody.forward;
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(new Ray(___itemRigidbody.position, forward), ref val, 1.3f))
{
if (((RaycastHit)(ref val)).distance < 0.1f)
{
___inRangeOfWall = false;
}
else
{
___attachPos = ((RaycastHit)(ref val)).point;
Quaternion val2 = Quaternion.LookRotation(-((RaycastHit)(ref val)).normal, Vector3.up);
if (((RaycastHit)(ref val)).normal.y > 0.8f)
{
val2 = Quaternion.LookRotation(-((RaycastHit)(ref val)).normal, ((Component)__instance).transform.up);
}
Quaternion val3 = Quaternion.AngleAxis(heldRotationYOffset, Vector3.forward);
___attachRot = val2 * val3;
___inRangeOfWall = true;
__instance.InvokePrivateMethod("SetUpTargeter", ___attachPos, ___attachRot, ((Component)__instance).GetComponent<MeshFilter>().sharedMesh);
}
}
else
{
___inRangeOfWall = false;
}
}
else
{
___inRangeOfWall = false;
}
if (__instance.GetPrivateField<bool>("isLookedAt"))
{
__instance.UpdateLookText();
}
__instance.InvokePrivateMethod("ProcessSaveable");
return false;
}
}
[HarmonyPatch(typeof(GoPointer), "LateUpdate")]
private class GoPointerPatches
{
public static void Postfix(PickupableItem ___heldItem)
{
//IL_0046: 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_0056: 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)
if (!((Object)(object)___heldItem == (Object)null) && !___heldItem.big)
{
PickupableItemAddOns component = ((Component)___heldItem).GetComponent<PickupableItemAddOns>();
if (!((Object)(object)component == (Object)null) && component.heldRotationYOffset != 0f)
{
Transform transform = ((Component)___heldItem).transform;
transform.rotation *= Quaternion.AngleAxis(component.heldRotationYOffset, Vector3.forward);
}
}
}
}
}
internal class PickupableItemAddOns : MonoBehaviour
{
public float heldRotationYOffset;
private void Start()
{
heldRotationYOffset = 0f;
}
private void Update()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
float num = GameInput.GetScrollAxis() * 25f + OVRInput.Get((Axis2D)2, (Controller)int.MinValue).y;
if ((double)num != 0.0 && GameInput.GetKey((InputName)11))
{
heldRotationYOffset += num * 4f;
heldRotationYOffset = Mathf.Clamp(heldRotationYOffset, -90f, 90f);
}
}
}
internal static class Extensions
{
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 GetPrivateField<T>(this object obj, string field)
{
return (T)Traverse.Create(obj).Field(field).GetValue();
}
}
internal class Offsets
{
public static readonly Dictionary<string, Offsets> HangingItems = new Dictionary<string, Offsets>
{
{
"70 bucket(Clone)",
new Offsets(new Vector3(0f, -0.245f, 0f))
},
{
"382 kettle A(Clone)",
new Offsets(new Vector3(0f, -0.289f, 0f))
},
{
"383 kettle E(Clone)",
new Offsets(new Vector3(0f, -0.2f, -0.01f))
},
{
"384 kettle M(Clone)",
new Offsets(new Vector3(0f, -0.26f, 0f))
},
{
"156 pot(Clone)",
new Offsets(new Vector3(0.02f, -0.175f, -0.11f), default(Vector3), isFish: false, 0f, 270f, 40f)
},
{
"157 pot big(Clone)",
new Offsets(new Vector3(0.025f, -0.205f, -0.13f), default(Vector3), isFish: false, 0f, 270f, 50f)
},
{
"102 mug metal(Clone)",
new Offsets(new Vector3(0f, -0.12f, -0.02f), default(Vector3), isFish: false, 0f, 90f, -28f)
},
{
"102 mug metal",
new Offsets(new Vector3(0f, -0.12f, -0.02f), default(Vector3), isFish: false, 0f, 90f, -28f)
},
{
"103 mug metal gold(Clone)",
new Offsets(new Vector3(0f, -0.12f, -0.02f), default(Vector3), isFish: false, 0f, 90f, -20f)
},
{
"100 mug wood(Clone)",
new Offsets(new Vector3(-0.07f, -0.075f, -0.02f), default(Vector3), isFish: false, 0f, 0f, 270f)
},
{
"100 mug wood",
new Offsets(new Vector3(-0.07f, -0.075f, -0.02f), default(Vector3), isFish: false, 0f, 0f, 270f)
},
{
"31 templefish (A)(Clone)",
new Offsets(new Vector3(-0.035f, -0.14f, 0f), default(Vector3), isFish: true)
},
{
"32 sunspot fish (A)(Clone)",
new Offsets(new Vector3(-0.05f, -0.21f, 0f), default(Vector3), isFish: true)
},
{
"46 tuna (A)(Clone)",
new Offsets(new Vector3(0f, -0.27f, 0f), default(Vector3), isFish: true)
},
{
"33 salmon (E)(Clone)",
new Offsets(new Vector3(-0.035f, -0.3f, 0f), default(Vector3), isFish: true)
},
{
"34 eel (E)(Clone)",
new Offsets(new Vector3(-0.006f, -0.65f, 0.01f), default(Vector3), isFish: true)
},
{
"35 shimmertail (E)(Clone)",
new Offsets(new Vector3(-0.05f, -0.28f, 0f), default(Vector3), isFish: true)
},
{
"36 trout (M)(Clone)",
new Offsets(new Vector3(-0.04f, -0.28f, 0f), default(Vector3), isFish: true)
},
{
"37 north fish (M)(Clone)",
new Offsets(new Vector3(-0.03f, -0.2f, 0f), default(Vector3), isFish: true)
},
{
"38 blackfin hunter (M)(Clone)",
new Offsets(new Vector3(-0.035f, -0.245f, 0f), default(Vector3), isFish: true)
},
{
"140 gold albacore(Clone)",
new Offsets(new Vector3(0f, -0.27f, 0f), default(Vector3), isFish: true)
},
{
"141 swamp fish 1 (snapper(Clone)",
new Offsets(new Vector3(-0.035f, -0.265f, 0f), default(Vector3), isFish: true)
},
{
"142 swamp fish 2 (bubbler)(Clone)",
new Offsets(new Vector3(-0.045f, -0.19f, 0f), default(Vector3), isFish: true)
},
{
"148 swamp fish 3(Clone)",
new Offsets(new Vector3(-0.065f, -0.2f, 0f), default(Vector3), isFish: true)
}
};
public static readonly Dictionary<string, Offsets> AttachedItems = new Dictionary<string, Offsets>
{
{
"fishing rod",
new Offsets(new Vector3(0.309f, 1.1f, -0.38f), new Vector3(-40f, 180f, 0f))
},
{
"broom",
new Offsets(new Vector3(0f, -0.25f, -0.11f))
},
{
"chip log",
new Offsets(new Vector3(0.002f, 0.25f, -0.12f))
},
{
"oar",
new Offsets(new Vector3(0f, -0.65f, -0.11f), new Vector3(180f, 0f, 0f))
},
{
"quadrant",
new Offsets(new Vector3(-0.0155f, 0.164f, -0.115f), new Vector3(90f, -90f, 0f))
},
{
"knife",
new Offsets(new Vector3(0.05f, -0.115f, -0.182f), new Vector3(270f, 270f, 0f))
},
{
"hammer",
new Offsets(new Vector3(0f, -0.3f, -0.22f), new Vector3(270f, 270f, 0f))
},
{
"anchor_E (1)",
new Offsets(new Vector3(0f, 0.2f, -0.13f), new Vector3(270f, 0f, 0f))
},
{
"anchor_E",
new Offsets(new Vector3(0f, 0.2f, -0.13f), new Vector3(270f, 0f, 0f))
},
{
"anchor_M",
new Offsets(new Vector3(0f, 0.2f, -0.13f), new Vector3(270f, 0f, 0f))
},
{
"anchor_A",
new Offsets(new Vector3(0f, 0.2f, -0.13f), new Vector3(270f, 0f, 0f))
}
};
public Vector3 Position { get; }
public Vector3 Rotation { get; }
public float RotX { get; }
public float RotY { get; }
public float RotZ { get; }
public bool LockX { get; }
public bool LockZ { get; }
public Offsets(Vector3 positionOffset, Vector3 rotationOffset = default(Vector3), bool isFish = false, float rotX = 0f, float rotY = 0f, float rotZ = 0f, bool lockX = true, bool lockZ = true)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Position = positionOffset;
Rotation = rotationOffset;
RotX = rotX;
RotY = rotY;
RotZ = rotZ;
LockX = lockX;
LockZ = lockZ;
if (isFish)
{
RotY = 90f;
RotZ = 270f;
}
}
}
internal static class OffsetsExtensions
{
public static bool TryGetOffset(this Dictionary<string, Offsets> dict, string itemName, out Offsets offset)
{
return dict.TryGetValue(itemName, out offset);
}
public static Offsets GetOffset(this Dictionary<string, Offsets> dict, string itemName)
{
Offsets value;
return dict.TryGetValue(itemName, out value) ? value : null;
}
public static bool IsHangable(this Dictionary<string, Offsets> dict, string itemName)
{
return dict.ContainsKey(itemName);
}
}
internal class HangableFoodPatches
{
private delegate void NonBurnableDescDelegate(ref string description, float amount);
[HarmonyPatch(typeof(FoodState))]
private class FoodStatePatches
{
[HarmonyPostfix]
[HarmonyPatch("Update")]
public static void HangDry(FoodState __instance, ShipItemFood ___food)
{
HangableItem component = ((Component)__instance).GetComponent<HangableItem>();
if (GameState.playing && !__instance.inWater && ((ShipItem)___food).sold && !((Object)(object)component == (Object)null) && component.IsHanging())
{
float num = Time.deltaTime * Sun.sun.timescale / (30f * ___food.GetEnergyPerBite());
num *= Mathf.Lerp(1f, 10f, __instance.salted);
num *= 1.5f;
if (((ShipItem)___food).name == "eel")
{
num *= 1.5f;
}
if (((Component)__instance).gameObject.layer == 26)
{
num = 0f;
}
__instance.dried += num;
}
}
[HarmonyPrefix]
[HarmonyPatch("UpdateLookText")]
public static bool UpdateDescription(FoodState __instance, ShipItemFood ___food)
{
if (__instance.spoiled > 0.9f || ((ShipItem)___food).amount >= 1.5f || (__instance.salted >= 0.99f && __instance.smoked >= 0.99f) || __instance.smoked >= 0.99f)
{
return true;
}
if (__instance.salted >= 0.99f && __instance.dried >= 0.99f)
{
((GoPointerButton)___food).description = "salted dried " + ((ShipItem)___food).name;
return false;
}
return true;
}
[HarmonyBefore(new string[] { "pr0skynesis.cookedinfo" })]
[HarmonyPostfix]
[HarmonyPatch("UpdateLookText")]
public static void UpdateCookedInfo(FoodState __instance, ShipItemFood ___food)
{
if (_nonBurnableDescription != null)
{
HangableItem component = ((Component)__instance).GetComponent<HangableItem>();
if (!((Object)(object)component == (Object)null) && component.IsHanging())
{
string description = ((GoPointerButton)___food).description;
_nonBurnableDescription(ref description, __instance.dried / 0.99f);
((GoPointerButton)___food).description = description;
}
}
}
}
[HarmonyPatch(typeof(ShipItemFood))]
private class ShipItemFoodPatches
{
[HarmonyPrefix]
[HarmonyPatch("AllowOnItemClick")]
public static bool AllowOnItemClick(GoPointerButton lookedAtButton, ShipItemFood __instance, ref bool __result)
{
if (!((ShipItem)__instance).sold)
{
return true;
}
if ((Object)(object)((Component)__instance).GetComponent<HangableItem>() != (Object)null && (Object)(object)((Component)lookedAtButton).GetComponent<AttachableItemHolder>() != (Object)null && !((Component)lookedAtButton).GetComponent<AttachableItemHolder>().IsOccupied)
{
__result = true;
return false;
}
return true;
}
}
private static NonBurnableDescDelegate _nonBurnableDescription;
internal static void GetNonBurnableDescription()
{
Type type = AccessTools.TypeByName("DescriptionBuilder");
MethodInfo methodInfo = AccessTools.Method(type, "NonBurnableDescription", (Type[])null, (Type[])null);
if (!(methodInfo == null))
{
_nonBurnableDescription = (NonBurnableDescDelegate)Delegate.CreateDelegate(typeof(NonBurnableDescDelegate), methodInfo);
}
}
}
internal class AttachableFishingRodPatches
{
[HarmonyPatch(typeof(ShipItemFishingRod), "OnLoad")]
private class ShipItemFishingRodPatches
{
public static void Postfix(ShipItemFishingRod __instance)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
AttachableItem attachableItem = ((Component)__instance).gameObject.AddComponent<AttachableItem>();
Offsets offset = Offsets.AttachedItems.GetOffset(((ShipItem)__instance).name);
attachableItem.PositionOffset = offset.Position;
attachableItem.RotationOffset = offset.Rotation;
}
}
[HarmonyPatch(typeof(FishingRodFish), "Update")]
private class FishingRodFishPatches
{
[HarmonyBefore(new string[] { "com.isa_idlefishing.patch" })]
public static void Postfix(FishingRodFish __instance, ShipItemFishingRod ___rod, SimpleFloatingObject ___floater, ConfigurableJoint ___bobberJoint, ref float ___fishTimer)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance.currentFish != (Object)null || ((ShipItem)___rod).health <= 0f || !HHM_Plugin.AttachedItems.ContainsKey((PickupableItem)(object)___rod) || !((FloatingObjectBase)___floater).InWater)
{
return;
}
SoftJointLimit linearLimit = ___bobberJoint.linearLimit;
if (((SoftJointLimit)(ref linearLimit)).limit <= 1f || ((Component)__instance).gameObject.layer == 16)
{
return;
}
float num = ((!(GameState.distanceToLand < 500f)) ? (HHM_Plugin.IdleFishingFound ? 10f : 5.13f) : (HHM_Plugin.IdleFishingFound ? 20f : 6.67f));
___fishTimer -= Time.deltaTime;
float num2 = Vector3.Distance(((Component)__instance).transform.position, ((Component)___rod).transform.position);
float num3 = Mathf.InverseLerp(3f, 20f, num2) * 2.5f + 0.5f;
if (___fishTimer <= 0f)
{
___fishTimer = 1f;
num3 /= num;
if (Random.Range(0f, 100f) < num3)
{
__instance.CatchFish();
}
}
}
}
}
internal class HangablePatches
{
[HarmonyPatch(typeof(ShipItem))]
private class ShipItemPatches
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
public static void AddComponent(ShipItem __instance)
{
if (Offsets.HangingItems.IsHangable(((Object)((Component)__instance).transform).name))
{
((Component)__instance).gameObject.AddComponent<HangableItem>();
}
}
[HarmonyPostfix]
[HarmonyPatch("OnPickup")]
public static void OnPickup(ShipItem __instance)
{
if (Offsets.HangingItems.IsHangable(((Object)((Component)__instance).transform).name))
{
HangableItem component = ((Component)__instance).GetComponent<HangableItem>();
if ((Object)(object)component != (Object)null)
{
component.DisconnectJoint();
}
}
}
[HarmonyPostfix]
[HarmonyPatch("OnEnterInventory")]
public static void OnEnterInventory(ShipItem __instance)
{
if (Offsets.HangingItems.IsHangable(((Object)((Component)__instance).transform).name))
{
HangableItem component = ((Component)__instance).GetComponent<HangableItem>();
if ((Object)(object)component != (Object)null)
{
component.DisconnectJoint();
}
}
}
}
[HarmonyPatch(typeof(HangableItem))]
private class HangableItemPatches
{
[HarmonyPostfix]
[HarmonyPatch("ConnectJoint")]
public static void AdjustAnchor(HangableItem __instance)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
if (!GameState.currentlyLoading && !GameState.loadingBoatLocalItems && Offsets.HangingItems.TryGetOffset(((Object)__instance).name, out var offset))
{
Vector3 eulerAngles = ((Component)__instance).transform.eulerAngles;
eulerAngles.y += offset.RotY;
((Component)__instance).transform.eulerAngles = eulerAngles;
}
}
[HarmonyPrefix]
[HarmonyPatch("LateUpdate")]
public static bool ApplyPositionOffset(HangableItem __instance, Collider ___currentHook)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.IsHanging())
{
return true;
}
if (!Offsets.HangingItems.TryGetOffset(((Object)__instance).name, out var offset))
{
return true;
}
Vector3 eulerAngles = ((Component)__instance).transform.eulerAngles;
if (offset.LockX)
{
eulerAngles.x = offset.RotX;
}
if (offset.LockZ)
{
eulerAngles.z = offset.RotZ;
}
((Component)__instance).transform.eulerAngles = eulerAngles;
((Component)__instance).transform.position = ((Component)___currentHook).transform.position + ((Component)___currentHook).transform.forward * (-0.128f + offset.Position.z) + ((Component)___currentHook).transform.right * offset.Position.x;
((Component)__instance).transform.position = new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + offset.Position.y, ((Component)__instance).transform.position.z);
return false;
}
[HarmonyPrefix]
[HarmonyPatch("OnTriggerEnter")]
public static bool OnTriggerEnter(HangableItem __instance, Collider other)
{
bool flag = ((Object)(object)((Component)other).GetComponent<AttachableItemHolder>() != (Object)null && ((Component)other).GetComponent<AttachableItemHolder>().IsOccupied) || ((Object)(object)((Component)other).GetComponent<ShipItemLampHook>() != (Object)null && ((Component)other).GetComponent<ShipItemLampHook>().GetPrivateField<bool>("occupied"));
if (__instance.IsHanging() || flag)
{
return false;
}
return true;
}
}
}
internal class AttachablePatches
{
[HarmonyPatch(typeof(ShipItem))]
private class ShipItemPatches
{
[HarmonyBefore(new string[] { "com.nandbrew.nandfixes" })]
[HarmonyPostfix]
[HarmonyPatch("Awake")]
public static void AddItemHolderAndAttachable(ShipItem __instance)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (__instance is ShipItemLampHook)
{
((Component)__instance).gameObject.AddComponent<AttachableItemHolder>();
}
if (Offsets.AttachedItems.TryGetOffset(__instance.name, out var offset))
{
AttachableItem attachableItem = ((Component)__instance).gameObject.AddComponent<AttachableItem>();
attachableItem.PositionOffset = offset.Position;
attachableItem.RotationOffset = offset.Rotation;
}
}
[HarmonyPrefix]
[HarmonyPatch("AllowOnItemClick")]
public static bool AllowOnItemClick(GoPointerButton lookedAtButton, ShipItem __instance, ref bool __result)
{
if (!__instance.sold)
{
return true;
}
if ((Object)(object)((Component)__instance).GetComponent<AttachableItem>() != (Object)null && (Object)(object)((Component)lookedAtButton).GetComponent<AttachableItemHolder>() != (Object)null && !((Component)lookedAtButton).GetComponent<AttachableItemHolder>().IsOccupied)
{
__result = true;
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("OnPickup")]
public static void OnShipItemPickup(ShipItem __instance)
{
if ((Object)(object)((Component)__instance).GetComponent<AttachableItem>() != (Object)null && HHM_Plugin.AttachedItems.ContainsKey((PickupableItem)(object)__instance))
{
AttachableItemHolder attachableItemHolder = HHM_Plugin.AttachedItems[(PickupableItem)(object)__instance];
if ((Object)(object)attachableItemHolder != (Object)null && (Object)(object)attachableItemHolder.AttachedItem == (Object)(object)__instance)
{
attachableItemHolder.DetachItem();
}
}
}
}
[HarmonyPatch(typeof(PickupableItem), "OnPickup")]
private class PickupableItemOnPickupPatch
{
[HarmonyPostfix]
public static void OnPickup(PickupableItem __instance)
{
if ((Object)(object)((Component)__instance).GetComponent<AttachableItem>() != (Object)null && HHM_Plugin.AttachedItems.ContainsKey(__instance))
{
AttachableItemHolder attachableItemHolder = HHM_Plugin.AttachedItems[__instance];
if ((Object)(object)attachableItemHolder != (Object)null && (Object)(object)attachableItemHolder.AttachedItem == (Object)(object)__instance)
{
attachableItemHolder.DetachItem();
}
}
}
}
[HarmonyPatch(typeof(ShipItemLampHook))]
private class ShipItemLampHookPatches
{
[HarmonyPostfix]
[HarmonyPatch("OnPickup")]
public static void OnPickup(ShipItemLampHook __instance)
{
AttachableItemHolder component = ((Component)__instance).GetComponent<AttachableItemHolder>();
if (component.IsOccupied)
{
component.DetachItem();
}
}
[HarmonyPostfix]
[HarmonyPatch("OnEnterInventory")]
public static void OnEnterInventory(ShipItemLampHook __instance)
{
AttachableItemHolder component = ((Component)__instance).GetComponent<AttachableItemHolder>();
if (component.IsOccupied)
{
component.DetachItem();
}
}
[HarmonyPrefix]
[HarmonyPatch("OnItemClick")]
public static bool OnItemClick(PickupableItem heldItem, ShipItemLampHook __instance, bool ___occupied, ref bool __result)
{
AttachableItemHolder component = ((Component)__instance).GetComponent<AttachableItemHolder>();
if (component.IsOccupied || ___occupied)
{
__result = false;
return false;
}
ShipItem val = (ShipItem)(object)((heldItem is ShipItem) ? heldItem : null);
if (val != null)
{
if (!val.sold)
{
return true;
}
ShipItemSoup val2 = (ShipItemSoup)(object)((val is ShipItemSoup) ? val : null);
if (val2 == null || !(val2.currentWater > 0f))
{
ShipItemBottle val3 = (ShipItemBottle)(object)((val is ShipItemBottle) ? val : null);
if (val3 == null || !(((ShipItem)val3).health > 0f))
{
goto IL_00a3;
}
}
NotificationUi.instance.ShowNotification("Cannot hang\nit is not empty");
__result = false;
return false;
}
goto IL_00a3;
IL_00a3:
AttachableItem component2 = ((Component)heldItem).GetComponent<AttachableItem>();
if ((Object)(object)component2 != (Object)null)
{
component.AttachItem(heldItem);
component2.Holder = component;
__result = true;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(SaveablePrefab), "Load")]
private class SaveablePrefabPAtches
{
public static void Prefix(SavePrefabData data, SaveablePrefab __instance)
{
if (data.inventorySlot > -1)
{
AttachableItem component = ((Component)__instance).GetComponent<AttachableItem>();
if ((Object)(object)component != (Object)null)
{
component.LoadInInventory();
}
}
}
}
}
internal class AttachableQuadrantPatches
{
[HarmonyPatch(typeof(ShipItemQuadrant))]
private class ShipItemQuadrantPatches
{
[HarmonyPostfix]
[HarmonyPatch("OnLoad")]
public static void AddAttachable(ShipItemQuadrant __instance)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
AttachableItem attachableItem = ((Component)__instance).gameObject.AddComponent<AttachableItem>();
Offsets offset = Offsets.AttachedItems.GetOffset(((ShipItem)__instance).name);
attachableItem.PositionOffset = offset.Position;
attachableItem.RotationOffset = offset.Rotation;
}
[HarmonyPostfix]
[HarmonyPatch("ExtraLateUpdate")]
public static void Postfix(ShipItemQuadrant __instance)
{
if (GameState.playing)
{
AttachableItem component = ((Component)__instance).GetComponent<AttachableItem>();
if ((Object)(object)component != (Object)null && component.IsAttached)
{
__instance.lockX = false;
}
else
{
__instance.lockX = true;
}
}
}
}
}
public class AttachableItem : MonoBehaviour
{
private ShipItem _shipItem;
private PickupableItem _pickupable;
private bool _disallowHangingOnTrigger;
private float _framesAfterAwake;
internal AttachableItemHolder Holder { get; set; }
public Vector3 PositionOffset { get; set; }
public Vector3 RotationOffset { get; set; }
public bool IsAttached => (Object)(object)Holder != (Object)null;
private void Awake()
{
//IL_0034: 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)
_pickupable = ((Component)this).GetComponent<PickupableItem>();
_shipItem = ((Component)this).GetComponent<ShipItem>();
Holder = null;
_disallowHangingOnTrigger = false;
_framesAfterAwake = 0f;
PositionOffset = Vector3.zero;
RotationOffset = Vector3.zero;
}
private void LateUpdate()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_pickupable != (Object)null)
{
PickupableItem pickupable = _pickupable;
Anchor val = (Anchor)(object)((pickupable is Anchor) ? pickupable : null);
if (val != null && IsAttached)
{
((Component)val).transform.position = ((Component)Holder).transform.TransformPoint(PositionOffset);
((Component)val).transform.rotation = ((Component)Holder).transform.rotation * Quaternion.Euler(RotationOffset);
}
}
}
private void FixedUpdate()
{
if (_framesAfterAwake < 3f)
{
_framesAfterAwake += 1f;
}
}
public void LoadInInventory()
{
_disallowHangingOnTrigger = true;
}
public void OnTriggerEnter(Collider other)
{
AttachableItemHolder component = ((Component)other).GetComponent<AttachableItemHolder>();
bool flag = (_framesAfterAwake < 3f || GameState.currentlyLoading || GameState.loadingBoatLocalItems) && !Object.op_Implicit((Object)(object)_pickupable.held) && !_disallowHangingOnTrigger && ((Component)other).CompareTag("Hook") && (Object)(object)component != (Object)null && !component.IsOccupied && !IsAttached;
if ((Object)(object)_shipItem != (Object)null)
{
flag = flag && _shipItem.sold && _shipItem.GetCurrentInventorySlot() == -1;
}
if (flag)
{
HHM_Plugin.LogDebug("Attaching " + ((Object)_pickupable).name + " during load.");
component.AttachItem(_pickupable);
Holder = component;
}
}
public void DetachHolder()
{
if ((Object)(object)Holder != (Object)null)
{
Holder = null;
}
}
public void OnDestroy()
{
Holder?.DetachItem();
_disallowHangingOnTrigger = false;
}
}
public class AttachableItemHolder : MonoBehaviour
{
private Transform _itemRigidBody;
public PickupableItem AttachedItem { get; private set; }
public bool IsOccupied => (Object)(object)AttachedItem != (Object)null;
private void Awake()
{
_itemRigidBody = ((Component)((ShipItem)((Component)((Component)this).transform).GetComponent<ShipItemLampHook>()).itemRigidbodyC).transform;
}
internal void AttachItem(PickupableItem item)
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
AttachableItem component = ((Component)item).GetComponent<AttachableItem>();
if ((Object)(object)component == (Object)null)
{
HHM_Plugin.LogError("HolderAttachable is null, cannot hang item");
return;
}
AttachedItem = item;
ShipItem val = (ShipItem)(object)((item is ShipItem) ? item : null);
if (val != null)
{
Vector3 position = _itemRigidBody.TransformPoint(component.PositionOffset);
((Component)val.itemRigidbodyC).transform.position = position;
Quaternion rotation = _itemRigidBody.rotation * Quaternion.Euler(component.RotationOffset);
((Component)val.itemRigidbodyC).transform.rotation = rotation;
val.itemRigidbodyC.attached = true;
HHM_Plugin.LogDebug($"{val.name} item localpos: {((Component)val.itemRigidbodyC).transform.localPosition}, item parent: {((Component)val.itemRigidbodyC).transform.parent}");
}
else
{
HHM_Plugin.LogDebug($"{((Object)item).name} item localpos: {((Component)item).transform.localPosition}, item parent: {((Component)item).transform.parent}");
}
HHM_Plugin.AttachedItems.Add(item, this);
}
internal void DetachItem()
{
if ((Object)(object)AttachedItem == (Object)null)
{
return;
}
PickupableItem attachedItem = AttachedItem;
ShipItem val = (ShipItem)(object)((attachedItem is ShipItem) ? attachedItem : null);
if (val != null)
{
val.itemRigidbodyC.attached = false;
}
else
{
CapsuleCollider component = ((Component)AttachedItem).GetComponent<CapsuleCollider>();
if ((Object)(object)component != (Object)null)
{
((Collider)component).isTrigger = false;
}
}
HHM_Plugin.AttachedItems.Remove(AttachedItem);
((Component)AttachedItem).GetComponent<AttachableItem>().DetachHolder();
AttachedItem = null;
}
private void OnDestroy()
{
if (IsOccupied)
{
DetachItem();
}
}
}
internal class Configs
{
internal static ConfigEntry<bool> flipKnifeRotation;
internal static void InitializeConfigs()
{
ConfigFile config = ((BaseUnityPlugin)HHM_Plugin.Instance).Config;
flipKnifeRotation = config.Bind<bool>("Settings", "Knife hangs down", false, "Knife hangs down in the lamp hook instead of pointing up.");
}
}
}
namespace HooksHangMore.Patches
{
internal class UIPatches
{
[HarmonyPatch(typeof(LookUI), "ShowLookText")]
private class LookUIPatches
{
public static void Postfix(GoPointerButton button, TextMesh ___controlsText, GoPointer ___pointer, TextMesh ___textLicon, TextMesh ___textRIcon, ref bool ___showingIcon)
{
ShipItemLampHook val = (((Object)(object)button == (Object)null) ? null : ((Component)button).GetComponent<ShipItemLampHook>());
AttachableItemHolder attachableItemHolder = (((Object)(object)val == (Object)null) ? null : ((Component)val).GetComponent<AttachableItemHolder>());
PickupableItem val2 = (((Object)(object)___pointer == (Object)null) ? null : ___pointer.GetHeldItem());
AttachableItem attachableItem = (((Object)(object)val2 == (Object)null) ? null : ((Component)val2).GetComponent<AttachableItem>());
HangableItem val3 = (((Object)(object)val2 == (Object)null) ? null : ((Component)val2).GetComponent<HangableItem>());
if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)attachableItemHolder != (Object)null && attachableItemHolder.IsOccupied)
{
((Component)___textLicon).gameObject.SetActive(false);
___showingIcon = false;
___controlsText.text = "";
if (Object.op_Implicit((Object)(object)((Component)val2).GetComponent<ShipItemHammer>()) && ShipItemHammer.CanNail(((Component)button).GetComponent<ShipItem>()))
{
___showingIcon = true;
if (((Component)button).GetComponent<ShipItem>().nailed)
{
((Component)___textRIcon).gameObject.SetActive(true);
___controlsText.text = "\nunlock";
}
else
{
((Component)___textRIcon).gameObject.SetActive(true);
___controlsText.text = "\nlock";
}
}
}
else
{
if (!((Object)(object)val != (Object)null) || !((Object)(object)val2 != (Object)null) || (!((Object)(object)attachableItem != (Object)null) && !((Object)(object)val3 != (Object)null)) || attachableItemHolder.IsOccupied)
{
return;
}
string text = ((Component)val2).GetComponent<ShipItem>()?.name ?? "anchor";
((Component)___textLicon).gameObject.SetActive(true);
___showingIcon = true;
___controlsText.text = "attach " + text + "\n";
if (Object.op_Implicit((Object)(object)((Component)val2).GetComponent<ShipItemHammer>()) && ShipItemHammer.CanNail(((Component)button).GetComponent<ShipItem>()))
{
if (((Component)button).GetComponent<ShipItem>().nailed)
{
((Component)___textRIcon).gameObject.SetActive(true);
___controlsText.text = "attach " + text + "\nunlock";
}
else
{
((Component)___textRIcon).gameObject.SetActive(true);
___controlsText.text = "attach " + text + "\nlock";
}
}
}
}
}
}
}