mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Patch supernova method
This commit is contained in:
parent
339c8e17d1
commit
41cd4743c5
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Handlers
|
||||
{
|
||||
@ -85,6 +86,25 @@ namespace NewHorizons.Handlers
|
||||
|
||||
public static SunController GetSunController() => _sunController;
|
||||
|
||||
public static bool InPointInsideSunSupernova(NHSupernovaPlanetEffectController supernovaPlanetEffectController) => _sunController != null && (supernovaPlanetEffectController.transform.position - _sunController.transform.position).sqrMagnitude < 2500000000f;//(50000f*50000f);
|
||||
public static bool InPointInsideAnySupernova(Vector3 position)
|
||||
{
|
||||
foreach (StarEvolutionController starEvolutionController in _starEvolutionControllers)
|
||||
{
|
||||
if (starEvolutionController == null) continue;
|
||||
if (!(starEvolutionController.gameObject.activeSelf && starEvolutionController.gameObject.activeInHierarchy)) continue;
|
||||
float distance = (position - starEvolutionController.transform.position).sqrMagnitude;
|
||||
float size = starEvolutionController.GetSupernovaRadius();
|
||||
if (distance < (size * size)) return true;
|
||||
}
|
||||
|
||||
if (_sunController != null && _sunController.gameObject.activeSelf)
|
||||
{
|
||||
float distance = (position - _sunController.transform.position).sqrMagnitude;
|
||||
float size = _sunController.GetSupernovaRadius();
|
||||
if (distance < (size * size)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
@ -34,6 +35,14 @@ namespace NewHorizons.Patches
|
||||
__instance._outOfRange = false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyBody), nameof(ProxyBody.IsObjectInSupernova))]
|
||||
public static bool ProxyBody_IsObjectInSupernova(ProxyBody __instance, ref bool __result)
|
||||
{
|
||||
__result = SupernovaEffectHandler.InPointInsideAnySupernova(__instance._realObjectTransform.position);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mobius why doesn't ProxyOrbiter inherit from ProxyBody
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProxyOrbiter), nameof(ProxyOrbiter.Awake))]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user