mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
commit
acb235d478
@ -126,7 +126,6 @@ namespace NewHorizons.Builder.Body
|
|||||||
light.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>());
|
light.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>());
|
||||||
light.intensity *= starModule.solarLuminosity;
|
light.intensity *= starModule.solarLuminosity;
|
||||||
light.range = starModule.lightRadius;
|
light.range = starModule.lightRadius;
|
||||||
light.range *= Mathf.Sqrt(starModule.solarLuminosity);
|
|
||||||
|
|
||||||
Color lightColour = light.color;
|
Color lightColour = light.color;
|
||||||
if (starModule.lightTint != null) lightColour = starModule.lightTint.ToColor();
|
if (starModule.lightTint != null) lightColour = starModule.lightTint.ToColor();
|
||||||
|
|||||||
@ -287,6 +287,8 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
_stellarRemnant.SetActive(true);
|
_stellarRemnant.SetActive(true);
|
||||||
var remnantStarController = _stellarRemnant.GetComponentInChildren<StarController>();
|
var remnantStarController = _stellarRemnant.GetComponentInChildren<StarController>();
|
||||||
if (remnantStarController != null) StarLightController.AddStar(remnantStarController);
|
if (remnantStarController != null) StarLightController.AddStar(remnantStarController);
|
||||||
|
var remnantStarLight = _stellarRemnant.FindChild("SunLight");
|
||||||
|
if (remnantStarLight != null) StarLightController.AddStarLight(remnantStarLight.GetComponent<Light>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Time.time > _supernovaStartTime + supernovaTime)
|
if (Time.time > _supernovaStartTime + supernovaTime)
|
||||||
@ -300,6 +302,7 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
private void DisableStar(bool start = false)
|
private void DisableStar(bool start = false)
|
||||||
{
|
{
|
||||||
if (controller != null) StarLightController.RemoveStar(controller);
|
if (controller != null) StarLightController.RemoveStar(controller);
|
||||||
|
if (!isProxy) StarLightController.RemoveStarLight(gameObject.FindChild("SunLight").GetAddComponent<Light>());
|
||||||
|
|
||||||
if (_stellarRemnant != null)
|
if (_stellarRemnant != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,6 +14,7 @@ namespace NewHorizons.Components
|
|||||||
public static StarLightController Instance { get; private set; }
|
public static StarLightController Instance { get; private set; }
|
||||||
|
|
||||||
private List<StarController> _stars = new List<StarController>();
|
private List<StarController> _stars = new List<StarController>();
|
||||||
|
private List<Light> _lights = new List<Light>();
|
||||||
private StarController _activeStar;
|
private StarController _activeStar;
|
||||||
|
|
||||||
private SunLightController _sunLightController;
|
private SunLightController _sunLightController;
|
||||||
@ -53,6 +54,20 @@ namespace NewHorizons.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddStarLight(Light light)
|
||||||
|
{
|
||||||
|
if (light == null) return;
|
||||||
|
|
||||||
|
Instance._lights.Add(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveStarLight(Light light)
|
||||||
|
{
|
||||||
|
if (light == null) return;
|
||||||
|
|
||||||
|
if (Instance._lights.Contains(light)) Instance._lights.Remove(light);
|
||||||
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (_activeStar == null || !_activeStar.gameObject.activeInHierarchy)
|
if (_activeStar == null || !_activeStar.gameObject.activeInHierarchy)
|
||||||
@ -78,13 +93,14 @@ namespace NewHorizons.Components
|
|||||||
material.SetFloat(SunIntensity, intensity);
|
material.SetFloat(SunIntensity, intensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Player is always at 0,0,0 more or less so if they arent using the map camera then wtv
|
||||||
|
var origin = Vector3.zero;
|
||||||
|
|
||||||
foreach (var star in _stars)
|
foreach (var star in _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;
|
||||||
|
|
||||||
// Player is always at 0,0,0 more or less so if they arent using the map camera then wtv
|
|
||||||
var origin = Vector3.zero;
|
|
||||||
if (PlayerState.InMapView())
|
if (PlayerState.InMapView())
|
||||||
{
|
{
|
||||||
origin = Locator.GetActiveCamera().transform.position;
|
origin = Locator.GetActiveCamera().transform.position;
|
||||||
@ -96,6 +112,19 @@ namespace NewHorizons.Components
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PlayerState.InMapView())
|
||||||
|
{
|
||||||
|
foreach (var light in _lights) light.enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var light in _lights)
|
||||||
|
{
|
||||||
|
// Minimum 50km range so it's not badly noticeable for dim stars
|
||||||
|
if ((light.transform.position - origin).sqrMagnitude <= Mathf.Max(light.range * light.range, 2500000000)) light.enabled = true;
|
||||||
|
else light.enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeActiveStar(StarController star)
|
private void ChangeActiveStar(StarController star)
|
||||||
|
|||||||
@ -59,6 +59,7 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
starLightGO.AddComponent<StarLightController>();
|
starLightGO.AddComponent<StarLightController>();
|
||||||
StarLightController.AddStar(starController);
|
StarLightController.AddStar(starController);
|
||||||
|
StarLightController.AddStarLight(starController.Light);
|
||||||
|
|
||||||
starLightGO.SetActive(true);
|
starLightGO.SetActive(true);
|
||||||
|
|
||||||
@ -500,6 +501,9 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
if (starController != null) StarLightController.AddStar(starController);
|
if (starController != null) StarLightController.AddStar(starController);
|
||||||
|
|
||||||
|
var starLight = star.FindChild("SunLight");
|
||||||
|
if (starLight != null) StarLightController.AddStarLight(starLight.GetComponent<Light>());
|
||||||
|
|
||||||
// If it has an evolution controller that means it will die -> we make a remnant (unless its a remnant)
|
// If it has an evolution controller that means it will die -> we make a remnant (unless its a remnant)
|
||||||
if (starEvolutionController != null && !body.Config.isStellarRemnant)
|
if (starEvolutionController != null && !body.Config.isStellarRemnant)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -118,6 +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>();
|
||||||
StarLightController.RemoveStar(starController);
|
StarLightController.RemoveStar(starController);
|
||||||
|
StarLightController.RemoveStarLight(ao.gameObject.FindChild("Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>());
|
||||||
GameObject.Destroy(starController);
|
GameObject.Destroy(starController);
|
||||||
|
|
||||||
var audio = ao.GetComponentInChildren<SunSurfaceAudioController>();
|
var audio = ao.GetComponentInChildren<SunSurfaceAudioController>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user