diff --git a/SCHIZO/Items/Data/ItemData.cs b/SCHIZO/Items/Data/ItemData.cs index fbd85ff8..3e777108 100644 --- a/SCHIZO/Items/Data/ItemData.cs +++ b/SCHIZO/Items/Data/ItemData.cs @@ -28,19 +28,11 @@ protected override void Register() protected override void PostRegister() { -#if SUBNAUTICA - if (!registerInSN) + if (!RetargetHelpers.Pick(registerInSN, registerInBZ)) { - LOGGER.LogMessage($"Not registering {classId} in SN"); + LOGGER.LogMessage($"Not registering {classId} in {(IS_BELOWZERO ? "BZ" : "SN")}"); return; } -#else - if (!registerInBZ) - { - LOGGER.LogMessage($"Not registering {classId} in BZ"); - return; - } -#endif LOGGER.LogDebug($"Creating prefab {loader.GetType().Name} for {classId}"); loader.Load(ModItem); diff --git a/SCHIZO/Items/FumoItem/FumoItemTool.BelowZero.cs b/SCHIZO/Items/FumoItem/FumoItemTool.BelowZero.cs index 98dbbc87..c7f2c09c 100644 --- a/SCHIZO/Items/FumoItem/FumoItemTool.BelowZero.cs +++ b/SCHIZO/Items/FumoItem/FumoItemTool.BelowZero.cs @@ -6,16 +6,17 @@ public partial class FumoItemTool { private (Transform parent, Vector3 localPosOffset) GetHugOffset(float distScale) { + Transform player = usingPlayer.transform; // TODO: move just the arms instead of the entire body (IK) - Transform parent = transform.root.Find("body").GetChild(0); + Transform parent = player.Find("body").GetChild(0); // to chest (a bit lower than camera/face) - Vector3 worldDirectionToPlayer = usingPlayer.transform.position + _chestOffset - transform.position; + Vector3 worldDirectionToPlayer = player.position + _chestOffset - transform.position; Vector3 worldOffset = Vector3.Slerp(Vector3.zero, worldDirectionToPlayer * _hugDistance, Mathf.Clamp01(distScale)); Vector3 localOffset = parent.worldToLocalMatrix.MultiplyVector(worldOffset); // in BZ the camera is attached to the body - Transform cam = transform.root.Find("camPivot/camRoot/camOffset/pdaCamPivot"); + Transform cam = player.Find("camPivot/camRoot/camOffset/pdaCamPivot"); cam.localPosition = cam.worldToLocalMatrix.MultiplyVector(-worldOffset); return (parent, localOffset); diff --git a/SCHIZO/Items/FumoItem/FumoItemTool.Subnautica.cs b/SCHIZO/Items/FumoItem/FumoItemTool.Subnautica.cs index 1354629e..ca97d827 100644 --- a/SCHIZO/Items/FumoItem/FumoItemTool.Subnautica.cs +++ b/SCHIZO/Items/FumoItem/FumoItemTool.Subnautica.cs @@ -7,11 +7,12 @@ partial class FumoItemTool { private (Transform parent, Vector3 localPosOffset) GetHugOffset(float distScale) { + Transform player = usingPlayer.transform; // TODO: move just the arms instead of the entire body (IK) - Transform parent = transform.root.Find("body").GetChild(0); + Transform parent = player.Find("body").GetChild(0); // to chest (a bit lower than camera/face) - Vector3 worldDirectionToPlayer = usingPlayer.transform.position + _chestOffset - transform.position; + Vector3 worldDirectionToPlayer = player.position + _chestOffset - transform.position; Vector3 localDirectionToPlayer = parent.worldToLocalMatrix.MultiplyVector(worldDirectionToPlayer); Vector3 offset = Vector3.Slerp(Vector3.zero, localDirectionToPlayer * _hugDistance, Mathf.Clamp01(distScale)); diff --git a/SCHIZO/Jukebox/CustomJukeboxTrackPatches.BelowZero.cs b/SCHIZO/Jukebox/CustomJukeboxTrackPatches.BelowZero.cs index 41f5261a..1089193b 100644 --- a/SCHIZO/Jukebox/CustomJukeboxTrackPatches.BelowZero.cs +++ b/SCHIZO/Jukebox/CustomJukeboxTrackPatches.BelowZero.cs @@ -22,6 +22,7 @@ public static class CustomJukeboxTrackPatches static CustomJukeboxTrackPatches() { CoroutineHost.StartCoroutine(GetJukeboxDiskPrefab()); + CoroutineHost.StartCoroutine(InitJukebox()); } private static IEnumerator GetJukeboxDiskPrefab() { @@ -36,6 +37,14 @@ private static IEnumerator GetJukeboxDiskPrefab() LOGGER.LogDebug("Loaded default prefab for custom tracks"); } + private static IEnumerator InitJukebox() + { + while (PlatformUtils.main.GetServices() == null) + yield return null; + + _ = BZJukebox.main; + } + [HarmonyPatch(typeof(BZJukebox), nameof(BZJukebox.Awake))] public static class AwakeWorkaround { @@ -56,13 +65,11 @@ public static void AddCustomTracks(BZJukebox __instance) CustomJukeboxTrack track = pair.Value; BZJukebox.unlockableMusic[pair.Key] = track.identifier; - BZJukebox.musicLabels[track.identifier] = track.trackLabel; // only read inside Awake but why not __instance._info[track.identifier] = track.ToTrackInfo(false); } } } - [HarmonyPatch(typeof(JukeboxInstance), nameof(JukeboxInstance.Start))] [HarmonyPatch(typeof(uGUI_SeaTruckSegment), nameof(uGUI_SeaTruckSegment.Awake))] [HarmonyPostfix]