mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Address review - use _invinicible in its own file, comment orbitlines
This commit is contained in:
parent
52f164a458
commit
90cf5880ed
@ -1,21 +1,14 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Utility.OWML;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace NewHorizons.Handlers
|
||||
{
|
||||
[HarmonyPatch]
|
||||
internal class InvulnerabilityHandler
|
||||
{
|
||||
private static float _defaultImpactDeathSpeed = -1f;
|
||||
private static bool _invulnerable;
|
||||
|
||||
public static void MakeInvulnerable(bool invulnerable)
|
||||
{
|
||||
NHLogger.Log($"Toggling immortality: {invulnerable}");
|
||||
|
||||
_invulnerable = invulnerable;
|
||||
var deathManager = GetDeathManager();
|
||||
var resources = GetPlayerResouces();
|
||||
|
||||
@ -30,23 +23,7 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DeathManager), nameof(DeathManager.KillPlayer))]
|
||||
[HarmonyPatch(typeof(PlayerResources), nameof(PlayerResources.ApplyInstantDamage))]
|
||||
[HarmonyPatch(typeof(PlayerImpactAudio), nameof(PlayerImpactAudio.OnImpact))]
|
||||
public static bool DeathManager_KillPlayer_Prefix()
|
||||
{
|
||||
// Base game _invincible is still overriden by high speed impacts
|
||||
// We also are avoiding playing impact related effects by just skipping these methods
|
||||
return !_invulnerable;
|
||||
}
|
||||
|
||||
private static DeathManager GetDeathManager() => GameObject.FindObjectOfType<DeathManager>();
|
||||
private static PlayerResources GetPlayerResouces() => GameObject.FindObjectOfType<PlayerResources>();
|
||||
|
||||
static InvulnerabilityHandler()
|
||||
{
|
||||
SceneManager.sceneUnloaded += (_) => _invulnerable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,6 +514,7 @@ namespace NewHorizons.Handlers
|
||||
|
||||
if (body.Config.Orbit.showOrbitLine && !body.Config.Orbit.isStatic)
|
||||
{
|
||||
// No map mode at eye
|
||||
if (LoadManager.GetCurrentScene() != OWScene.EyeOfTheUniverse)
|
||||
{
|
||||
OrbitlineBuilder.Make(body.Object, body.Config.Orbit.isMoon, body.Config);
|
||||
@ -858,6 +859,7 @@ namespace NewHorizons.Handlers
|
||||
var isMoon = newAO.GetAstroObjectType() is AstroObject.Type.Moon or AstroObject.Type.Satellite or AstroObject.Type.SpaceStation;
|
||||
if (body.Config.Orbit.showOrbitLine)
|
||||
{
|
||||
// No map mode at eye
|
||||
if (LoadManager.GetCurrentScene() != OWScene.EyeOfTheUniverse)
|
||||
{
|
||||
OrbitlineBuilder.Make(go, isMoon, body.Config);
|
||||
|
||||
19
NewHorizons/Patches/InvincibilityPatches.cs
Normal file
19
NewHorizons/Patches/InvincibilityPatches.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using HarmonyLib;
|
||||
|
||||
namespace NewHorizons.Patches
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public static class InvincibilityPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DeathManager), nameof(DeathManager.KillPlayer))]
|
||||
[HarmonyPatch(typeof(PlayerResources), nameof(PlayerResources.ApplyInstantDamage))]
|
||||
[HarmonyPatch(typeof(PlayerImpactAudio), nameof(PlayerImpactAudio.OnImpact))]
|
||||
public static bool DeathManager_KillPlayer_Prefix()
|
||||
{
|
||||
// Base game _invincible is still overriden by high speed impacts
|
||||
// We also are avoiding playing impact related effects by just skipping these methods
|
||||
return !(Locator.GetDeathManager()?._invincible ?? false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user