Renamed it and fixed it for the sun

This commit is contained in:
Nick 2022-09-15 00:57:10 -04:00
parent 5a5ea46b05
commit b1eac0748e
4 changed files with 19 additions and 8 deletions

View File

@ -303,7 +303,7 @@ namespace NewHorizons.Components.SizeControllers
private void DisableStar(bool start = false) private void DisableStar(bool start = false)
{ {
if (controller != null) SunLightEffectsController.RemoveStar(controller); if (controller != null) SunLightEffectsController.RemoveStar(controller);
if (!isProxy) SunLightEffectsController.RemoveStarLight(gameObject.FindChild("SunLight").GetAddComponent<Light>()); if (!isProxy) SunLightEffectsController.RemoveStarLight(gameObject.FindChild("SunLight").GetComponent<Light>());
if (_stellarRemnant != null) if (_stellarRemnant != null)
{ {

View File

@ -1,4 +1,5 @@
using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Atmosphere;
using NewHorizons.Utility;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
@ -31,6 +32,13 @@ namespace NewHorizons.Components.Stars
_sunLightParamUpdater._sunLightController = _sunLightController; _sunLightParamUpdater._sunLightController = _sunLightController;
} }
public void Start()
{
// Using GameObject.Find here so that if its null we just dont find it
var sunlight = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>();
if (sunlight != null) AddStarLight(sunlight);
}
public static void AddStar(StarController star) public static void AddStar(StarController star)
{ {
if (star == null) return; if (star == null) return;
@ -58,16 +66,18 @@ namespace NewHorizons.Components.Stars
public static void AddStarLight(Light light) public static void AddStarLight(Light light)
{ {
if (light == null) return; if (light != null)
{
Instance._lights.Add(light); Instance._lights.SafeAdd(light);
}
} }
public static void RemoveStarLight(Light light) public static void RemoveStarLight(Light light)
{ {
if (light == null) return; if (light != null && Instance._lights.Contains(light))
{
if (Instance._lights.Contains(light)) Instance._lights.Remove(light); Instance._lights.Remove(light);
}
} }
public void Update() public void Update()

View File

@ -118,7 +118,7 @@ namespace NewHorizons.Handlers
case AstroObject.Name.Sun: case AstroObject.Name.Sun:
var starController = ao.gameObject.GetComponent<StarController>(); var starController = ao.gameObject.GetComponent<StarController>();
SunLightEffectsController.RemoveStar(starController); SunLightEffectsController.RemoveStar(starController);
SunLightEffectsController.RemoveStarLight(ao.gameObject.FindChild("Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>()); SunLightEffectsController.RemoveStarLight(ao.transform.Find("Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>());
GameObject.Destroy(starController); GameObject.Destroy(starController);
var audio = ao.GetComponentInChildren<SunSurfaceAudioController>(); var audio = ao.GetComponentInChildren<SunSurfaceAudioController>();

View File

@ -354,6 +354,7 @@ namespace NewHorizons
var map = GameObject.FindObjectOfType<MapController>(); var map = GameObject.FindObjectOfType<MapController>();
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f; if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
// Fix the map satellite // Fix the map satellite
SearchUtilities.Find("HearthianMapSatellite_Body", false).AddComponent<MapSatelliteOrbitFix>(); SearchUtilities.Find("HearthianMapSatellite_Body", false).AddComponent<MapSatelliteOrbitFix>();