Skip to content

Commit

Permalink
0.3.4
Browse files Browse the repository at this point in the history
The Pale Reach should all work properly now with this update

- Cutscenes in The Pale Reach DLC now actually play out
- Fix infected fish particle orientation
- Hide laser pointers when hiding UI
- Show "UNBOUND" in tutorial popups if an input is missing
- Fix snow position on Pale Reach title screen
- Removed the "disable distance particles" option because it was buggy
- Fixed message entries disappearing when changing tabs
- Fixed held message positions
  • Loading branch information
xen-42 authored Jan 18, 2024
2 parents 17e9d9d + b637b3d commit 46d2342
Show file tree
Hide file tree
Showing 15 changed files with 290 additions and 95 deletions.
4 changes: 2 additions & 2 deletions DredgeVR/DredgeVR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DredgeGameLibs" Version="1.4.0" />
<PackageReference Include="DredgeGameLibs" Version="1.4.2" />
<PackageReference Include="HarmonyX" Version="2.10.2" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Winch" Version="0.2.3" />
<PackageReference Include="Winch" Version="0.3.1" />
<Reference Include="../dlls/*" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions DredgeVR/DredgeVRCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public void Awake()
gameObject.AddComponent<WorldManager>();
gameObject.AddComponent<VRTutorialManager>();

#if DEBUG
gameObject.AddComponent<DebugCommands>();
#endif

SceneManager.sceneUnloaded += OnActiveSceneUnloaded;
SceneManager.activeSceneChanged += OnActiveSceneChanged;

Expand Down
37 changes: 37 additions & 0 deletions DredgeVR/Helpers/DebugCommands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using UnityEngine;

namespace DredgeVR.Helpers;

public class DebugCommands : MonoBehaviour
{
private List<(KeyCode, Action)> commands = new()
{
(KeyCode.Keypad1, TryInfect)
};

public void Update()
{
foreach (var (key, action) in commands)
{
if (Input.GetKeyDown(key))
{
NotificationHelper.ShowNotificationWithColour(NotificationType.NONE, $"Invoked debug action {action.Method.Name}", DredgeColorTypeEnum.POSITIVE);
try
{
action.Invoke();
}
catch (Exception ex)
{
NotificationHelper.ShowNotificationWithColour(NotificationType.NONE, $"Failed {ex}", DredgeColorTypeEnum.NEGATIVE);
}
}
}
}

private static void TryInfect()
{
GameManager.Instance.GridManager.InfectRandomItemInInventory();
}
}
22 changes: 22 additions & 0 deletions DredgeVR/Helpers/NotificationHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Taken from Cosmic Horror Fishing Buddies
namespace DredgeVR.Helpers
{
internal static class NotificationHelper
{
public static void ShowNotificationWithColour(NotificationType notificationType, string text, DredgeColorTypeEnum colour)
{
ShowNotificationWithColour(notificationType, text, GameManager.Instance.LanguageManager.GetColorCode(colour));
}

public static void ShowNotificationWithColour(NotificationType notificationType, string text, string colourCode)
{
ShowNotification(notificationType, $"<color=#{colourCode}>{text}</color>");
}

public static void ShowNotification(NotificationType notificationType, string text)
{
GameEvents.Instance.TriggerNotification(notificationType, text);
DredgeVRLogger.Info($"Wrote notification: {text}");
}
}
}
8 changes: 8 additions & 0 deletions DredgeVR/Messages/Patches/MessagesWindowPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ public static void MessagesWindow_Show(MessagesWindow __instance)
__instance.messageEntryContainer.localPosition = Vector3.zero;
__instance.transform.Find("Container/Scrim").gameObject.SetActive(false);
}

[HarmonyPostfix]
[HarmonyPatch(nameof(MessagesWindow.OnTabChanged))]
public static void MessagesWindow_OnTabChanged(MessagesWindow __instance)
{
// Not sure why but something in the refresh moves it here as well
__instance.messageEntryContainer.transform.localPosition = Vector3.zero;
}
}
6 changes: 0 additions & 6 deletions DredgeVR/Options/OptionsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ public class OptionsConfig
[JsonProperty]
public bool disableExtraParticleEffects = false;

/// <summary>
/// Disables particles effects over 100m away. Improves performance
/// </summary>
[JsonProperty]
public bool disableDistantParticleEffects = true;

/// <summary>
/// Not ideal for now because it makes some rocks literally invisible, but helps with performance.
/// </summary>
Expand Down
97 changes: 97 additions & 0 deletions DredgeVR/VRCamera/Patches/TriggerableTimelinePatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using Cinemachine;
using Cinemachine.Utility;
using DredgeVR.VRUI;
using HarmonyLib;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace DredgeVR.VRCamera.Patches;

[HarmonyPatch(typeof(TriggerableTimeline))]
public static class TriggerableTimelinePatches
{
private static bool _playing;
private static CinemachineVirtualCamera _camera;
private static CinemachineVirtualCamera[] _cameras;

[HarmonyPostfix]
[HarmonyPatch(nameof(TriggerableTimeline.Play))]
public static void TriggerableTimeline_Play(TriggerableTimeline __instance)
{
_playing = true;
_camera = null;
_cameras = __instance.GetComponentsInChildren<CinemachineVirtualCamera>(true);

VRCameraManager.Instance.StartCoroutine(TriggerableTimelineLogic(__instance));
}

[HarmonyPostfix]
[HarmonyPatch(nameof(TriggerableTimeline.OnTimelineComplete))]
public static void TriggerableTimeline_OnTimelineComplete(TriggerableTimeline __instance)
{
_playing = false;
}

private static IEnumerator TriggerableTimelineLogic(TriggerableTimeline __instance)
{
VRUIManager.HideHeldUI();
VRCameraManager.Instance.InCutscene = true;

while (_playing)
{
var prevCamera = _camera;

if (_camera == null || !_camera.gameObject.activeInHierarchy)
{
// Try to update the camera to an active one
_camera = _cameras.FirstOrDefault(x => x.gameObject.activeInHierarchy);
if (prevCamera != _camera)
{
if (_camera != null)
{
// When the camera changes we fade out the screen first
yield return ShowLoadingScreen(true);

// Camera exists, move to it
VRCameraManager.AnchorTransform.transform.position = _camera.transform.position;
VRCameraManager.AnchorTransform.transform.LookAt(_camera.transform.position + _camera.transform.forward.ProjectOntoPlane(Vector3.up));

yield return ShowLoadingScreen(false);
}
}
}

yield return new WaitForSeconds(0.1f);
}

yield return ShowLoadingScreen(true);

VRCameraManager.Instance.InCutscene = false;

VRCameraManager.Instance.ResetAnchorToBoat();

yield return ShowLoadingScreen(false);

VRUIManager.ShowHeldUI();
}

private static bool _showingLoadingScreen;
private static YieldInstruction ShowLoadingScreen(bool show)
{
if (show != _showingLoadingScreen)
{
_showingLoadingScreen = show;
GameManager.Instance.Loader.loadingScreen.Fade(show, true);
return new WaitForSeconds(1f);
}
else
{
return new WaitForEndOfFrame();
}
}
}
51 changes: 44 additions & 7 deletions DredgeVR/VRCamera/VRCameraManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Cinemachine.Utility;
using Cinemachine;
using Cinemachine.Utility;
using DredgeVR.Helpers;
using DredgeVR.Options;
using DredgeVR.VRInput;
using DredgeVR.VRUI;
using HarmonyLib;
using System.Collections;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.Experimental.Rendering.Universal;
using UnityEngine.Rendering;
Expand Down Expand Up @@ -31,7 +35,7 @@ public class VRCameraManager : MonoBehaviour
public float minX = 0.5f;
private bool _justTurned;

private bool _inFinaleCutscene;
public bool InCutscene;

public void Awake()
{
Expand Down Expand Up @@ -139,6 +143,9 @@ private void OnTitleSceneStart()

AnchorTransform.position = new Vector3(-90.6f, 1f, -1337.3f);
AnchorTransform.LookAt(camLookAt);

// Move snow particles to the anchor position
GameObject.Find("VCam/Snow").transform.position = AnchorTransform.position;
}
else
{
Expand All @@ -153,7 +160,7 @@ private void OnTitleSceneStart()

private void OnPlayerSpawned()
{
_inFinaleCutscene = false;
InCutscene = false;

// Make the player follow the boat
AnchorTransform.parent = GameManager.Instance.Player.transform;
Expand All @@ -177,7 +184,7 @@ public void Update()
// Else you bump into something and dear god
if (SceneManager.GetActiveScene().name == "Game")
{
if (_inFinaleCutscene)
if (InCutscene)
{

}
Expand Down Expand Up @@ -223,9 +230,9 @@ public void RecenterCamera()
}
}

private void ResetAnchorToBoat()
public void ResetAnchorToBoat()
{
if (_inFinaleCutscene) return;
if (InCutscene) return;

AnchorTransform.localPosition = OptionsManager.Options.PlayerPosition;

Expand Down Expand Up @@ -270,7 +277,7 @@ private void UpdateCameraRotation()

private void OnCutToCredits()
{
_inFinaleCutscene = true;
InCutscene = true;
AnchorTransform.parent = null;
AnchorTransform.transform.position = new Vector3(18, 7, 4);
AnchorTransform.transform.rotation = Quaternion.Euler(0, 270, 0);
Expand All @@ -292,4 +299,34 @@ private void OnCutToCredits()
[HarmonyPostfix]
[HarmonyPatch(typeof(FinaleCutsceneLogic), nameof(FinaleCutsceneLogic.CutToCredits))]
public static void FinaleCutsceneLogic_CutToCredits() => Instance.OnCutToCredits();

/*
[HarmonyPostfix]
[HarmonyPatch(typeof(CinematicCamera), nameof(CinematicCamera.Play))]
public static void CinematicCamera_Play(CinematicCamera __instance)
{
// Final cutscene has its own separate logic
// This is for TPR
if (!Instance._inFinaleCutscene)
{
Instance.StartCoroutine(Instance.WaitForCinematicToFinish(__instance.virtualCamera));
VRUIManager.HideHeldUI();
}
}
private IEnumerator WaitForCinematicToFinish(CinemachineVirtualCamera camera)
{
while(camera.enabled)
{
AnchorTransform.position = camera.transform.position;
yield return new WaitForFixedUpdate();
}
// Go back to regular camera
ResetAnchorToBoat();
VRUIManager.ShowHeldUI();
}
*/


}
9 changes: 8 additions & 1 deletion DredgeVR/VRInput/VRBindingSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ public string GetButtonName()
var button = action.GetLocalizedOriginPart(SteamVR_Input_Sources.Any, EVRInputStringBits.VRInputString_InputSource);
var hand = action.GetLocalizedOriginPart(SteamVR_Input_Sources.Any, EVRInputStringBits.VRInputString_Hand);

return $"{button} ({hand})";
if (string.IsNullOrEmpty(button) || string.IsNullOrEmpty(hand))
{
return "UNBOUND";
}
else
{
return $"{button} ({hand})";
}
}

public VRBindingSource(SteamVR_Action_Boolean action)
Expand Down
Loading

0 comments on commit 46d2342

Please sign in to comment.