Skip to content

Commit

Permalink
0.3.0
Browse files Browse the repository at this point in the history
- Fixed broken tutorial prompts
- Fixed Pale Reach title screen
- Made water transparent in the Reach
- Fix some depth effects in the Reach
- Dredge VR should now work directly with the mod manager and database
  • Loading branch information
xen-42 authored Dec 5, 2023
2 parents 0ee0900 + 3b3fd47 commit 216afdf
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
patreon: xen42
custom: ["https://paypal.me/xen42"]
14 changes: 5 additions & 9 deletions DredgeVR/DredgeVR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<PlatformTarget>x86</PlatformTarget>
<TargetFramework>net48</TargetFramework>
<LangVersion>default</LangVersion>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
Expand All @@ -25,23 +25,19 @@
<None Include="AssetBundles/**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="CopyToGame/**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DredgeVR.csproj.user" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DredgeGameLibs" Version="1.3.0" />
<PackageReference Include="DredgeGameLibs" Version="1.4.0" />
<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" />
<Reference Include="../dlls/*" />
</ItemGroup>

<ItemGroup>
<Compile Remove="VRCamera\NewFolder\**" />
<EmbeddedResource Remove="VRCamera\NewFolder\**" />
<None Remove="VRCamera\NewFolder\**" />
<Reference Remove="VRCamera\NewFolder\**" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions DredgeVR/Helpers/DLCHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace DredgeVR.Helpers;

public static class DLCHelper
{
public static bool OwnsThePaleReach() => GameManager.Instance.EntitlementManager.GetHasEntitlement(Entitlement.DLC_1);
}
35 changes: 35 additions & 0 deletions DredgeVR/Helpers/FileHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.IO;

namespace DredgeVR.Helpers;

public static class FileHelper
{
public static void Copy(string sourceDirectory, string targetDirectory)
{
DirectoryInfo diSource = new DirectoryInfo(sourceDirectory);
DirectoryInfo diTarget = new DirectoryInfo(targetDirectory);

CopyAll(diSource, diTarget);
}

public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
{
Directory.CreateDirectory(target.FullName);

// Copy each file into the new directory.
foreach (FileInfo fi in source.GetFiles())
{
Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);
fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);
}

// Copy each subdirectory using recursion.
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
{
DirectoryInfo nextTargetSubDir =
target.CreateSubdirectory(diSourceSubDir.Name);
CopyAll(diSourceSubDir, nextTargetSubDir);
}
}
}
20 changes: 18 additions & 2 deletions DredgeVR/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
using UnityEngine;
using UnityEngine.XR.Management;
using Valve.VR;
using System.Runtime.CompilerServices;

namespace DredgeVR
{
public class Loader
{
// Confuses me that the mod dll counts as the executing assembly
// Might change if we were using a different mod loader
// Should update Winch to provide these paths if it doesn't already
public static string DredgeVRFolder => Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;

// Bit hacky but eh
public static string DredgeFolder => Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.Parent.FullName;

public static void Initialize()
{
OptionsManager.Load();
Expand All @@ -26,6 +35,14 @@ public static void Initialize()
new Harmony("DredgeVR").PatchAll();
}

/// <summary>
/// This runs when the assembly is loaded
/// </summary>
public static void Preload()
{
FileHelper.Copy(Path.Combine(DredgeVRFolder, "CopyToGame"), Path.Combine(DredgeFolder, "DREDGE_Data"));
}

private static void SetUpXr()
{
SteamVR_Actions.PreInitialize();
Expand Down Expand Up @@ -54,8 +71,7 @@ private static void SetUpXr()
// SteamVR_Settings.instance.pauseGameWhenDashboardVisible = true;

// Makes it so that Dredge appears as a VR game in your Steam Home
var dredgeFolder = Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.Parent.FullName;
var manifestPath = Path.Combine(dredgeFolder, @"DREDGE_Data\StreamingAssets\dredge.vrmanifest");
var manifestPath = Path.Combine(DredgeFolder, @"DREDGE_Data\StreamingAssets\dredge.vrmanifest");
ApplicationManifestHelper.UpdateManifest(manifestPath,
"steam.app.1562430",
"https://steamcdn-a.akamaihd.net/steam/apps/1562430/header.jpg",
Expand Down
20 changes: 15 additions & 5 deletions DredgeVR/VRCamera/VRCameraManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,22 @@ private void OnSceneStart(string _)

private void OnTitleSceneStart()
{
// Make the player look towards the lighthouse
var lightHouse = GameObject.Find("TheMarrows/Islands/LittleMarrow").transform;
var worldPos = new Vector3(lightHouse.position.x, 0.5f, lightHouse.position.z);
if (DLCHelper.OwnsThePaleReach())
{
var camLookAt = GameObject.Find("DLC1Positions/DLC1CamLookAt").transform.position.ProjectOntoPlane(Vector3.up);

AnchorTransform.position = new Vector3(-90.6f, 1f, -1337.3f);
AnchorTransform.LookAt(camLookAt);
}
else
{
// Make the player look towards the lighthouse
var lightHouse = GameObject.Find("TheMarrows/Islands/LittleMarrow").transform;
var worldPos = new Vector3(lightHouse.position.x, 0.5f, lightHouse.position.z);

AnchorTransform.position = new Vector3(-6.5f, 0.5f, 0);
AnchorTransform.LookAt(worldPos);
AnchorTransform.position = new Vector3(-6.5f, 0.5f, 0);
AnchorTransform.LookAt(worldPos);
}
}

private void OnPlayerSpawned()
Expand Down
16 changes: 16 additions & 0 deletions DredgeVR/VRInput/VRInputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,25 @@ public static void InitControls()
AddNewBinding(GameManager.Instance.Input.Controls.TabLeft, SteamVR_Actions._default.TabLeft);
AddNewBinding(GameManager.Instance.Input.Controls.TabRight, SteamVR_Actions._default.TabRight);

// These bindings are only really used by the tutorial manager to check if the player is moving
AddNewBinding(GameManager.Instance.Input.controls.MoveForward, SteamVR_Actions._default.Move, Vector2.up);
AddNewBinding(GameManager.Instance.Input.controls.MoveBack, SteamVR_Actions._default.Move, Vector2.down);
AddNewBinding(GameManager.Instance.Input.controls.MoveLeft, SteamVR_Actions._default.Move, Vector2.left);
AddNewBinding(GameManager.Instance.Input.controls.MoveRight, SteamVR_Actions._default.Move, Vector2.right);

new CustomControl(SteamVR_Actions._default.RecenterCamera, VRCameraManager.Instance.RecenterCamera);
}

private static void AddNewBinding(PlayerAction action, SteamVR_Action_Vector2 vrAction, Vector2 direction)
{
var vrBindingSource = new VRVector2BindingSource(vrAction, direction);

action.AddDefaultBinding(vrBindingSource);
action.AddBinding(vrBindingSource);

DredgeVRLogger.Debug($"Added new binding for {action.Name} - {vrAction.GetShortName()}");
}

private static void AddNewBinding(PlayerAction action, SteamVR_Action_Boolean vrAction)
{
var vrBindingSource = new VRBindingSource(vrAction);
Expand Down
64 changes: 64 additions & 0 deletions DredgeVR/VRInput/VRVector2BindingSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using InControl;
using System.IO;
using UnityEngine;
using Valve.VR;

namespace DredgeVR.VRInput;

public class VRVector2BindingSource : BindingSource
{
public SteamVR_Action_Vector2 action;
private Vector2 _direction;

public string GetButtonName()
{
// Keep these localized because they will appear in text strings
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})";
}

public VRVector2BindingSource(SteamVR_Action_Vector2 action, Vector2 direction)
{
this.action = action;
this._direction = direction;
}

public override string Name => $"{action.GetShortName()} - {action.GetLocalizedOrigin(SteamVR_Input_Sources.Any)}";

public override string DeviceName => "VR";

public override InputDeviceClass DeviceClass => InputDeviceClass.Controller;

public override InputDeviceStyle DeviceStyle => InputDeviceStyle.Oculus;

public static BindingSourceType Source = BindingSourceType.UnknownDeviceBindingSource;
public override BindingSourceType BindingSourceType => Source;

public override bool Equals(BindingSource other)
{
return other is VRBindingSource otherVR && otherVR.action.Equals(action);
}

public override bool GetState(InputDevice inputDevice)
{
// Dot product greater than zero means that some part of this movement is in the direction specified
return Vector2.Dot(action.axis, _direction) > 0;
}

public override float GetValue(InputDevice inputDevice)
{
return GetState(inputDevice) ? 1f : 0f;
}

public override void Load(BinaryReader reader, ushort dataFormatVersion)
{

}

public override void Save(BinaryWriter writer)
{

}
}
5 changes: 0 additions & 5 deletions DredgeVR/VRUI/LoadScene/SceneLoadFade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace DredgeVR.VRUI;
[HarmonyPatch]
public class VRLoadingScene : MonoBehaviour
{
private MeshRenderer _meshRenderer;
private int _cameraLayerCache;

private bool _isInLoadingScreen;
Expand Down Expand Up @@ -74,8 +73,6 @@ public void ShowLoadScreen()

VRCameraManager.LeftEye.Camera.clearFlags = CameraClearFlags.Depth;
VRCameraManager.RightEye.Camera.clearFlags = CameraClearFlags.Depth;

_meshRenderer.forceRenderingOff = false;
}
}

Expand All @@ -89,8 +86,6 @@ public void HideLoadScreen()

VRCameraManager.LeftEye.Camera.clearFlags = CameraClearFlags.Skybox;
VRCameraManager.RightEye.Camera.clearFlags = CameraClearFlags.Skybox;

_meshRenderer.forceRenderingOff = true;
}
}
}
13 changes: 11 additions & 2 deletions DredgeVR/VRUI/VRUIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,17 @@ private void OnTitleSceneStart()
// We place the title screen canvas on the beach
var canvas = GameObject.Find("Canvases");

canvas.transform.position = new Vector3(-5.3f, 0.45f, 2f);
canvas.transform.rotation = Quaternion.Euler(0, 70, 0);
if (DLCHelper.OwnsThePaleReach())
{
canvas.transform.position = new Vector3(-91.1f, 1f, -1339.2f);
canvas.transform.rotation = Quaternion.Euler(0, 230, 0);
}
else
{
canvas.transform.position = new Vector3(-5.3f, 0.45f, 2f);
canvas.transform.rotation = Quaternion.Euler(0, 70, 0);
}

canvas.transform.localScale = Vector3.one * 0.002f;

// Remove controls tab for now since it doesnt work
Expand Down
10 changes: 9 additions & 1 deletion DredgeVR/World/Patches/DepthFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ private static void UpdateDepth(WaterController __instance)

if (GameManager.Instance.Player != null)
{
var t = Mathf.Clamp01(Mathf.InverseLerp(5, 30, GameManager.Instance.Player.PlayerDepthMonitor.currentDepth * 100));
var depth = GameManager.Instance.Player.PlayerDepthMonitor.currentDepth * 100; // m

var t = Mathf.Clamp01(Mathf.InverseLerp(5, 30, depth));
// High "depth" is clearer than low "depth"
var realDepth = currentDepth * Mathf.Lerp(1200, 400, t*t);

// In the middle of the ocean just make the water clear since theres no bottom anyway
if (depth >= 100)
{
realDepth = currentDepth * 1000f;
}

float depthToUse;

if (_previousDepth == -1f)
Expand Down
9 changes: 9 additions & 0 deletions DredgeVR/World/WorldManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ private void OnGameSceneStart()
// OnDestroy breaks the reference to the culling brain so we reconnect it so other scripts don't NRE
GameManager.Instance.CullingBrain = cullingBrain;
}

if (DLCHelper.OwnsThePaleReach())
{
foreach (var meshRenderer in GameObject.FindObjectsOfType<MeshRenderer>().Where(x => x.material.shader.name.Contains("DLC1TransparentIceShader")))
{
// Since we break depth textures we have to fix this shader
meshRenderer.material.SetFloat("_IceDepth", 0.00025f);
}
}
}

public void OnPlayerSpawned()
Expand Down
7 changes: 4 additions & 3 deletions DredgeVR/mod_meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"Name": "DredgeVR",
"ModGUID": "xen.DredgeVR",
"Version": "0.1.6",
"Version": "0.2.0",
"ModAssembly": "DredgeVR.dll",
"MinWinchVersion": "0.2.3",
"Entrypoint": "DredgeVR.Loader/Initialize"
"MinWinchVersion": "0.3.0",
"Entrypoint": "DredgeVR.Loader/Initialize",
"Preload": "DredgeVR.Loader/Preload"
}

0 comments on commit 216afdf

Please sign in to comment.