Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed Nov 7, 2023
2 parents aa243b2 + 6072433 commit 76ecb76
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
12 changes: 2 additions & 10 deletions SCHIZO/Items/Data/ItemData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions SCHIZO/Items/FumoItem/FumoItemTool.BelowZero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions SCHIZO/Items/FumoItem/FumoItemTool.Subnautica.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
11 changes: 9 additions & 2 deletions SCHIZO/Jukebox/CustomJukeboxTrackPatches.BelowZero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class CustomJukeboxTrackPatches
static CustomJukeboxTrackPatches()
{
CoroutineHost.StartCoroutine(GetJukeboxDiskPrefab());
CoroutineHost.StartCoroutine(InitJukebox());
}
private static IEnumerator GetJukeboxDiskPrefab()
{
Expand All @@ -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
{
Expand All @@ -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]
Expand Down

0 comments on commit 76ecb76

Please sign in to comment.