Patch supernova method

This commit is contained in:
Noah Pilarski 2022-08-18 19:08:25 -04:00
parent 339c8e17d1
commit 41cd4743c5
2 changed files with 30 additions and 1 deletions

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Handlers namespace NewHorizons.Handlers
{ {
@ -85,6 +86,25 @@ namespace NewHorizons.Handlers
public static SunController GetSunController() => _sunController; 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;
}
} }
} }

View File

@ -1,4 +1,5 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -34,6 +35,14 @@ namespace NewHorizons.Patches
__instance._outOfRange = false; __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 // Mobius why doesn't ProxyOrbiter inherit from ProxyBody
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(ProxyOrbiter), nameof(ProxyOrbiter.Awake))] [HarmonyPatch(typeof(ProxyOrbiter), nameof(ProxyOrbiter.Awake))]