Skip to content

Commit

Permalink
fix sea monkey fumo positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Govorunb committed Apr 19, 2024
1 parent 4b011fa commit c60ce8d
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 13 deletions.
27 changes: 27 additions & 0 deletions SCHIZO/Items/Components/SeaMonkeyHeldItemOverrides.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using UnityEngine;

namespace SCHIZO.Items.Components;

partial class SeaMonkeyHeldItemOverrides
{
private Vector3 _savedLocalPos;
private Quaternion _savedLocalRot;
public void OnPickedUp()
{
if (!enabled) return;

_savedLocalPos = overrideTransform.localPosition;
_savedLocalRot = overrideTransform.localRotation;

overrideTransform.localPosition = localPosition;
overrideTransform.localEulerAngles = localRotation;
}

public void OnDropped()
{
if (!enabled) return;

overrideTransform.localPosition = _savedLocalPos;
overrideTransform.localRotation = _savedLocalRot;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using HarmonyLib;

namespace SCHIZO.Items.Components;
[HarmonyPatch]
public static class SeaMonkeyHeldItemOverridesPatches
{
[HarmonyPatch(typeof(SeaMonkeyHeldItem), nameof(SeaMonkeyHeldItem.Hold), [typeof(Pickupable), typeof(bool)])]
[HarmonyPostfix]
public static void OnHold(Pickupable pickupable)
{
if (!pickupable) return;
SeaMonkeyHeldItemOverrides overrideComponent = pickupable.GetComponent<SeaMonkeyHeldItemOverrides>();
if (!overrideComponent) return;

overrideComponent.OnPickedUp();
}

[HarmonyPatch(typeof(SeaMonkeyHeldItem), nameof(SeaMonkeyHeldItem.Drop))]
[HarmonyPrefix]
public static void OnDrop(SeaMonkeyHeldItem __instance)
{
if (!__instance.item) return;
SeaMonkeyHeldItemOverrides overrideComponent = __instance.item.GetComponent<SeaMonkeyHeldItemOverrides>();
if (!overrideComponent) return;

overrideComponent.OnDropped();
}
}
47 changes: 34 additions & 13 deletions Unity/Assets/Mod/Evil Fumo/Evil Fumo item.prefab
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!65 &4332142020512149085
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3050323588128677620}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 4.0000005, y: 4.3434496, z: 3.2994847}
m_Center: {x: -0, y: 2.1420708, z: -0.17539322}
--- !u!1 &4427810026626581335
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -177,6 +164,21 @@ MonoBehaviour:
m_EditorClassIdentifier:
propModel: {fileID: 853428788585080163}
viewModel: {fileID: 7656616662938203038}
--- !u!114 &7732719034029743030
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5958827312421353464}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: def191360849e4c4eb0083d03d029b81, type: 3}
m_Name:
m_EditorClassIdentifier:
overrideTransform: {fileID: 4242091266149702868}
localPosition: {x: 0, y: 0, z: 0}
localRotation: {x: -40, y: 0, z: 30}
--- !u!114 &5518736193718426385
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -197,6 +199,19 @@ MonoBehaviour:
_fabricatorMesh: {fileID: 4300000, guid: f02dbf41adbb6c14c8b2eb4704e4fd18, type: 2}
_fabricatorPrefab: {fileID: 4931248133309480, guid: 18b270460e531e34ca5ebc989dccd026,
type: 3}
--- !u!65 &4332142020512149085
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3050323588128677620}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 4.0000005, y: 4.3434496, z: 3.2994847}
m_Center: {x: -0, y: 2.1420708, z: -0.17539322}
--- !u!1001 &8219148621552729296
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -339,6 +354,12 @@ GameObject:
type: 3}
m_PrefabInstance: {fileID: 8219148621552729296}
m_PrefabAsset: {fileID: 0}
--- !u!4 &4242091266149702868 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5246314888156504068, guid: 494d51939a4d56f47a65310c2d52e286,
type: 3}
m_PrefabInstance: {fileID: 8219148621552729296}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2059160104811668376 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7963440748852813640, guid: 494d51939a4d56f47a65310c2d52e286,
Expand Down
21 changes: 21 additions & 0 deletions Unity/Assets/Mod/Neurofumo/Neurofumo item.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ MonoBehaviour:
underwaterDrag: 0.5
handleWind: 0
windScalar: 1
--- !u!114 &4318481871196627161
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5527787040625736568}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: def191360849e4c4eb0083d03d029b81, type: 3}
m_Name:
m_EditorClassIdentifier:
overrideTransform: {fileID: 6978155363206644661}
localPosition: {x: 0, y: 0, z: 0}
localRotation: {x: 0, y: 0, z: 0}
--- !u!114 &5550508841886641735
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -266,6 +281,12 @@ GameObject:
type: 3}
m_PrefabInstance: {fileID: 5020507161881458003}
m_PrefabAsset: {fileID: 0}
--- !u!4 &6978155363206644661 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2700769981969528550, guid: 5a15aed96d8d1b84592bfbe203825ee4,
type: 3}
m_PrefabInstance: {fileID: 5020507161881458003}
m_PrefabAsset: {fileID: 0}
--- !u!1 &3170597382691848538 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7614554720012481545, guid: 5a15aed96d8d1b84592bfbe203825ee4,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if UNITY_EDITOR
using SCHIZO.Interop.Subnautica.Enums;
#endif
using TriInspector;
using UnityEngine;

namespace SCHIZO.Items.Components
{
[AddComponentMenu("SCHIZO/Sea Monkey Held Item Overrides")]
public sealed partial class SeaMonkeyHeldItemOverrides : MonoBehaviour
{
[InfoBox("When a sea monkey grabs this object, temporarily set the target transform's local position and rotation.\n"
+ "Use this to fix misaligned items.")]
public Transform overrideTransform;
public Vector3 localPosition;
public Vector3 localRotation;

#if UNITY_EDITOR
private void OnValidate()
{
if (!enabled) return;

Component ecoTarget = GetComponent("EcoTarget");
EcoTargetType_All type = (EcoTargetType_All)HarmonyLib.AccessTools.Field(ecoTarget.GetType(), "type").GetValue(ecoTarget);
if (type != EcoTargetType_All.Shiny)
Debug.LogWarning("Sea monkeys only steal Shiny items, so these overrides are useless");
}
private void OnDisable() {}
private void OnEnable() {}
#endif
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c60ce8d

Please sign in to comment.