Skip to content

Commit b0ea66f

Browse files
committed
Few more 1.1.0 changes
- Disabled AO (major performance boost) - Fix one enemy patch not being applied - Bump BepInEx requirement - Add eye tracking debug flag
1 parent 505cf25 commit b0ea66f

File tree

10 files changed

+91
-49
lines changed

10 files changed

+91
-49
lines changed

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# 1.1.0
22

3-
-- BUGS --
3+
-- TODOs --
44

5-
- Flashlight not aligned (needs more testing)
5+
- LocalPlayerCamera maybe not being synced properly
6+
- Dead head spectate tip might have wrong controls
7+
- Compact canvas UI a little bit (on X axis) so it's easier to see
8+
- Grab map shoulder is only on one side (should be both), also no haptic feedback
69

710
## Detached Arms
811

@@ -39,10 +42,12 @@ You can now swap between VR mode and flatscreen mode by pressing the F8 button o
3942
- Added hotswapping in the main menu (F8)
4043

4144
**Changes**:
45+
- The ceiling eye now darkens the world except for where the eye is (no more cheating hihi)
4246
- Removed the performance tab and replaced it with UI in the settings
4347
- Replaced the valuable discover overlay with a new 3D graphic (supports custom colors)
4448
- You now look at the enemy/object that killed you while the death animation plays (if possible)
45-
- Optimized the custom camera by adding a frame rate limiter
49+
- Slightly optimized the custom camera by adding a frame rate limiter
50+
- Optimized framerate by forcibly disabling ambient occlusion (20%-40% less render time)
4651
- Renamed "Dynamic Smooth Speed" to "Analog Smooth Turn"
4752
- Changed the minimum possible HUD height value to account for detached hands
4853
- The map tool can now also be grabbed from behind your head (near the shoulders)

Source/Experiments.cs

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
using System.Collections.Generic;
44
using System.Reflection.Emit;
55
using HarmonyLib;
6+
using UnityEngine;
67

78
namespace RepoXR;
89

910
#if DEBUG
1011
internal static class Experiments
1112
{
1213
[HarmonyPatch(typeof(EnemyDirector), nameof(EnemyDirector.Awake))]
13-
[HarmonyPostfix]
14+
// [HarmonyPostfix]
1415
private static void FuckLolEnemy(EnemyDirector __instance)
1516
{
1617
// Difficulty 1 enemies
@@ -50,7 +51,7 @@ private static void FuckLolEnemy(EnemyDirector __instance)
5051
private static bool done;
5152

5253
[HarmonyPatch(typeof(MenuButton), nameof(MenuButton.OnHovering))]
53-
[HarmonyPrefix]
54+
// [HarmonyPrefix]
5455
private static void ForceMap()
5556
{
5657
if (done)
@@ -70,22 +71,28 @@ private static void ForceMap()
7071

7172
var boombox = museum.ValuablePresets[0].big[2];
7273

73-
for (var i = 0; i < museum.ValuablePresets.Count; i++)
74+
foreach (var preset in museum.ValuablePresets)
7475
{
75-
for (var j = 0; j < museum.ValuablePresets[i].big.Count; j++)
76-
Logger.LogDebug($"[{museum.ValuablePresets[i]}] Big: {museum.ValuablePresets[i].big[j].prefabName}");
77-
for (var j = 0; j < museum.ValuablePresets[i].medium.Count; j++)
78-
Logger.LogDebug($"[{museum.ValuablePresets[i]}] Medium: {museum.ValuablePresets[i].medium[j].prefabName}");
79-
for (var j = 0; j < museum.ValuablePresets[i].small.Count; j++)
80-
Logger.LogDebug($"[{museum.ValuablePresets[i]}] Small: {museum.ValuablePresets[i].small[j].prefabName}");
81-
for (var j = 0; j < museum.ValuablePresets[i].tall.Count; j++)
82-
Logger.LogDebug($"[{museum.ValuablePresets[i]}] Tall: {museum.ValuablePresets[i].tall[j].prefabName}");
83-
for (var j = 0; j < museum.ValuablePresets[i].tiny.Count; j++)
84-
Logger.LogDebug($"[{museum.ValuablePresets[i]}] Tiny: {museum.ValuablePresets[i].tiny[j].prefabName}");
85-
for (var j = 0; j < museum.ValuablePresets[i].veryTall.Count; j++)
86-
Logger.LogDebug($"[{museum.ValuablePresets[i]}] Very Tall: {museum.ValuablePresets[i].veryTall[j].prefabName}");
87-
for (var j = 0; j < museum.ValuablePresets[i].wide.Count; j++)
88-
Logger.LogDebug($"[{museum.ValuablePresets[i]}] Wide: {museum.ValuablePresets[i].wide[j].prefabName}");
76+
foreach (var val in preset.big)
77+
Logger.LogDebug($"[{preset}] Big: {val.prefabName}");
78+
79+
foreach (var val in preset.medium)
80+
Logger.LogDebug($"[{preset}] Medium: {val.prefabName}");
81+
82+
foreach (var val in preset.small)
83+
Logger.LogDebug($"[{preset}] Small: {val.prefabName}");
84+
85+
foreach (var val in preset.tall)
86+
Logger.LogDebug($"[{preset}] Tall: {val.prefabName}");
87+
88+
foreach (var val in preset.tiny)
89+
Logger.LogDebug($"[{preset}] Tiny: {val.prefabName}");
90+
91+
foreach (var val in preset.veryTall)
92+
Logger.LogDebug($"[{preset}] Very Tall: {val.prefabName}");
93+
94+
foreach (var val in preset.wide)
95+
Logger.LogDebug($"[{preset}] Wide: {val.prefabName}");
8996
}
9097

9198
museum.ValuablePresets[0].big.Clear();
@@ -153,5 +160,17 @@ private static void IAmASurgeonIMeanDeveloper(ref bool __result)
153160
{
154161
__result = true;
155162
}
163+
164+
[HarmonyPatch(typeof(DebugConsoleUI), nameof(DebugConsoleUI.Update))]
165+
[HarmonyTranspiler]
166+
[HarmonyDebug]
167+
private static IEnumerable<CodeInstruction> KeepEnterKeyThing(IEnumerable<CodeInstruction> instructions)
168+
{
169+
return new CodeMatcher(instructions)
170+
.MatchForward(false, new CodeMatch(OpCodes.Ldc_I4_S, (sbyte)9))
171+
.SetOperandAndAdvance((sbyte)KeyCode.Return)
172+
.SetOperandAndAdvance(AccessTools.Method(typeof(UnityEngine.Input), nameof(UnityEngine.Input.GetKeyDown), [typeof(KeyCode)]))
173+
.InstructionEnumeration();
174+
}
156175
}
157176
#endif

Source/Patches/Enemy/EnemyOoglyPatches.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88

99
namespace RepoXR.Patches.Enemy;
1010

11+
[RepoXRPatch]
1112
internal static class EnemyOoglyPatches
1213
{
14+
/// <summary>
15+
/// Oh you don't wanna know... oh the horror (look at oogly while being attached)
16+
/// </summary>
1317
[HarmonyPatch(typeof(EnemyOogly), nameof(EnemyOogly.UpdateEvilEyesTimer))]
1418
[HarmonyTranspiler]
1519
private static IEnumerable<CodeInstruction> LookAtPatch(IEnumerable<CodeInstruction> instructions)

Source/Patches/Enemy/EnemySpinnyPatches.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ namespace RepoXR.Patches.Enemy;
77
internal static class EnemySpinnyPatches
88
{
99
/// <summary>
10-
/// TODO: I don't yet know what this enemy does or looks like
10+
/// Make sure to always look at the little gambling machine
1111
/// </summary>
1212
[HarmonyPatch(typeof(EnemySpinny), nameof(EnemySpinny.OverrideTargetPlayerCameraAim))]
1313
[HarmonyPrefix]
1414
private static bool OverrideVRCameraAim(EnemySpinny __instance, float _strenght, float _strenghtNoAim)
1515
{
16+
// Always low impact, there's not really a need to force up-down look here
1617
VRCameraAim.instance.SetAimTargetSoft(__instance.spinnyWheel.position, 0.1f, _strenght, _strenghtNoAim,
17-
__instance.gameObject, 100, Plugin.Config.ReducedAimImpact.Value);
18+
__instance.gameObject, 100, true);
1819

1920
return false;
2021
}

Source/Patches/HarmonyPatcher.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ internal enum RepoXRPatchTarget
8787
/// https://github.com/BepInEx/HarmonyX/blob/master/Harmony/Internal/Patching/ILManipulator.cs#L322
8888
/// Licensed under MIT: https://github.com/BepInEx/HarmonyX/blob/master/LICENSE
8989
/// </summary>
90+
// TODO: It is unclear how BepInEx currently chooses Harmony versions, so we keep this patch in for now
9091
[RepoXRPatch(RepoXRPatchTarget.Universal)]
9192
[HarmonyPriority(Priority.First)]
9293
internal static class LeaveMyLeaveAlonePatch

Source/Patches/InputPatches.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ private static bool KeyPullAndPush(ref float __result)
190190

191191
var pull = Actions.Instance["Pull"].ReadValue<float>();
192192
if (pull > 0)
193-
{
194193
__result = -pull;
195-
return false;
196-
}
197194

198195
return false;
199196
}

Source/Patches/Player/PlayerEyesPatches.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ private static void LookAtTransformEyeTracking(PlayerEyes __instance)
1919
if (!__instance.playerAvatar || __instance.playerAvatar.isLocal)
2020
return;
2121

22-
// TODO: Determine if certain occurrences in the game should override eye gaze
23-
2422
if (!NetworkSystem.instance.GetNetworkPlayer(__instance.playerAvatar, out var player) || !player.EyeTracking)
2523
return;
2624

Source/Player/VREyeTracking.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ private void Awake()
2828

2929
Plugin.Config.EnableEyeTracking.SettingChanged += OnEyeTrackingSettingChanged;
3030

31-
// TODO: Remove once tested with real hardware
31+
if (!Plugin.Flags.HasFlag(Flags.EyeTrackingDebug))
32+
return;
33+
3234
debugCube = Instantiate(AssetCollection.Cube).transform;
3335
debugCube.GetComponent<MeshRenderer>().material.color = Color.blue;
3436
debugCube.GetComponent<Collider>().enabled = false;
@@ -101,6 +103,9 @@ private void Update()
101103

102104
NetworkSystem.instance.UpdateEyeTracking(position);
103105

106+
if (!debugCube)
107+
return;
108+
104109
debugCube.position = position;
105110
debugCube.rotation = Quaternion.LookRotation(ray.direction);
106111
}

Source/Plugin.cs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@ public class Plugin : BaseUnityPlugin
2121
public const string PLUGIN_GUID = "io.daxcess.repoxr";
2222
public const string PLUGIN_NAME = "RepoXR";
2323
public const string PLUGIN_VERSION = "1.1.0";
24-
25-
#if DEBUG
24+
25+
#if DEBUG
2626
private const string SKIP_CHECKSUM_VAR = $"--repoxr-skip-checksum={PLUGIN_VERSION}-dev";
27-
#else
27+
#else
2828
private const string SKIP_CHECKSUM_VAR = $"--repoxr-skip-checksum={PLUGIN_VERSION}";
29-
#endif
29+
#endif
3030

31-
private const string HASHES_OVERRIDE_URL = "https://gist.githubusercontent.com/DaXcess/033e8ff514c505d2372e6f55a412dc00/raw/RepoXR%2520Game%2520Hashes";
31+
private const string HASHES_OVERRIDE_URL =
32+
"https://gist.githubusercontent.com/DaXcess/033e8ff514c505d2372e6f55a412dc00/raw/RepoXR%2520Game%2520Hashes";
3233

3334
private readonly string[] GAME_ASSEMBLY_HASHES =
3435
[
3536
"137D6E8475DEA976831CC95D7F56F4B7DA311E52A57B4C420591A5122F25589F" // v0.3.0
3637
];
37-
38+
3839
public new static Config Config { get; private set; } = null!;
3940
public static Flags Flags { get; private set; } = 0;
4041

@@ -105,14 +106,17 @@ private void Awake()
105106
}
106107
#endif
107108

109+
if (Environment.GetCommandLineArgs().Contains("--repoxr-debug-eyetracking", StringComparer.OrdinalIgnoreCase))
110+
Flags |= Flags.EyeTrackingDebug;
111+
108112
Native.BringGameWindowToFront();
109113
Config.SetupGlobalCallbacks();
110114

111115
SceneManager.sceneLoaded += (scene, _) => UniversalEntrypoint.OnSceneLoad(scene.name);
112116
}
113117

114118
public static string GetCommitHash()
115-
{
119+
{
116120
try
117121
{
118122
var attribute = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>();
@@ -131,17 +135,17 @@ private bool VerifyGameVersion()
131135
{
132136
var location = Path.Combine(Paths.ManagedPath, "Assembly-CSharp.dll");
133137
var hash = BitConverter.ToString(Utils.ComputeHash(File.ReadAllBytes(location))).Replace("-", "");
134-
138+
135139
// Attempt local lookup first
136140
if (GAME_ASSEMBLY_HASHES.Contains(hash))
137141
{
138142
Logger.LogInfo("Game version verified using local hashes");
139143

140144
return true;
141145
}
142-
146+
143147
Logger.LogWarning("Failed to verify game version using local hashes, checking remotely for updated hashes...");
144-
148+
145149
// Attempt to fetch a gist with known working assembly hashes
146150
// This allows me to keep RepoXR up and running if the game updates, without having to push an update out
147151
try
@@ -150,7 +154,7 @@ private bool VerifyGameVersion()
150154
var hashes = Utils.ParseConfig(contents);
151155

152156
var found = false;
153-
157+
154158
foreach (var versionedHash in hashes)
155159
{
156160
try
@@ -206,8 +210,9 @@ private bool PreloadRuntimeDependencies()
206210
}
207211
catch (Exception ex)
208212
{
209-
Logger.LogError($"Unexpected error occured while preloading runtime dependencies (incorrect folder structure?): {ex.Message}");
210-
213+
Logger.LogError(
214+
$"Unexpected error occured while preloading runtime dependencies (incorrect folder structure?): {ex.Message}");
215+
211216
return false;
212217
}
213218

@@ -231,7 +236,7 @@ public static void ToggleVR()
231236
Flags |= Flags.VR;
232237
}
233238
}
234-
239+
235240
private static bool InitializeVR()
236241
{
237242
RepoXR.Logger.LogInfo("Loading VR...");
@@ -245,21 +250,23 @@ private static bool InitializeVR()
245250

246251
return false;
247252
}
248-
249-
if (OpenXR.GetActiveRuntimeName(out var name) && OpenXR.GetActiveRuntimeVersion(out var major, out var minor, out var patch))
253+
254+
if (OpenXR.GetActiveRuntimeName(out var name) &&
255+
OpenXR.GetActiveRuntimeVersion(out var major, out var minor, out var patch))
250256
RepoXR.Logger.LogInfo($"OpenXR runtime being used: {name} ({major}.{minor}.{patch})");
251257
else
252258
RepoXR.Logger.LogError("Could not get OpenXR runtime info?");
253259

254260
HarmonyPatcher.PatchVR();
255-
261+
256262
RepoXR.Logger.LogDebug("Inserted VR patches using Harmony");
257-
263+
258264
// Change render pipeline settings if needed
259265
XRSettings.eyeTextureResolutionScale = Config.CameraResolution.Value / 100f;
260-
266+
261267
// Input settings
262-
InputSystem.settings.backgroundBehavior = InputSettings.BackgroundBehavior.IgnoreFocus; // Prevent VR from getting disabled when losing focus
268+
InputSystem.settings.backgroundBehavior =
269+
InputSettings.BackgroundBehavior.IgnoreFocus; // Prevent VR from getting disabled when losing focus
263270

264271
return true;
265272
}
@@ -276,5 +283,6 @@ public static MethodInfo GetConfigGetter()
276283
public enum Flags
277284
{
278285
VR = 1 << 0,
279-
StartupFailed = 1 << 1
286+
StartupFailed = 1 << 1,
287+
EyeTrackingDebug = 1 << 2
280288
}

Source/Rendering/CustomPostProcessing.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using UnityEngine;
2+
using UnityEngine.Rendering.PostProcessing;
23

34
namespace RepoXR.Rendering;
45

@@ -22,6 +23,9 @@ private void Start()
2223

2324
// Disable original shaders
2425
postProcessing.vignette.enabled.value = false;
26+
27+
// Disable ambient occlusion (big performance boost)
28+
postProcessing.GetComponent<PostProcessVolume>().profile.GetSetting<AmbientOcclusion>().enabled.value = false;
2529
}
2630

2731
private void Update()

0 commit comments

Comments
 (0)