-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
153 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
SCHIZO/Items/Components/SeaMonkeyHeldItemOverridesPatches.BelowZero.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Unity/Assets/Scripts/SCHIZO/Items/Components/SeaMonkeyHeldItemOverrides.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Unity/Assets/Scripts/SCHIZO/Items/Components/SeaMonkeyHeldItemOverrides.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.