mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix star size in SunLightParamUpdater
This commit is contained in:
parent
41121fdc26
commit
b3327f7ae6
@ -454,6 +454,8 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
|
|
||||||
public float GetSupernovaRadius() => supernova.GetSupernovaRadius();
|
public float GetSupernovaRadius() => supernova.GetSupernovaRadius();
|
||||||
|
|
||||||
|
public float GetSurfaceRadius() => transform.localScale.x;
|
||||||
|
|
||||||
public float GetMaxSupernovaRadius() => supernovaSize;
|
public float GetMaxSupernovaRadius() => supernovaSize;
|
||||||
|
|
||||||
protected new void FixedUpdate()
|
protected new void FixedUpdate()
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using NewHorizons.Builder.Atmosphere;
|
using NewHorizons.Builder.Atmosphere;
|
||||||
|
using NewHorizons.Components.SizeControllers;
|
||||||
using NewHorizons.Utility.OWML;
|
using NewHorizons.Utility.OWML;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -17,7 +18,11 @@ namespace NewHorizons.Components.Stars
|
|||||||
private readonly List<StarController> _stars = new();
|
private readonly List<StarController> _stars = new();
|
||||||
private readonly List<Light> _lights = new();
|
private readonly List<Light> _lights = new();
|
||||||
|
|
||||||
private StarController _activeStar;
|
// SunController or StarEvolutionController
|
||||||
|
public StarEvolutionController ActiveStarEvolutionController { get; private set; }
|
||||||
|
public SunController ActiveSunController { get; private set; }
|
||||||
|
|
||||||
|
private StarController _activeStarController;
|
||||||
private SunLightController _sunLightController;
|
private SunLightController _sunLightController;
|
||||||
private SunLightParamUpdater _sunLightParamUpdater;
|
private SunLightParamUpdater _sunLightParamUpdater;
|
||||||
|
|
||||||
@ -54,7 +59,7 @@ namespace NewHorizons.Components.Stars
|
|||||||
NHLogger.LogVerbose($"Removing star from list: {star?.gameObject?.name}");
|
NHLogger.LogVerbose($"Removing star from list: {star?.gameObject?.name}");
|
||||||
if (Instance._stars.Contains(star))
|
if (Instance._stars.Contains(star))
|
||||||
{
|
{
|
||||||
if (Instance._activeStar != null && Instance._activeStar.Equals(star))
|
if (Instance._activeStarController != null && Instance._activeStarController.Equals(star))
|
||||||
{
|
{
|
||||||
Instance._stars.Remove(star);
|
Instance._stars.Remove(star);
|
||||||
if (Instance._stars.Count > 0) Instance.ChangeActiveStar(Instance._stars[0]);
|
if (Instance._stars.Count > 0) Instance.ChangeActiveStar(Instance._stars[0]);
|
||||||
@ -121,11 +126,11 @@ namespace NewHorizons.Components.Stars
|
|||||||
|
|
||||||
if (_stars.Count > 0)
|
if (_stars.Count > 0)
|
||||||
{
|
{
|
||||||
if (_activeStar == null || !_activeStar.gameObject.activeInHierarchy)
|
if (_activeStarController == null || !_activeStarController.gameObject.activeInHierarchy)
|
||||||
{
|
{
|
||||||
if (_stars.Contains(_activeStar))
|
if (_stars.Contains(_activeStarController))
|
||||||
{
|
{
|
||||||
_stars.Remove(_activeStar);
|
_stars.Remove(_activeStarController);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_stars.Count > 0)
|
if (_stars.Count > 0)
|
||||||
@ -145,8 +150,8 @@ namespace NewHorizons.Components.Stars
|
|||||||
// Update atmo shaders
|
// Update atmo shaders
|
||||||
foreach (var (planet, material) in AtmosphereBuilder.Skys)
|
foreach (var (planet, material) in AtmosphereBuilder.Skys)
|
||||||
{
|
{
|
||||||
var sqrDist = (planet.transform.position - _activeStar.transform.position).sqrMagnitude;
|
var sqrDist = (planet.transform.position - _activeStarController.transform.position).sqrMagnitude;
|
||||||
var intensity = Mathf.Min(_activeStar.Intensity / (sqrDist / hearthSunDistanceSqr), 1f);
|
var intensity = Mathf.Min(_activeStarController.Intensity / (sqrDist / hearthSunDistanceSqr), 1f);
|
||||||
|
|
||||||
material.SetFloat(SunIntensity, intensity);
|
material.SetFloat(SunIntensity, intensity);
|
||||||
}
|
}
|
||||||
@ -156,7 +161,7 @@ namespace NewHorizons.Components.Stars
|
|||||||
if (star == null) continue;
|
if (star == null) continue;
|
||||||
if (!(star.gameObject.activeSelf && star.gameObject.activeInHierarchy)) continue;
|
if (!(star.gameObject.activeSelf && star.gameObject.activeInHierarchy)) continue;
|
||||||
|
|
||||||
if (star.Intensity * (star.transform.position - origin).sqrMagnitude < _activeStar.Intensity * (_activeStar.transform.position - origin).sqrMagnitude)
|
if (star.Intensity * (star.transform.position - origin).sqrMagnitude < _activeStarController.Intensity * (_activeStarController.transform.position - origin).sqrMagnitude)
|
||||||
{
|
{
|
||||||
ChangeActiveStar(star);
|
ChangeActiveStar(star);
|
||||||
break;
|
break;
|
||||||
@ -170,11 +175,13 @@ namespace NewHorizons.Components.Stars
|
|||||||
{
|
{
|
||||||
if (_sunLightController == null || _sunLightParamUpdater == null) return;
|
if (_sunLightController == null || _sunLightParamUpdater == null) return;
|
||||||
|
|
||||||
if (_activeStar != null) _activeStar.Disable();
|
_activeStarController?.Disable();
|
||||||
|
|
||||||
NHLogger.LogVerbose($"Switching active star: {star.gameObject.name}");
|
NHLogger.LogVerbose($"Switching active star: {star.gameObject.name}");
|
||||||
|
|
||||||
_activeStar = star;
|
_activeStarController = star;
|
||||||
|
ActiveStarEvolutionController = star.GetComponentInChildren<StarEvolutionController>();
|
||||||
|
ActiveSunController = star.GetComponent<SunController>();
|
||||||
|
|
||||||
star.Enable();
|
star.Enable();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using NewHorizons.Components.Stars;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
namespace NewHorizons.Patches.SunPatches
|
namespace NewHorizons.Patches.SunPatches
|
||||||
{
|
{
|
||||||
@ -13,10 +14,20 @@ namespace NewHorizons.Patches.SunPatches
|
|||||||
{
|
{
|
||||||
Vector3 position = __instance.transform.position;
|
Vector3 position = __instance.transform.position;
|
||||||
float w = 2000f;
|
float w = 2000f;
|
||||||
if (__instance._sunController != null)
|
|
||||||
|
var sunController = SunLightEffectsController.Instance.ActiveSunController;
|
||||||
|
var starEvolutionController = SunLightEffectsController.Instance.ActiveStarEvolutionController;
|
||||||
|
|
||||||
|
if (sunController != null)
|
||||||
{
|
{
|
||||||
w = __instance._sunController.HasSupernovaStarted() ? __instance._sunController.GetSupernovaRadius() : __instance._sunController.GetSurfaceRadius();
|
w = sunController.HasSupernovaStarted() ? sunController.GetSupernovaRadius() : sunController.GetSurfaceRadius();
|
||||||
}
|
}
|
||||||
|
// This is an addition in this patch, to work with our stars
|
||||||
|
else if (starEvolutionController != null)
|
||||||
|
{
|
||||||
|
w = starEvolutionController.HasSupernovaStarted() ? starEvolutionController.GetSupernovaRadius() : starEvolutionController.GetSurfaceRadius();
|
||||||
|
}
|
||||||
|
|
||||||
float range = __instance.sunLight.range;
|
float range = __instance.sunLight.range;
|
||||||
Color color = __instance._sunLightController != null ? __instance._sunLightController.sunColor : __instance.sunLight.color;
|
Color color = __instance._sunLightController != null ? __instance._sunLightController.sunColor : __instance.sunLight.color;
|
||||||
float w2 = __instance._sunLightController != null ? __instance._sunLightController.sunIntensity : __instance.sunLight.intensity;
|
float w2 = __instance._sunLightController != null ? __instance._sunLightController.sunIntensity : __instance.sunLight.intensity;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user