Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable rotating TH with QSB #536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions NomaiVR/EffectFixes/FixProbeCannonVisibility.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using NomaiVR.Helpers;
using NomaiVR.ModConfig;
using UnityEngine;

namespace NomaiVR.EffectFixes
Expand All @@ -20,6 +21,8 @@ internal class Patch: NomaiVRPatch

public override void ApplyPatches()
{
if (NomaiVR.Helper.Interaction.ModExists("Raicuparta.QuantumSpaceBuddies"))
return;
// OWRigidBody will unparent every physics object, so the rotation of Timber Hearth needs to happen
// before OWRigidBody.Awake. Otherwise those objects would stay behind.
Prefix<OWRigidbody>(nameof(OWRigidbody.Awake), nameof(RotateTimberHearth));
Expand All @@ -31,7 +34,7 @@ public override void ApplyPatches()
// Rotate Timber Hearth so that Giand's Deep is visible without the player looking up.
private static void RotateTimberHearth()
{
if (isInitialized) return;
if (isInitialized || !ModSettings.RotateTimberHearth) return;
isInitialized = true;

if (!SceneHelper.IsInSolarSystem()) return;
Expand All @@ -46,16 +49,16 @@ private static void RotateTimberHearth()
// Rotate player around their Y axis so that they start facing Giant's Deep.
private static void RotatePlayer(PlayerSpawner __instance)
{
if (__instance._initialSpawnPoint == null || LoadManager.GetCurrentScene() != OWScene.SolarSystem) return;
if (__instance._initialSpawnPoint == null || LoadManager.GetCurrentScene() != OWScene.SolarSystem || !ModSettings.RotateTimberHearth) return;
var playerTransform = __instance._playerBody.transform;
var playerPosition = playerTransform.position;
var playerUp = playerTransform.up;
var playerForward = playerTransform.forward;
var projectedPosition = Vector3.Project(playerPosition, playerUp) - playerPosition;
var giantsDeepPosition = Locator.GetAstroObject(AstroObject.Name.GiantsDeep).transform.position;
var projectedForward = Vector3.Project(playerForward, playerUp);
var siantsDeepDirection = Vector3.Project(giantsDeepPosition - playerPosition, playerUp);
var angle = Vector3.Angle(projectedForward, siantsDeepDirection);
var giantsDeepDirection = Vector3.Project(giantsDeepPosition - playerPosition, playerUp);
var angle = Vector3.Angle(projectedForward, giantsDeepDirection);
var rotationOffset = Quaternion.AngleAxis(Vector3.Angle(playerForward, projectedPosition) + angle, playerUp);
playerTransform.rotation = rotationOffset * playerTransform.rotation;
}
Expand Down
1 change: 1 addition & 0 deletions NomaiVR/ModConfig/IModSettingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface IModSettingProvider
bool EnableFeetMarker { get; }
bool PreventClipping { get; }
bool FlashlightGesture { get; }
bool RotateTimberHearth { get; }
bool ControllerOrientedMovement { get; }
bool AutoHideToolbelt { get; }
float ToolbeltHeight { get; }
Expand Down
1 change: 1 addition & 0 deletions NomaiVR/ModConfig/ModSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static class ModSettings
public static bool EnableFeetMarker => settingsProvider.EnableFeetMarker;
public static bool PreventClipping => settingsProvider.PreventClipping;
public static bool FlashlightGesture => settingsProvider.FlashlightGesture;
public static bool RotateTimberHearth => settingsProvider.RotateTimberHearth;
public static bool ControllerOrientedMovement => settingsProvider.ControllerOrientedMovement;
public static bool AutoHideToolbelt => settingsProvider.AutoHideToolbelt;
public static float ToolbeltHeight => settingsProvider.ToolbeltHeight;
Expand Down
2 changes: 2 additions & 0 deletions NomaiVR/ModConfig/OWMLSettingsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class OwmlSettingsProvider : IModSettingProvider
public bool EnableFeetMarker { get; private set; }
public bool PreventClipping { get; private set; }
public bool FlashlightGesture { get; private set; }
public bool RotateTimberHearth { get; private set; }
public bool ControllerOrientedMovement { get; private set; }
public bool AutoHideToolbelt { get; private set; }
public float ToolbeltHeight { get; private set; }
Expand All @@ -42,6 +43,7 @@ public void Configure()
EnableHandLaser = config.GetSettingsValue<bool>("showHandLaser");
EnableFeetMarker = config.GetSettingsValue<bool>("showFeetMarker");
FlashlightGesture = config.GetSettingsValue<bool>("flashlightGesture");
RotateTimberHearth = config.GetSettingsValue<bool>("rotateTimberHearth");
PreventClipping = config.GetSettingsValue<bool>("preventClipping");
DebugMode = config.GetSettingsValue<bool>("debug");
AutoHideToolbelt = config.GetSettingsValue<bool>("autoHideToolbelt");
Expand Down
7 changes: 7 additions & 0 deletions NomaiVR/ModConfig/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@
"yes": "Enabled",
"no": "Disabled"
},
"rotateTimberHearth": {
"type": "toggle",
"value": true,
"title": "Rotate Timber Hearth",
"yes": "Enabled",
"no": "Disabled"
},
"disableCursorLock": {
"type": "toggle",
"value": true,
Expand Down