mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Bring back patch to impact audio
This commit is contained in:
parent
d5d9200331
commit
8a1fa3de97
@ -1,4 +1,3 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Utility.OWML;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
@ -7,10 +6,16 @@ namespace NewHorizons.Handlers
|
||||
{
|
||||
internal class InvulnerabilityHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Used in patches
|
||||
/// </summary>
|
||||
public static bool Invincible { get; private set; }
|
||||
|
||||
public static void MakeInvulnerable(bool invulnerable)
|
||||
{
|
||||
NHLogger.Log($"Toggling immortality: {invulnerable}");
|
||||
|
||||
Invincible = invulnerable;
|
||||
var deathManager = GetDeathManager();
|
||||
var resources = GetPlayerResouces();
|
||||
|
||||
@ -29,5 +34,11 @@ namespace NewHorizons.Handlers
|
||||
|
||||
private static DeathManager GetDeathManager() => GameObject.FindObjectOfType<DeathManager>();
|
||||
private static PlayerResources GetPlayerResouces() => GameObject.FindObjectOfType<PlayerResources>();
|
||||
|
||||
static InvulnerabilityHandler()
|
||||
{
|
||||
// If the scene unloads when Invincible is on it might not get turned off
|
||||
SceneManager.sceneUnloaded += (_) => Invincible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
NewHorizons/Patches/PlayerImpactAudioPatches.cs
Normal file
21
NewHorizons/Patches/PlayerImpactAudioPatches.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Handlers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.Patches;
|
||||
|
||||
[HarmonyPatch]
|
||||
public static class PlayerImpactAudioPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerImpactAudio), nameof(PlayerImpactAudio.OnImpact))]
|
||||
public static bool PlayerImpactAudio_OnImpact()
|
||||
{
|
||||
// DeathManager and PlayerResources _invincible stops player dying but you still hear the impact sounds which is annoying so we disable them
|
||||
return !InvulnerabilityHandler.Invincible;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user