mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Refactor (description)
Refactor proxies, fix named, create proxy remnants, don't let focal points be destroyed by stars
This commit is contained in:
parent
bd405f92dc
commit
5fe7630f48
@ -8,6 +8,7 @@ using UnityEngine;
|
|||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
using NewHorizons.External.Modules.VariableSize;
|
using NewHorizons.External.Modules.VariableSize;
|
||||||
using NewHorizons.Handlers;
|
using NewHorizons.Handlers;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Body
|
namespace NewHorizons.Builder.Body
|
||||||
{
|
{
|
||||||
@ -15,40 +16,60 @@ namespace NewHorizons.Builder.Body
|
|||||||
{
|
{
|
||||||
private static Material lavaMaterial;
|
private static Material lavaMaterial;
|
||||||
|
|
||||||
private static GameObject _blackHolePrefab;
|
|
||||||
private static GameObject _whiteHolePrefab;
|
|
||||||
|
|
||||||
private static readonly string _blackHolePath = "TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_TT/Prefab_NOM_WarpTransmitter (1)/BlackHole/BlackHoleSingularity";
|
|
||||||
private static readonly string _whiteHolePath = "TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_CT/Prefab_NOM_WarpTransmitter/WhiteHole/WhiteHoleSingularity";
|
|
||||||
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
|
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
|
||||||
private static readonly int Radius = Shader.PropertyToID("_Radius");
|
|
||||||
private static readonly int MaxDistortRadius = Shader.PropertyToID("_MaxDistortRadius");
|
|
||||||
private static readonly int MassScale = Shader.PropertyToID("_MassScale");
|
|
||||||
private static readonly int DistortFadeDist = Shader.PropertyToID("_DistortFadeDist");
|
|
||||||
private static readonly int Color1 = Shader.PropertyToID("_Color");
|
|
||||||
|
|
||||||
|
public static void Make(GameObject planetGO, NewHorizonsBody body, NewHorizonsBody remnant)
|
||||||
public static void Make(GameObject planetGO, NewHorizonsBody body)
|
|
||||||
{
|
{
|
||||||
if (lavaMaterial == null) lavaMaterial = SearchUtilities.FindObjectOfTypeAndName<ProxyOrbiter>("VolcanicMoon_Body").transform.Find("LavaSphere").GetComponent<MeshRenderer>().material;
|
if (lavaMaterial == null) lavaMaterial = SearchUtilities.FindObjectOfTypeAndName<ProxyOrbiter>("VolcanicMoon_Body").transform.Find("LavaSphere").GetComponent<MeshRenderer>().material;
|
||||||
|
|
||||||
var proxyController = ProxyHandler.GetProxy(body.Config.name);
|
var proxyController = ProxyHandler.GetProxy(body.Config.name);
|
||||||
var proxy = proxyController != null ? proxyController.gameObject : new GameObject($"{body.Config.name}_Proxy");
|
var proxy = proxyController != null ? proxyController.gameObject : new GameObject($"{body.Config.name}_Proxy");
|
||||||
|
|
||||||
proxy.SetActive(false);
|
proxy.SetActive(false);
|
||||||
if (proxyController == null)
|
if (proxyController == null)
|
||||||
{
|
{
|
||||||
proxyController = proxy.AddComponent<NHProxy>();
|
proxyController = proxy.AddComponent<NHProxy>();
|
||||||
proxyController.astroName = body.Config.name;
|
proxyController.astroName = body.Config.name;
|
||||||
proxyController._planet = planetGO;
|
proxyController.planet = planetGO;
|
||||||
}
|
}
|
||||||
|
|
||||||
var success = SharedMake(planetGO, proxy, proxyController, body);
|
var rootProxy = new GameObject("Root");
|
||||||
|
rootProxy.transform.parent = proxy.transform;
|
||||||
|
rootProxy.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
var success = SharedMake(planetGO, rootProxy, proxyController, body);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
GameObject.Destroy(proxy);
|
GameObject.Destroy(proxy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proxyController.root = rootProxy;
|
||||||
|
|
||||||
|
// Add remnants
|
||||||
|
if (remnant != null)
|
||||||
|
{
|
||||||
|
var remnantGO = new GameObject("Remnant");
|
||||||
|
remnantGO.transform.parent = proxy.transform;
|
||||||
|
remnantGO.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
SharedMake(planetGO, remnantGO, proxyController, remnant);
|
||||||
|
|
||||||
|
proxyController.stellarRemnantGO = remnantGO;
|
||||||
|
}
|
||||||
|
else if (body.Config.Star != null)
|
||||||
|
{
|
||||||
|
Logger.LogVerbose($"Making remnant proxy");
|
||||||
|
|
||||||
|
var remnantGO = new GameObject("Remnant");
|
||||||
|
remnantGO.transform.parent = proxy.transform;
|
||||||
|
remnantGO.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
StellarRemnantBuilder.MakeProxyRemnant(planetGO, remnantGO, body.Mod, body.Config.Star);
|
||||||
|
|
||||||
|
proxyController.stellarRemnantGO = remnantGO;
|
||||||
|
}
|
||||||
|
|
||||||
proxy.SetActive(true);
|
proxy.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +97,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
float fogCurveMaxVal = 0;
|
float fogCurveMaxVal = 0;
|
||||||
Renderer topClouds = null;
|
Renderer topClouds = null;
|
||||||
CloudLightningGenerator lightningGenerator = null;
|
CloudLightningGenerator lightningGenerator = null;
|
||||||
|
|
||||||
if (body.Config.Atmosphere != null)
|
if (body.Config.Atmosphere != null)
|
||||||
{
|
{
|
||||||
atmosphere = AtmosphereBuilder.Make(proxy, null, body.Config.Atmosphere, body.Config.Base.surfaceSize, true).GetComponentInChildren<MeshRenderer>();
|
atmosphere = AtmosphereBuilder.Make(proxy, null, body.Config.Atmosphere, body.Config.Base.surfaceSize, true).GetComponentInChildren<MeshRenderer>();
|
||||||
@ -147,11 +169,11 @@ namespace NewHorizons.Builder.Body
|
|||||||
{
|
{
|
||||||
if (singularity.type == SingularityModule.SingularityType.BlackHole)
|
if (singularity.type == SingularityModule.SingularityType.BlackHole)
|
||||||
{
|
{
|
||||||
MakeBlackHole(proxy, singularity.position, singularity.size, singularity.curve);
|
SingularityBuilder.MakeBlackHoleProxy(proxy, singularity.position, singularity.size, singularity.curve);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MakeWhiteHole(proxy, singularity.position, singularity.size, singularity.curve);
|
SingularityBuilder.MakeWhiteHoleProxy(proxy, singularity.position, singularity.size, singularity.curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realSize < singularity.size) realSize = singularity.size;
|
if (realSize < singularity.size) realSize = singularity.size;
|
||||||
@ -199,11 +221,11 @@ namespace NewHorizons.Builder.Body
|
|||||||
proxyController._atmosphere = atmosphere;
|
proxyController._atmosphere = atmosphere;
|
||||||
proxyController._fog = fog;
|
proxyController._fog = fog;
|
||||||
proxyController._fogCurveMaxVal = fogCurveMaxVal;
|
proxyController._fogCurveMaxVal = fogCurveMaxVal;
|
||||||
proxyController._topClouds = topClouds;
|
proxyController.topClouds = topClouds;
|
||||||
proxyController._lightningGenerator = lightningGenerator;
|
proxyController.lightningGenerator = lightningGenerator;
|
||||||
proxyController._supernovaPlanetEffectController = supernovaPlanetEffect;
|
proxyController.supernovaPlanetEffectController = supernovaPlanetEffect;
|
||||||
proxyController._realObjectDiameter = realSize;
|
proxyController._realObjectDiameter = realSize;
|
||||||
proxyController._baseRealObjectDiameter = realSize;
|
proxyController.baseRealObjectDiameter = realSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -240,63 +262,5 @@ namespace NewHorizons.Builder.Body
|
|||||||
sizeController.size = size;
|
sizeController.size = size;
|
||||||
return sizeController;
|
return sizeController;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GameObject MakeBlackHole(GameObject rootObject, MVector3 position, float size, VariableSizeModule.TimeValuePair[] curve = null)
|
|
||||||
{
|
|
||||||
if (_blackHolePrefab == null) _blackHolePrefab = SearchUtilities.Find(_blackHolePath);
|
|
||||||
|
|
||||||
var blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().material.shader;
|
|
||||||
if (blackHoleShader == null) blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;
|
|
||||||
|
|
||||||
var blackHoleRender = new GameObject("BlackHoleRender");
|
|
||||||
blackHoleRender.transform.parent = rootObject.transform;
|
|
||||||
if (position != null) blackHoleRender.transform.localPosition = position;
|
|
||||||
else blackHoleRender.transform.localPosition = Vector3.zero;
|
|
||||||
blackHoleRender.transform.localScale = Vector3.one * size;
|
|
||||||
|
|
||||||
var meshFilter = blackHoleRender.AddComponent<MeshFilter>();
|
|
||||||
meshFilter.mesh = _blackHolePrefab.GetComponent<MeshFilter>().mesh;
|
|
||||||
|
|
||||||
var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>();
|
|
||||||
meshRenderer.material = new Material(blackHoleShader);
|
|
||||||
meshRenderer.material.SetFloat(Radius, size * 0.4f);
|
|
||||||
meshRenderer.material.SetFloat(MaxDistortRadius, size * 0.95f);
|
|
||||||
meshRenderer.material.SetFloat(MassScale, 1);
|
|
||||||
meshRenderer.material.SetFloat(DistortFadeDist, size * 0.55f);
|
|
||||||
|
|
||||||
if (curve != null) AddSizeController(blackHoleRender, curve, size);
|
|
||||||
|
|
||||||
blackHoleRender.SetActive(true);
|
|
||||||
return blackHoleRender;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GameObject MakeWhiteHole(GameObject rootObject, MVector3 position, float size, VariableSizeModule.TimeValuePair[] curve = null)
|
|
||||||
{
|
|
||||||
if (_whiteHolePrefab == null) _whiteHolePrefab = SearchUtilities.Find(_whiteHolePath);
|
|
||||||
|
|
||||||
var whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().material.shader;
|
|
||||||
if (whiteHoleShader == null) whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;
|
|
||||||
|
|
||||||
var whiteHoleRenderer = new GameObject("WhiteHoleRenderer");
|
|
||||||
whiteHoleRenderer.transform.parent = rootObject.transform;
|
|
||||||
if (position != null) whiteHoleRenderer.transform.localPosition = position;
|
|
||||||
else whiteHoleRenderer.transform.localPosition = Vector3.zero;
|
|
||||||
whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f;
|
|
||||||
|
|
||||||
var meshFilter = whiteHoleRenderer.AddComponent<MeshFilter>();
|
|
||||||
meshFilter.mesh = _whiteHolePrefab.GetComponent<MeshFilter>().mesh;
|
|
||||||
|
|
||||||
var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>();
|
|
||||||
meshRenderer.material = new Material(whiteHoleShader);
|
|
||||||
meshRenderer.sharedMaterial.SetFloat(Radius, size * 0.4f);
|
|
||||||
meshRenderer.sharedMaterial.SetFloat(DistortFadeDist, size);
|
|
||||||
meshRenderer.sharedMaterial.SetFloat(MaxDistortRadius, size * 2.8f);
|
|
||||||
meshRenderer.sharedMaterial.SetColor(Color1, new Color(1.88f, 1.88f, 1.88f, 1f));
|
|
||||||
|
|
||||||
if (curve != null) AddSizeController(whiteHoleRenderer, curve, size);
|
|
||||||
|
|
||||||
whiteHoleRenderer.SetActive(true);
|
|
||||||
return whiteHoleRenderer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,6 +15,9 @@ namespace NewHorizons.Builder.Body
|
|||||||
{
|
{
|
||||||
public static class SingularityBuilder
|
public static class SingularityBuilder
|
||||||
{
|
{
|
||||||
|
private static readonly string _blackHoleProxyPath = "TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_TT/Prefab_NOM_WarpTransmitter (1)/BlackHole/BlackHoleSingularity";
|
||||||
|
private static readonly string _whiteHoleProxyPath = "TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_CT/Prefab_NOM_WarpTransmitter/WhiteHole/WhiteHoleSingularity";
|
||||||
|
private static GameObject _blackHoleProxyPrefab, _whiteHoleProxyPrefab;
|
||||||
|
|
||||||
private static Shader blackHoleShader = null;
|
private static Shader blackHoleShader = null;
|
||||||
private static Shader whiteHoleShader = null;
|
private static Shader whiteHoleShader = null;
|
||||||
@ -283,5 +286,71 @@ namespace NewHorizons.Builder.Body
|
|||||||
whiteHole.SetActive(true);
|
whiteHole.SetActive(true);
|
||||||
return whiteHole;
|
return whiteHole;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GameObject MakeBlackHoleProxy(GameObject rootObject, MVector3 position, float size, VariableSizeModule.TimeValuePair[] curve = null)
|
||||||
|
{
|
||||||
|
if (_blackHoleProxyPrefab == null) _blackHoleProxyPrefab = SearchUtilities.Find(_blackHoleProxyPath);
|
||||||
|
|
||||||
|
var blackHoleShader = _blackHoleProxyPrefab.GetComponent<MeshRenderer>().material.shader;
|
||||||
|
if (blackHoleShader == null) blackHoleShader = _blackHoleProxyPrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;
|
||||||
|
|
||||||
|
var blackHoleRender = new GameObject("BlackHoleRender");
|
||||||
|
blackHoleRender.transform.parent = rootObject.transform;
|
||||||
|
if (position != null) blackHoleRender.transform.localPosition = position;
|
||||||
|
else blackHoleRender.transform.localPosition = Vector3.zero;
|
||||||
|
blackHoleRender.transform.localScale = Vector3.one * size;
|
||||||
|
|
||||||
|
var meshFilter = blackHoleRender.AddComponent<MeshFilter>();
|
||||||
|
meshFilter.mesh = _blackHoleProxyPrefab.GetComponent<MeshFilter>().mesh;
|
||||||
|
|
||||||
|
var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>();
|
||||||
|
meshRenderer.material = new Material(blackHoleShader);
|
||||||
|
meshRenderer.material.SetFloat(Radius, size * 0.4f);
|
||||||
|
meshRenderer.material.SetFloat(MaxDistortRadius, size * 0.95f);
|
||||||
|
meshRenderer.material.SetFloat(MassScale, 1);
|
||||||
|
meshRenderer.material.SetFloat(DistortFadeDist, size * 0.55f);
|
||||||
|
|
||||||
|
if (curve != null) AddSizeController(blackHoleRender, curve, size);
|
||||||
|
|
||||||
|
blackHoleRender.SetActive(true);
|
||||||
|
return blackHoleRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameObject MakeWhiteHoleProxy(GameObject rootObject, MVector3 position, float size, VariableSizeModule.TimeValuePair[] curve = null)
|
||||||
|
{
|
||||||
|
if (_whiteHoleProxyPrefab == null) _whiteHoleProxyPrefab = SearchUtilities.Find(_whiteHoleProxyPath);
|
||||||
|
|
||||||
|
var whiteHoleShader = _whiteHoleProxyPrefab.GetComponent<MeshRenderer>().material.shader;
|
||||||
|
if (whiteHoleShader == null) whiteHoleShader = _whiteHoleProxyPrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;
|
||||||
|
|
||||||
|
var whiteHoleRenderer = new GameObject("WhiteHoleRenderer");
|
||||||
|
whiteHoleRenderer.transform.parent = rootObject.transform;
|
||||||
|
if (position != null) whiteHoleRenderer.transform.localPosition = position;
|
||||||
|
else whiteHoleRenderer.transform.localPosition = Vector3.zero;
|
||||||
|
whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f;
|
||||||
|
|
||||||
|
var meshFilter = whiteHoleRenderer.AddComponent<MeshFilter>();
|
||||||
|
meshFilter.mesh = _whiteHoleProxyPrefab.GetComponent<MeshFilter>().mesh;
|
||||||
|
|
||||||
|
var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>();
|
||||||
|
meshRenderer.material = new Material(whiteHoleShader);
|
||||||
|
meshRenderer.sharedMaterial.SetFloat(Radius, size * 0.4f);
|
||||||
|
meshRenderer.sharedMaterial.SetFloat(DistortFadeDist, size);
|
||||||
|
meshRenderer.sharedMaterial.SetFloat(MaxDistortRadius, size * 2.8f);
|
||||||
|
meshRenderer.sharedMaterial.SetColor(Color1, new Color(1.88f, 1.88f, 1.88f, 1f));
|
||||||
|
|
||||||
|
if (curve != null) AddSizeController(whiteHoleRenderer, curve, size);
|
||||||
|
|
||||||
|
whiteHoleRenderer.SetActive(true);
|
||||||
|
return whiteHoleRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SizeController AddSizeController(GameObject go, VariableSizeModule.TimeValuePair[] curve, float size)
|
||||||
|
{
|
||||||
|
var sizeController = go.AddComponent<SizeController>();
|
||||||
|
sizeController.SetScaleCurve(curve);
|
||||||
|
sizeController.size = size;
|
||||||
|
return sizeController;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -167,10 +167,10 @@ namespace NewHorizons.Builder.Body
|
|||||||
starEvolutionController.atmosphere = sunAtmosphere;
|
starEvolutionController.atmosphere = sunAtmosphere;
|
||||||
starEvolutionController.controller = starController;
|
starEvolutionController.controller = starController;
|
||||||
starEvolutionController.supernova = supernova;
|
starEvolutionController.supernova = supernova;
|
||||||
starEvolutionController.StartColour = starModule.tint;
|
starEvolutionController.startColour = starModule.tint;
|
||||||
starEvolutionController.EndColour = starModule.endTint;
|
starEvolutionController.endColour = starModule.endTint;
|
||||||
starEvolutionController.SupernovaColour = starModule.supernovaTint;
|
starEvolutionController.supernovaColour = starModule.supernovaTint;
|
||||||
starEvolutionController.WillExplode = starModule.stellarDeathType != StellarDeathType.None;
|
starEvolutionController.willExplode = starModule.stellarDeathType != StellarDeathType.None;
|
||||||
starEvolutionController.lifespan = starModule.lifespan;
|
starEvolutionController.lifespan = starModule.lifespan;
|
||||||
starEvolutionController.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
|
starEvolutionController.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
|
||||||
starEvolutionController.heatVolume = heatVolume.GetComponent<HeatHazardVolume>();
|
starEvolutionController.heatVolume = heatVolume.GetComponent<HeatHazardVolume>();
|
||||||
@ -211,7 +211,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
starGO.SetActive(false);
|
starGO.SetActive(false);
|
||||||
var controller = starGO.AddComponent<StarEvolutionController>();
|
var controller = starGO.AddComponent<StarEvolutionController>();
|
||||||
controller._isProxy = true;
|
controller.isProxy = true;
|
||||||
if (starModule.curve != null) controller.SetScaleCurve(starModule.curve);
|
if (starModule.curve != null) controller.SetScaleCurve(starModule.curve);
|
||||||
controller.size = starModule.size;
|
controller.size = starModule.size;
|
||||||
controller.supernovaSize = starModule.supernovaSize;
|
controller.supernovaSize = starModule.supernovaSize;
|
||||||
@ -221,10 +221,10 @@ namespace NewHorizons.Builder.Body
|
|||||||
controller.supernovaScaleStart = duration * 0.9f;
|
controller.supernovaScaleStart = duration * 0.9f;
|
||||||
controller.deathType = starModule.stellarDeathType;
|
controller.deathType = starModule.stellarDeathType;
|
||||||
controller.supernova = supernova;
|
controller.supernova = supernova;
|
||||||
controller.StartColour = starModule.tint;
|
controller.startColour = starModule.tint;
|
||||||
controller.EndColour = starModule.endTint;
|
controller.endColour = starModule.endTint;
|
||||||
controller.SupernovaColour = starModule.supernovaTint;
|
controller.supernovaColour = starModule.supernovaTint;
|
||||||
controller.WillExplode = starModule.stellarDeathType != StellarDeathType.None;
|
controller.willExplode = starModule.stellarDeathType != StellarDeathType.None;
|
||||||
controller.lifespan = starModule.lifespan;
|
controller.lifespan = starModule.lifespan;
|
||||||
controller.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
|
controller.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
|
||||||
if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture))
|
if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture))
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using Epic.OnlineServices.Stats;
|
||||||
using NewHorizons.Builder.General;
|
using NewHorizons.Builder.General;
|
||||||
using NewHorizons.Components;
|
using NewHorizons.Components;
|
||||||
using NewHorizons.Components.SizeControllers;
|
using NewHorizons.Components.SizeControllers;
|
||||||
@ -26,28 +27,12 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
var remnantType = star.Config.Star.stellarRemnantType;
|
var remnantType = star.Config.Star.stellarRemnantType;
|
||||||
|
|
||||||
var progenitorSize = star.Config.Star.size;
|
if (remnantType == StellarRemnantType.Default) remnantType = GetDefault(star.Config.Star.size);
|
||||||
|
|
||||||
if (remnantType == StellarRemnantType.Default)
|
|
||||||
{
|
|
||||||
if (progenitorSize >= 4000) remnantType = StellarRemnantType.BlackHole;
|
|
||||||
else if (2000 < progenitorSize && progenitorSize < 4000) remnantType = StellarRemnantType.NeutronStar;
|
|
||||||
else remnantType = StellarRemnantType.WhiteDwarf;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (remnantType)
|
switch (remnantType)
|
||||||
{
|
{
|
||||||
case StellarRemnantType.WhiteDwarf:
|
case StellarRemnantType.WhiteDwarf:
|
||||||
var whiteDwarfSize = progenitorSize / 10;
|
MakeWhiteDwarf(go, sector, mod, star.Config.Star);
|
||||||
var wdModule = new StarModule
|
|
||||||
{
|
|
||||||
size = whiteDwarfSize,
|
|
||||||
tint = new MColor(384, 384, 384, 255),
|
|
||||||
lightTint = MColor.white,
|
|
||||||
lightRadius = 10000,
|
|
||||||
solarLuminosity = 0.5f
|
|
||||||
};
|
|
||||||
StarBuilder.Make(go, sector, wdModule, mod, true);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case StellarRemnantType.NeutronStar:
|
case StellarRemnantType.NeutronStar:
|
||||||
@ -56,12 +41,11 @@ namespace NewHorizons.Builder.Body
|
|||||||
break;
|
break;
|
||||||
case StellarRemnantType.Pulsar:
|
case StellarRemnantType.Pulsar:
|
||||||
MakeNeutronStar(go, sector, mod, star.Config.Star);
|
MakeNeutronStar(go, sector, mod, star.Config.Star);
|
||||||
|
// TODO: add jets, up rotation speed (use a RotateTransform on the star instead of changing sidereal period)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case StellarRemnantType.BlackHole:
|
case StellarRemnantType.BlackHole:
|
||||||
var blackHoleSize = progenitorSize / 100;
|
MakeBlackhole(go, sector, star.Config.Star);
|
||||||
|
|
||||||
SingularityBuilder.MakeBlackHole(go, sector, Vector3.zero, blackHoleSize, true, string.Empty);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -77,7 +61,29 @@ namespace NewHorizons.Builder.Body
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GameObject MakeNeutronStar(GameObject root, Sector sector, IModBehaviour mod, StarModule progenitor)
|
private static StellarRemnantType GetDefault(float progenitorSize)
|
||||||
|
{
|
||||||
|
if (progenitorSize >= 4000) return StellarRemnantType.BlackHole;
|
||||||
|
else if (2000 < progenitorSize && progenitorSize < 4000) return StellarRemnantType.NeutronStar;
|
||||||
|
else return StellarRemnantType.WhiteDwarf;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GameObject MakeWhiteDwarf(GameObject planetGO, Sector sector, IModBehaviour mod, StarModule progenitor, GameObject proxy = null)
|
||||||
|
{
|
||||||
|
var whiteDwarfSize = progenitor.size / 10;
|
||||||
|
var whiteDwarfModule = new StarModule
|
||||||
|
{
|
||||||
|
size = whiteDwarfSize,
|
||||||
|
tint = new MColor(384, 384, 384, 255),
|
||||||
|
lightTint = MColor.white,
|
||||||
|
lightRadius = 10000,
|
||||||
|
solarLuminosity = 0.5f
|
||||||
|
};
|
||||||
|
if (proxy != null) return StarBuilder.MakeStarProxy(planetGO, proxy, whiteDwarfModule, mod, true);
|
||||||
|
else return StarBuilder.Make(planetGO, sector, whiteDwarfModule, mod, true).Item1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GameObject MakeNeutronStar(GameObject planetGO, Sector sector, IModBehaviour mod, StarModule progenitor, GameObject proxy = null)
|
||||||
{
|
{
|
||||||
var neutronStarSize = progenitor.size / 50;
|
var neutronStarSize = progenitor.size / 50;
|
||||||
var neutronStarModule = new StarModule
|
var neutronStarModule = new StarModule
|
||||||
@ -91,7 +97,9 @@ namespace NewHorizons.Builder.Body
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Instead of showing the typical star surface we use a tinted singularity
|
// Instead of showing the typical star surface we use a tinted singularity
|
||||||
var (neutronStar, _, _) = StarBuilder.Make(root, sector, neutronStarModule, mod, true);
|
GameObject neutronStar;
|
||||||
|
if (proxy != null) neutronStar = StarBuilder.MakeStarProxy(planetGO, proxy, neutronStarModule, mod, true);
|
||||||
|
else (neutronStar, _, _) = StarBuilder.Make(planetGO, sector, neutronStarModule, mod, true);
|
||||||
neutronStar.FindChild("Surface").SetActive(false);
|
neutronStar.FindChild("Surface").SetActive(false);
|
||||||
|
|
||||||
// Modify solar flares
|
// Modify solar flares
|
||||||
@ -101,10 +109,40 @@ namespace NewHorizons.Builder.Body
|
|||||||
flares.gameObject.transform.localScale = new Vector3(0.85f, 0.85f, 0.85f);
|
flares.gameObject.transform.localScale = new Vector3(0.85f, 0.85f, 0.85f);
|
||||||
|
|
||||||
// Add singularity
|
// Add singularity
|
||||||
var singularityRenderer = SingularityBuilder.MakeBlackHoleGraphics(root, neutronStarSize * 2.5f);
|
var singularityRenderer = SingularityBuilder.MakeBlackHoleGraphics(planetGO, neutronStarSize * 2.5f);
|
||||||
singularityRenderer.GetComponent<MeshRenderer>().material.color = new Color(0.5f, 2f, 2f, 1f);
|
singularityRenderer.GetComponent<MeshRenderer>().material.color = new Color(0.5f, 2f, 2f, 1f);
|
||||||
|
|
||||||
return neutronStar;
|
return neutronStar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static GameObject MakeBlackhole(GameObject planetGO, Sector sector, StarModule progenitor, GameObject proxy = null)
|
||||||
|
{
|
||||||
|
var blackHoleSize = progenitor.size / 100;
|
||||||
|
|
||||||
|
if (proxy != null) return SingularityBuilder.MakeBlackHoleProxy(proxy, Vector3.zero, blackHoleSize);
|
||||||
|
else return SingularityBuilder.MakeBlackHole(planetGO, sector, Vector3.zero, blackHoleSize, true, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameObject MakeProxyRemnant(GameObject planet, GameObject proxy, IModBehaviour mod, StarModule progenitor)
|
||||||
|
{
|
||||||
|
var remnantType = progenitor.stellarRemnantType;
|
||||||
|
|
||||||
|
if (remnantType == StellarRemnantType.Default) remnantType = GetDefault(progenitor.size);
|
||||||
|
|
||||||
|
switch (remnantType)
|
||||||
|
{
|
||||||
|
case StellarRemnantType.WhiteDwarf:
|
||||||
|
return MakeWhiteDwarf(planet, null, mod, progenitor, proxy);
|
||||||
|
case StellarRemnantType.NeutronStar:
|
||||||
|
return MakeNeutronStar(planet, null, mod, progenitor, proxy);
|
||||||
|
case StellarRemnantType.Pulsar:
|
||||||
|
return MakeNeutronStar(planet, null, mod, progenitor, proxy);
|
||||||
|
case StellarRemnantType.BlackHole:
|
||||||
|
return MakeBlackhole(planet, null, progenitor, proxy);
|
||||||
|
default:
|
||||||
|
Logger.LogError($"Couldn't make proxy remnant for {planet.name}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ namespace NewHorizons.Builder.General
|
|||||||
{
|
{
|
||||||
NHAstroObject astroObject = body.AddComponent<NHAstroObject>();
|
NHAstroObject astroObject = body.AddComponent<NHAstroObject>();
|
||||||
astroObject.HideDisplayName = !config.Base.hasMapMarker;
|
astroObject.HideDisplayName = !config.Base.hasMapMarker;
|
||||||
astroObject.invulnerableToSun = config.Base.invulnerableToSun || config.Star != null;
|
astroObject.invulnerableToSun = config.Base.invulnerableToSun;
|
||||||
|
|
||||||
if (config.Orbit != null) astroObject.SetOrbitalParametersFromConfig(config.Orbit);
|
if (config.Orbit != null) astroObject.SetOrbitalParametersFromConfig(config.Orbit);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
|
using Epic.OnlineServices.Stats;
|
||||||
using NewHorizons.Components.SizeControllers;
|
using NewHorizons.Components.SizeControllers;
|
||||||
using NewHorizons.Handlers;
|
using NewHorizons.Handlers;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
namespace NewHorizons.Components
|
namespace NewHorizons.Components
|
||||||
{
|
{
|
||||||
@ -9,17 +11,25 @@ namespace NewHorizons.Components
|
|||||||
{
|
{
|
||||||
public string astroName;
|
public string astroName;
|
||||||
|
|
||||||
public GameObject _planet;
|
public GameObject planet;
|
||||||
public GameObject _star;
|
|
||||||
public StarEvolutionController _starEvolutionController;
|
private GameObject[] _stars;
|
||||||
private Renderer[] _starRenderers;
|
|
||||||
private TessellatedRenderer[] _starTessellatedRenderers;
|
public StarEvolutionController[] StarEvolutionControllers { get; private set; }
|
||||||
private ParticleSystemRenderer[] _starParticleRenderers;
|
|
||||||
private SolarFlareEmitter _solarFlareEmitter;
|
private IEnumerable<Renderer> _starRenderers = new List<Renderer>();
|
||||||
public CloudLightningGenerator _lightningGenerator;
|
private IEnumerable<TessellatedRenderer> _starTessellatedRenderers = new List<TessellatedRenderer>();
|
||||||
public Renderer _topClouds;
|
private IEnumerable<ParticleSystemRenderer> _starParticleRenderers = new List<ParticleSystemRenderer>();
|
||||||
public NHSupernovaPlanetEffectController _supernovaPlanetEffectController;
|
private IEnumerable<SolarFlareEmitter> _solarFlareEmitter = new List<SolarFlareEmitter>();
|
||||||
public float _baseRealObjectDiameter;
|
|
||||||
|
// Public stuff from the builder
|
||||||
|
public CloudLightningGenerator lightningGenerator;
|
||||||
|
public Renderer topClouds;
|
||||||
|
public NHSupernovaPlanetEffectController supernovaPlanetEffectController;
|
||||||
|
public float baseRealObjectDiameter;
|
||||||
|
|
||||||
|
public GameObject root;
|
||||||
|
public GameObject stellarRemnantGO;
|
||||||
|
|
||||||
public override void Awake()
|
public override void Awake()
|
||||||
{
|
{
|
||||||
@ -32,20 +42,26 @@ namespace NewHorizons.Components
|
|||||||
|
|
||||||
// The star part cant be disabled like the rest and we have to manually disable the renderers
|
// The star part cant be disabled like the rest and we have to manually disable the renderers
|
||||||
// Else it can stop the supernova effect mid way through
|
// Else it can stop the supernova effect mid way through
|
||||||
if (_starEvolutionController == null) _starEvolutionController = GetComponentInChildren<StarEvolutionController>();
|
StarEvolutionControllers = GetComponentsInChildren<StarEvolutionController>();
|
||||||
if (_star == null) _star = _starEvolutionController?.gameObject;
|
_stars = StarEvolutionControllers.Select(x => x.gameObject).ToArray();
|
||||||
|
|
||||||
if (_star != null)
|
foreach (var star in _stars)
|
||||||
{
|
{
|
||||||
_starRenderers = _star.GetComponentsInChildren<Renderer>();
|
_starRenderers = _starRenderers.Concat(star.GetComponentsInChildren<Renderer>());
|
||||||
_starTessellatedRenderers = _star.GetComponentsInChildren<TessellatedRenderer>();
|
_starTessellatedRenderers = _starTessellatedRenderers.Concat(star.GetComponentsInChildren<TessellatedRenderer>());
|
||||||
_starParticleRenderers = _star.GetComponentsInChildren<ParticleSystemRenderer>();
|
_starParticleRenderers = _starParticleRenderers.Concat(star.GetComponentsInChildren<ParticleSystemRenderer>());
|
||||||
_solarFlareEmitter = _star.GetComponentInChildren<SolarFlareEmitter>();
|
_solarFlareEmitter = _solarFlareEmitter.Append(star.GetComponentInChildren<SolarFlareEmitter>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lightningGenerator == null) _lightningGenerator = GetComponentInChildren<CloudLightningGenerator>();
|
var progenitorEvolutionController = root.GetComponentInChildren<StarEvolutionController>();
|
||||||
|
if (progenitorEvolutionController != null && stellarRemnantGO != null)
|
||||||
|
{
|
||||||
|
progenitorEvolutionController.SetStellarRemnant(stellarRemnantGO);
|
||||||
|
}
|
||||||
|
|
||||||
if (_supernovaPlanetEffectController == null) _supernovaPlanetEffectController = GetComponentInChildren<NHSupernovaPlanetEffectController>();
|
if (lightningGenerator == null) lightningGenerator = GetComponentInChildren<CloudLightningGenerator>();
|
||||||
|
|
||||||
|
if (supernovaPlanetEffectController == null) supernovaPlanetEffectController = GetComponentInChildren<NHSupernovaPlanetEffectController>();
|
||||||
|
|
||||||
// Start off
|
// Start off
|
||||||
_outOfRange = false;
|
_outOfRange = false;
|
||||||
@ -81,7 +97,7 @@ namespace NewHorizons.Components
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
if (_planet == null || !_planet.activeSelf)
|
if (planet == null || !planet.activeSelf)
|
||||||
{
|
{
|
||||||
_outOfRange = false;
|
_outOfRange = false;
|
||||||
ToggleRendering(false);
|
ToggleRendering(false);
|
||||||
@ -98,47 +114,51 @@ namespace NewHorizons.Components
|
|||||||
|
|
||||||
foreach (Transform child in transform)
|
foreach (Transform child in transform)
|
||||||
{
|
{
|
||||||
if (child.gameObject == _star) continue;
|
// The first layer of children are the different states of the proxy; root, remnant, eventually quantum states
|
||||||
child.gameObject.SetActive(on);
|
foreach (Transform grandChild in child)
|
||||||
}
|
|
||||||
|
|
||||||
if (_star != null)
|
|
||||||
{
|
|
||||||
if (_solarFlareEmitter != null)
|
|
||||||
{
|
{
|
||||||
_solarFlareEmitter.gameObject.SetActive(on);
|
// Don't disable any stars
|
||||||
}
|
if (_stars.Contains(grandChild.gameObject)) continue;
|
||||||
|
|
||||||
foreach (var renderer in _starRenderers)
|
// Toggle the grandchildren
|
||||||
{
|
grandChild.gameObject.SetActive(on);
|
||||||
renderer.enabled = on;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var renderer in _starTessellatedRenderers)
|
|
||||||
{
|
|
||||||
renderer.enabled = on;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var renderer in _starParticleRenderers)
|
|
||||||
{
|
|
||||||
renderer.enabled = on;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_topClouds != null)
|
foreach (var solarFlare in _solarFlareEmitter)
|
||||||
{
|
{
|
||||||
_topClouds.enabled = on;
|
solarFlare.gameObject.SetActive(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lightningGenerator != null)
|
foreach (var renderer in _starRenderers)
|
||||||
{
|
{
|
||||||
_lightningGenerator.enabled = on;
|
renderer.enabled = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_supernovaPlanetEffectController != null)
|
foreach (var renderer in _starTessellatedRenderers)
|
||||||
{
|
{
|
||||||
if (on) _supernovaPlanetEffectController.Enable();
|
renderer.enabled = on;
|
||||||
else _supernovaPlanetEffectController.Disable();
|
}
|
||||||
|
|
||||||
|
foreach (var renderer in _starParticleRenderers)
|
||||||
|
{
|
||||||
|
renderer.enabled = on;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topClouds != null)
|
||||||
|
{
|
||||||
|
topClouds.enabled = on;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lightningGenerator != null)
|
||||||
|
{
|
||||||
|
lightningGenerator.enabled = on;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supernovaPlanetEffectController != null)
|
||||||
|
{
|
||||||
|
if (on) supernovaPlanetEffectController.Enable();
|
||||||
|
else supernovaPlanetEffectController.Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,7 @@ namespace NewHorizons.Components
|
|||||||
{
|
{
|
||||||
if (!_shockLayer.enabled) _shockLayer.enabled = true;
|
if (!_shockLayer.enabled) _shockLayer.enabled = true;
|
||||||
Vector3 dir = Vector3.Normalize(transform.position - StarEvolutionController.transform.position);
|
Vector3 dir = Vector3.Normalize(transform.position - StarEvolutionController.transform.position);
|
||||||
s_matPropBlock_ShockLayer.SetColor(s_propID_Color, StarEvolutionController.SupernovaColour != null ? StarEvolutionController.SupernovaColour.ToColor() : _shockLayerColor);
|
s_matPropBlock_ShockLayer.SetColor(s_propID_Color, StarEvolutionController.supernovaColour != null ? StarEvolutionController.supernovaColour.ToColor() : _shockLayerColor);
|
||||||
s_matPropBlock_ShockLayer.SetMatrix(s_propID_WorldToLocalShockMatrix, Matrix4x4.TRS(transform.position, Quaternion.LookRotation(dir, Vector3.up), Vector3.one).inverse);
|
s_matPropBlock_ShockLayer.SetMatrix(s_propID_WorldToLocalShockMatrix, Matrix4x4.TRS(transform.position, Quaternion.LookRotation(dir, Vector3.up), Vector3.one).inverse);
|
||||||
s_matPropBlock_ShockLayer.SetVector(s_propID_Dir, dir);
|
s_matPropBlock_ShockLayer.SetVector(s_propID_Dir, dir);
|
||||||
s_matPropBlock_ShockLayer.SetFloat(s_propID_Length, shockLayerTrailLength);
|
s_matPropBlock_ShockLayer.SetFloat(s_propID_Length, shockLayerTrailLength);
|
||||||
|
|||||||
@ -16,15 +16,15 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
{
|
{
|
||||||
public class StarEvolutionController : SizeController
|
public class StarEvolutionController : SizeController
|
||||||
{
|
{
|
||||||
public bool _isProxy;
|
public bool isProxy;
|
||||||
|
|
||||||
public GameObject atmosphere;
|
public GameObject atmosphere;
|
||||||
public StarController controller;
|
public StarController controller;
|
||||||
public StellarDeathController supernova;
|
public StellarDeathController supernova;
|
||||||
public bool WillExplode { get; set; }
|
public bool willExplode;
|
||||||
public MColor StartColour { get; set; }
|
public MColor startColour;
|
||||||
public MColor EndColour { get; set; }
|
public MColor endColour;
|
||||||
public MColor SupernovaColour { get; set; }
|
public MColor supernovaColour;
|
||||||
public Texture normalRamp;
|
public Texture normalRamp;
|
||||||
public Texture collapseRamp;
|
public Texture collapseRamp;
|
||||||
|
|
||||||
@ -34,12 +34,13 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
private GameObject _stellarRemnant;
|
private GameObject _stellarRemnant;
|
||||||
private PlanetaryFogController _fog;
|
private PlanetaryFogController _fog;
|
||||||
private MeshRenderer[] _atmosphereRenderers;
|
private MeshRenderer[] _atmosphereRenderers;
|
||||||
|
|
||||||
public HeatHazardVolume heatVolume;
|
public HeatHazardVolume heatVolume;
|
||||||
public DestructionVolume destructionVolume;
|
public DestructionVolume destructionVolume;
|
||||||
public StarDestructionVolume planetDestructionVolume;
|
public StarDestructionVolume planetDestructionVolume;
|
||||||
public StarFluidVolume starFluidVolume;
|
public StarFluidVolume starFluidVolume;
|
||||||
|
|
||||||
private SolarFlareEmitter _flareEmitter;
|
private SolarFlareEmitter _flareEmitter;
|
||||||
private MapMarker _mapMarker;
|
|
||||||
private OWRigidbody _rigidbody;
|
private OWRigidbody _rigidbody;
|
||||||
|
|
||||||
public OWAudioSource oneShotSource;
|
public OWAudioSource oneShotSource;
|
||||||
@ -70,13 +71,13 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
|
|
||||||
private StarEvolutionController _proxy;
|
private StarEvolutionController _proxy;
|
||||||
|
|
||||||
public UnityEvent CollapseStart = new UnityEvent();
|
public UnityEvent CollapseStart = new();
|
||||||
public UnityEvent CollapseStop = new UnityEvent();
|
public UnityEvent CollapseStop = new();
|
||||||
public UnityEvent SupernovaStart = new UnityEvent();
|
public UnityEvent SupernovaStart = new();
|
||||||
public UnityEvent SupernovaStop = new UnityEvent();
|
public UnityEvent SupernovaStop = new();
|
||||||
|
|
||||||
private float maxScale;
|
private float _maxScale;
|
||||||
private float minScale;
|
private float _minScale;
|
||||||
private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp");
|
private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp");
|
||||||
private static readonly int ColorTime = Shader.PropertyToID("_ColorTime");
|
private static readonly int ColorTime = Shader.PropertyToID("_ColorTime");
|
||||||
private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius");
|
private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius");
|
||||||
@ -88,7 +89,6 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_rigidbody = this.GetAttachedOWRigidbody();
|
_rigidbody = this.GetAttachedOWRigidbody();
|
||||||
if (_rigidbody != null) _mapMarker = _rigidbody.GetComponent<MapMarker>();
|
|
||||||
|
|
||||||
var sun = GameObject.FindObjectOfType<SunController>();
|
var sun = GameObject.FindObjectOfType<SunController>();
|
||||||
_collapseStartSurfaceMaterial = new Material(sun._collapseStartSurfaceMaterial);
|
_collapseStartSurfaceMaterial = new Material(sun._collapseStartSurfaceMaterial);
|
||||||
@ -117,24 +117,24 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
_startSurfaceMaterial.SetTexture(ColorRamp, _normalRamp);
|
_startSurfaceMaterial.SetTexture(ColorRamp, _normalRamp);
|
||||||
_endSurfaceMaterial.SetTexture(ColorRamp, _normalRamp);
|
_endSurfaceMaterial.SetTexture(ColorRamp, _normalRamp);
|
||||||
|
|
||||||
if (StartColour == null)
|
if (startColour == null)
|
||||||
{
|
{
|
||||||
_startColour = _startSurfaceMaterial.color;
|
_startColour = _startSurfaceMaterial.color;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_startColour = StartColour.ToColor();
|
_startColour = startColour.ToColor();
|
||||||
_startSurfaceMaterial.color = _startColour;
|
_startSurfaceMaterial.color = _startColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EndColour == null)
|
if (endColour == null)
|
||||||
{
|
{
|
||||||
_endColour = _startColour;
|
_endColour = _startColour;
|
||||||
_endSurfaceMaterial.color = _startColour;
|
_endSurfaceMaterial.color = _startColour;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_endColour = EndColour.ToColor();
|
_endColour = endColour.ToColor();
|
||||||
_endSurfaceMaterial.color = _endColour * 4.5948f;
|
_endSurfaceMaterial.color = _endColour * 4.5948f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,13 +151,13 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
|
|
||||||
if (scaleCurve != null)
|
if (scaleCurve != null)
|
||||||
{
|
{
|
||||||
maxScale = scaleCurve.keys.Select(x => x.value).Max() * size;
|
_maxScale = scaleCurve.keys.Select(x => x.value).Max() * size;
|
||||||
minScale = scaleCurve.keys.Select(x => x.value).Min() * size;
|
_minScale = scaleCurve.keys.Select(x => x.value).Min() * size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
maxScale = 0;
|
_maxScale = 0;
|
||||||
minScale = 0;
|
_minScale = 0;
|
||||||
scaleCurve = new AnimationCurve();
|
scaleCurve = new AnimationCurve();
|
||||||
scaleCurve.AddKey(0, 1);
|
scaleCurve.AddKey(0, 1);
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
_flareEmitter = GetComponentInChildren<SolarFlareEmitter>();
|
_flareEmitter = GetComponentInChildren<SolarFlareEmitter>();
|
||||||
_surfaceMaterial = supernova._surface._materials[0];
|
_surfaceMaterial = supernova._surface._materials[0];
|
||||||
|
|
||||||
if (!_isProxy) SupernovaEffectHandler.RegisterStar(this);
|
if (!isProxy) SupernovaEffectHandler.RegisterStar(this);
|
||||||
|
|
||||||
var secondsElapsed = TimeLoop.GetSecondsElapsed();
|
var secondsElapsed = TimeLoop.GetSecondsElapsed();
|
||||||
var lifespanInSeconds = lifespan * 60;
|
var lifespanInSeconds = lifespan * 60;
|
||||||
@ -195,11 +195,11 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
private void UpdateMainSequence()
|
private void UpdateMainSequence()
|
||||||
{
|
{
|
||||||
// Only do colour transition stuff if they set an end colour
|
// Only do colour transition stuff if they set an end colour
|
||||||
if (EndColour != null)
|
if (endColour != null)
|
||||||
{
|
{
|
||||||
// Use minutes elapsed if theres no resizing happening, else make it get redder the larger it is or wtv
|
// Use minutes elapsed if theres no resizing happening, else make it get redder the larger it is or wtv
|
||||||
var t = TimeLoop.GetMinutesElapsed() / lifespan;
|
var t = TimeLoop.GetMinutesElapsed() / lifespan;
|
||||||
if (maxScale != minScale) t = Mathf.InverseLerp(minScale, maxScale, CurrentScale);
|
if (_maxScale != _minScale) t = Mathf.InverseLerp(_minScale, _maxScale, CurrentScale);
|
||||||
|
|
||||||
if (t < 1f)
|
if (t < 1f)
|
||||||
{
|
{
|
||||||
@ -293,10 +293,20 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
if (collider.attachedRigidbody != null)
|
if (collider.attachedRigidbody != null)
|
||||||
{
|
{
|
||||||
// Destroy any planets that are not invulnerable to the sun
|
// Destroy any planets that are not invulnerable to the sun
|
||||||
var body = collider.attachedRigidbody.GetComponent<OWRigidbody>();
|
var rb = collider.attachedRigidbody;
|
||||||
|
var body = rb.GetComponent<OWRigidbody>();
|
||||||
var astroObject = collider.gameObject.GetComponent<NHAstroObject>();
|
var astroObject = collider.gameObject.GetComponent<NHAstroObject>();
|
||||||
if (astroObject != null && !astroObject.invulnerableToSun)
|
if (astroObject != null)
|
||||||
planetDestructionVolume.Vanish(body, new RelativeLocationData(body, _rigidbody, planetDestructionVolume.transform));
|
{
|
||||||
|
if (!astroObject.invulnerableToSun)
|
||||||
|
planetDestructionVolume.Vanish(body, new RelativeLocationData(body, _rigidbody, planetDestructionVolume.transform));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Vanish anything unrelated to player
|
||||||
|
if (!(rb.CompareTag("Player") || rb.CompareTag("Ship") || rb.CompareTag("ShipCockpit") || rb.CompareTag("Probe")))
|
||||||
|
planetDestructionVolume.Vanish(body, new RelativeLocationData(body, _rigidbody, planetDestructionVolume.transform));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,7 +422,7 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
{
|
{
|
||||||
base.FixedUpdate();
|
base.FixedUpdate();
|
||||||
UpdateMainSequence();
|
UpdateMainSequence();
|
||||||
if (WillExplode && (TimeLoop.GetMinutesElapsed() / lifespan) >= 1) StartCollapse();
|
if (willExplode && (TimeLoop.GetMinutesElapsed() / lifespan) >= 1) StartCollapse();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
2
NewHorizons/External/Configs/PlanetConfig.cs
vendored
2
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -219,7 +219,7 @@ namespace NewHorizons.External.Configs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, int> existingGroupsPropCounts = new Dictionary<string, int>();
|
var existingGroupsPropCounts = new Dictionary<string, int>();
|
||||||
foreach (var prop in Props?.details)
|
foreach (var prop in Props?.details)
|
||||||
{
|
{
|
||||||
if (prop.quantumGroupID == null) continue;
|
if (prop.quantumGroupID == null) continue;
|
||||||
|
|||||||
@ -448,11 +448,15 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
AstroObjectLocator.RegisterCustomAstroObject(ao);
|
AstroObjectLocator.RegisterCustomAstroObject(ao);
|
||||||
|
|
||||||
|
var otherBodies = Main.BodyDict[Main.Instance.CurrentStarSystem];
|
||||||
|
var remnant = otherBodies.Where(x => x.Config.isStellarRemnant && x.Config.name == body.Config.name).FirstOrDefault();
|
||||||
|
// TODO: add proxies for quantum states
|
||||||
|
//var quantumStates = otherBodies.Where(x => x.Config.isQuantumState && x.Config.name == body.Config.name).ToArray();
|
||||||
if (!(body.Config.Cloak != null && body.Config.Cloak.radius != 0f))
|
if (!(body.Config.Cloak != null && body.Config.Cloak.radius != 0f))
|
||||||
{
|
{
|
||||||
Delay.FireOnNextUpdate(() =>
|
Delay.FireOnNextUpdate(() =>
|
||||||
{
|
{
|
||||||
ProxyBuilder.Make(go, body);
|
ProxyBuilder.Make(go, body, remnant);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ namespace NewHorizons.Patches
|
|||||||
[HarmonyPatch(typeof(ProxyBody), nameof(ProxyBody.IsObjectInSupernova))]
|
[HarmonyPatch(typeof(ProxyBody), nameof(ProxyBody.IsObjectInSupernova))]
|
||||||
public static bool ProxyBody_IsObjectInSupernova(ProxyBody __instance, ref bool __result)
|
public static bool ProxyBody_IsObjectInSupernova(ProxyBody __instance, ref bool __result)
|
||||||
{
|
{
|
||||||
if (__instance is NHProxy nh && nh._starEvolutionController != null)
|
if (__instance is NHProxy nh && nh.StarEvolutionControllers != null)
|
||||||
{
|
{
|
||||||
__result = false;
|
__result = false;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user