mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Refactor
This commit is contained in:
parent
7a00409f6c
commit
72ec389fbd
@ -95,7 +95,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject MakeBlackHole(GameObject planetGO, Sector sector, Vector3 localPosition, float size,
|
public static GameObject MakeBlackHole(GameObject planetGO, Sector sector, Vector3 localPosition, float size,
|
||||||
bool hasDestructionVolume, string targetSolarSystem, VariableSizeModule.TimeValuePair[] curve, bool makeAudio = true)
|
bool hasDestructionVolume, string targetSolarSystem, VariableSizeModule.TimeValuePair[] curve = null, bool makeAudio = true)
|
||||||
{
|
{
|
||||||
var blackHole = new GameObject("BlackHole");
|
var blackHole = new GameObject("BlackHole");
|
||||||
blackHole.SetActive(false);
|
blackHole.SetActive(false);
|
||||||
|
|||||||
134
NewHorizons/Builder/Body/StellarRemnantBuilder.cs
Normal file
134
NewHorizons/Builder/Body/StellarRemnantBuilder.cs
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
using NewHorizons.Builder.General;
|
||||||
|
using NewHorizons.Components;
|
||||||
|
using NewHorizons.Components.SizeControllers;
|
||||||
|
using NewHorizons.External.Configs;
|
||||||
|
using NewHorizons.External.Modules.VariableSize;
|
||||||
|
using NewHorizons.Handlers;
|
||||||
|
using NewHorizons.Utility;
|
||||||
|
using OWML.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
|
namespace NewHorizons.Builder.Body
|
||||||
|
{
|
||||||
|
public static class StellarRemnantBuilder
|
||||||
|
{
|
||||||
|
public static void Make(GameObject go, OWRigidbody rb, PlanetConfig config, IModBehaviour mod, float sphereOfInfluence)
|
||||||
|
{
|
||||||
|
Logger.Log($"Creating stellar remnant for [{config.name}]");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var starModule = config.Star;
|
||||||
|
var size = starModule.size;
|
||||||
|
var sector = SectorBuilder.Make(go, rb, sphereOfInfluence);
|
||||||
|
sector.name = "StellarRemnant";
|
||||||
|
var ss = sector.GetComponent<SphereShape>();
|
||||||
|
|
||||||
|
var stellarRemnantController = sector.gameObject.AddComponent<StellarRemnantController>();
|
||||||
|
var starEvolutionController = go.GetComponentInChildren<StarEvolutionController>(true);
|
||||||
|
stellarRemnantController.SetStarEvolutionController(starEvolutionController);
|
||||||
|
starEvolutionController.SetStellarRemnantController(stellarRemnantController);
|
||||||
|
|
||||||
|
sector.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
if (starModule.stellarRemnant != null)
|
||||||
|
{
|
||||||
|
var srConfig = starModule.stellarRemnant.ConvertToPlanetConfig(config);
|
||||||
|
var srBody = new NewHorizonsBody(srConfig, mod);
|
||||||
|
stellarRemnantController.SetRemnantType(StellarRemnantType.Custom);
|
||||||
|
stellarRemnantController.SetSurfaceSize(starModule.stellarRemnant.Base.surfaceSize);
|
||||||
|
stellarRemnantController.SetSurfaceGravity(starModule.stellarRemnant.Base.surfaceGravity);
|
||||||
|
stellarRemnantController.SetSiderealPeriod(starModule.stellarRemnant.siderealPeriod);
|
||||||
|
var srSphereOfInfluence = PlanetCreationHandler.GetSphereOfInfluence(srBody);
|
||||||
|
stellarRemnantController.SetSphereOfInfluence(srSphereOfInfluence);
|
||||||
|
ss.radius = srSphereOfInfluence + 10;
|
||||||
|
var alignmentRadius = srBody.Config.Atmosphere?.clouds?.outerCloudRadius ?? 1.5f * srBody.Config.Base.surfaceSize;
|
||||||
|
if (srBody.Config.Base.surfaceGravity == 0) alignmentRadius = 0;
|
||||||
|
stellarRemnantController.SetAlignmentRadius(alignmentRadius);
|
||||||
|
PlanetCreationHandler.SharedGenerateBody(srBody, go, sector, rb, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var remnantType = starModule.stellarRemnantType;
|
||||||
|
if (remnantType == StellarRemnantType.Default)
|
||||||
|
{
|
||||||
|
if (size > 4000)
|
||||||
|
remnantType = StellarRemnantType.BlackHole;
|
||||||
|
else if (2000 < size && size < 3000)
|
||||||
|
remnantType = StellarRemnantType.NeutronStar;
|
||||||
|
else
|
||||||
|
remnantType = StellarRemnantType.WhiteDwarf;
|
||||||
|
}
|
||||||
|
stellarRemnantController.SetRemnantType(starModule.stellarRemnantType);
|
||||||
|
switch (starModule.stellarRemnantType)
|
||||||
|
{
|
||||||
|
case StellarRemnantType.WhiteDwarf:
|
||||||
|
var wdSurfaceSize = size / 10;
|
||||||
|
stellarRemnantController.SetSurfaceSize(wdSurfaceSize);
|
||||||
|
stellarRemnantController.SetSurfaceGravity(config.Base.surfaceGravity * 1.4f);
|
||||||
|
stellarRemnantController.SetSphereOfInfluence(wdSurfaceSize * 2);
|
||||||
|
ss.radius = (wdSurfaceSize * 2) + 10;
|
||||||
|
stellarRemnantController.SetAlignmentRadius(wdSurfaceSize * 1.5f);
|
||||||
|
stellarRemnantController.SetSiderealPeriod(config.Orbit.siderealPeriod);
|
||||||
|
stellarRemnantController.SetStarController(StarBuilder.Make(go, sector, new StarModule
|
||||||
|
{
|
||||||
|
size = wdSurfaceSize,
|
||||||
|
tint = MColor.white,
|
||||||
|
endTint = MColor.black
|
||||||
|
}, mod, true));
|
||||||
|
break;
|
||||||
|
case StellarRemnantType.NeutronStar:
|
||||||
|
var nsSurfaceSize = size / 50;
|
||||||
|
stellarRemnantController.SetSurfaceSize(nsSurfaceSize);
|
||||||
|
stellarRemnantController.SetSurfaceGravity(config.Base.surfaceGravity * 2);
|
||||||
|
stellarRemnantController.SetSphereOfInfluence(nsSurfaceSize * 2);
|
||||||
|
ss.radius = (nsSurfaceSize * 2) + 10;
|
||||||
|
stellarRemnantController.SetAlignmentRadius(nsSurfaceSize * 1.5f);
|
||||||
|
stellarRemnantController.SetSiderealPeriod(1);
|
||||||
|
stellarRemnantController.SetStarController(StarBuilder.Make(go, sector, new StarModule
|
||||||
|
{
|
||||||
|
size = nsSurfaceSize,
|
||||||
|
tint = MColor.cyan
|
||||||
|
}, mod, true));
|
||||||
|
break;
|
||||||
|
case StellarRemnantType.Pulsar:
|
||||||
|
var psSurfaceSize = size / 50;
|
||||||
|
stellarRemnantController.SetSurfaceSize(psSurfaceSize);
|
||||||
|
stellarRemnantController.SetSurfaceGravity(config.Base.surfaceGravity * 2);
|
||||||
|
stellarRemnantController.SetSphereOfInfluence(psSurfaceSize * 2);
|
||||||
|
ss.radius = (psSurfaceSize * 2) + 10;
|
||||||
|
stellarRemnantController.SetAlignmentRadius(psSurfaceSize * 1.5f);
|
||||||
|
stellarRemnantController.SetSiderealPeriod(0.5f);
|
||||||
|
stellarRemnantController.SetStarController(StarBuilder.Make(go, sector, new StarModule
|
||||||
|
{
|
||||||
|
size = psSurfaceSize,
|
||||||
|
tint = MColor.cyan
|
||||||
|
}, mod, true));
|
||||||
|
break;
|
||||||
|
case StellarRemnantType.BlackHole:
|
||||||
|
var bhSurfaceSize = size / 100;
|
||||||
|
stellarRemnantController.SetSurfaceSize(bhSurfaceSize);
|
||||||
|
stellarRemnantController.SetSurfaceGravity(config.Base.surfaceGravity * 4);
|
||||||
|
stellarRemnantController.SetSphereOfInfluence(bhSurfaceSize * 2);
|
||||||
|
stellarRemnantController.SetSiderealPeriod(0.25f);
|
||||||
|
ss.radius = (bhSurfaceSize * 2) + 10;
|
||||||
|
stellarRemnantController.SetAlignmentRadius(bhSurfaceSize * 1.5f);
|
||||||
|
SingularityBuilder.MakeBlackHole(go, sector, Vector3.zero, bhSurfaceSize, true, string.Empty);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't make stellar remnant for [{config.name}]:\n{ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using NewHorizons.Components.SizeControllers;
|
using NewHorizons.Components.SizeControllers;
|
||||||
|
using NewHorizons.External.Modules.VariableSize;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -8,7 +9,7 @@ namespace NewHorizons.Components
|
|||||||
{
|
{
|
||||||
public class StellarRemnantController : MonoBehaviour
|
public class StellarRemnantController : MonoBehaviour
|
||||||
{
|
{
|
||||||
private RemnantType _type = RemnantType.None;
|
private StellarRemnantType _type = StellarRemnantType.Default;
|
||||||
|
|
||||||
private StarEvolutionController _starEvolutionController;
|
private StarEvolutionController _starEvolutionController;
|
||||||
|
|
||||||
@ -22,8 +23,8 @@ namespace NewHorizons.Components
|
|||||||
private float _sphereOfInfluence = 0;
|
private float _sphereOfInfluence = 0;
|
||||||
private float _alignmentRadius = 0;
|
private float _alignmentRadius = 0;
|
||||||
|
|
||||||
public RemnantType GetRemnantType() => _type;
|
public StellarRemnantType GetRemnantType() => _type;
|
||||||
public void SetRemnantType(RemnantType type) => _type = type;
|
public void SetRemnantType(StellarRemnantType type) => _type = type;
|
||||||
|
|
||||||
public void SetSiderealPeriod(float siderealPeriod) => _siderealPeriod = siderealPeriod;
|
public void SetSiderealPeriod(float siderealPeriod) => _siderealPeriod = siderealPeriod;
|
||||||
public void SetSurfaceGravity(float surfaceGravity) => _surfaceGravity = surfaceGravity;
|
public void SetSurfaceGravity(float surfaceGravity) => _surfaceGravity = surfaceGravity;
|
||||||
@ -68,14 +69,5 @@ namespace NewHorizons.Components
|
|||||||
|
|
||||||
if (_starController != null) StarLightController.AddStar(_starController);
|
if (_starController != null) StarLightController.AddStar(_starController);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RemnantType
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
BlackHole,
|
|
||||||
NeutronStar,
|
|
||||||
WhiteDwarf,
|
|
||||||
Custom
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5
NewHorizons/External/Configs/PlanetConfig.cs
vendored
5
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -100,11 +100,6 @@ namespace NewHorizons.External.Configs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool isQuantumState;
|
public bool isQuantumState;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Does this config describe a stellar remnant of a custom star defined in another file?
|
|
||||||
/// </summary>
|
|
||||||
public bool isStellarRemnant;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add lava to this planet
|
/// Add lava to this planet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using NewHorizons.External.Configs;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
namespace NewHorizons.External.Modules.VariableSize
|
namespace NewHorizons.External.Modules.VariableSize
|
||||||
{
|
{
|
||||||
@ -84,5 +87,141 @@ namespace NewHorizons.External.Modules.VariableSize
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(50000f)] [Range(0f, double.MaxValue)]
|
[DefaultValue(50000f)] [Range(0f, double.MaxValue)]
|
||||||
public float lightRadius = 50000f;
|
public float lightRadius = 50000f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type of death your star will have.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue("default")] public StellarDeathType stellarDeathType = StellarDeathType.Default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type of stellar remnant your star will leave behind.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue("default")] public StellarRemnantType stellarRemnantType = StellarRemnantType.Default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If you want a custom stellar remnant, use this.
|
||||||
|
/// </summary>
|
||||||
|
public StellarRemnantModule stellarRemnant;
|
||||||
|
|
||||||
|
public class StellarRemnantModule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes this Body's atmosphere
|
||||||
|
/// </summary>
|
||||||
|
public AtmosphereModule Atmosphere;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base Properties of this Body
|
||||||
|
/// </summary>
|
||||||
|
public BaseModule Base;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add bramble nodes to this planet and/or make this planet a bramble dimension
|
||||||
|
/// </summary>
|
||||||
|
public BrambleModule Bramble;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add a cloaking field to this planet
|
||||||
|
/// </summary>
|
||||||
|
public CloakModule Cloak;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add funnel from this planet to another
|
||||||
|
/// </summary>
|
||||||
|
public FunnelModule Funnel;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generate the surface of this planet using a heightmap
|
||||||
|
/// </summary>
|
||||||
|
public HeightMapModule HeightMap;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add lava to this planet
|
||||||
|
/// </summary>
|
||||||
|
public LavaModule Lava;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Procedural Generation
|
||||||
|
/// </summary>
|
||||||
|
public ProcGenModule ProcGen;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Spawn various objects on this body
|
||||||
|
/// </summary>
|
||||||
|
public PropModule Props;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of paths to child GameObjects to destroy on this planet
|
||||||
|
/// </summary>
|
||||||
|
public string[] removeChildren;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a ring around the planet
|
||||||
|
/// </summary>
|
||||||
|
public RingModule Ring;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add sand to this planet
|
||||||
|
/// </summary>
|
||||||
|
public SandModule Sand;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rotation period in minutes.
|
||||||
|
/// </summary>
|
||||||
|
public float siderealPeriod;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Make this body a star
|
||||||
|
/// </summary>
|
||||||
|
public StarModule Star;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add water to this planet
|
||||||
|
/// </summary>
|
||||||
|
public WaterModule Water;
|
||||||
|
|
||||||
|
public PlanetConfig ConvertToPlanetConfig(PlanetConfig star)
|
||||||
|
{
|
||||||
|
PlanetConfig planetConfig = new PlanetConfig();
|
||||||
|
planetConfig.name = star.name;
|
||||||
|
planetConfig.starSystem = star.starSystem;
|
||||||
|
planetConfig.Atmosphere = Atmosphere;
|
||||||
|
planetConfig.Base = Base;
|
||||||
|
planetConfig.Bramble = Bramble;
|
||||||
|
planetConfig.Cloak = Cloak;
|
||||||
|
planetConfig.Funnel = Funnel;
|
||||||
|
planetConfig.HeightMap = HeightMap;
|
||||||
|
planetConfig.Lava = Lava;
|
||||||
|
planetConfig.Orbit = star.Orbit;
|
||||||
|
planetConfig.ProcGen = ProcGen;
|
||||||
|
planetConfig.Props = Props;
|
||||||
|
planetConfig.removeChildren = removeChildren;
|
||||||
|
planetConfig.Ring = Ring;
|
||||||
|
planetConfig.Sand = Sand;
|
||||||
|
planetConfig.Water = Water;
|
||||||
|
planetConfig.Validate();
|
||||||
|
planetConfig.Migrate();
|
||||||
|
return planetConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public enum StellarDeathType
|
||||||
|
{
|
||||||
|
[EnumMember(Value = @"default")] Default,
|
||||||
|
[EnumMember(Value = @"planetaryNebula")] PlanetaryNebula,
|
||||||
|
[EnumMember(Value = @"supernova")] Supernova
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public enum StellarRemnantType
|
||||||
|
{
|
||||||
|
[EnumMember(Value = @"default")] Default,
|
||||||
|
[EnumMember(Value = @"whiteDwarf")] WhiteDwarf,
|
||||||
|
[EnumMember(Value = @"neutronStar")] NeutronStar,
|
||||||
|
[EnumMember(Value = @"pulsar")] Pulsar,
|
||||||
|
[EnumMember(Value = @"blackHole")] BlackHole,
|
||||||
|
[EnumMember(Value = @"custom")] Custom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -200,10 +200,6 @@ namespace NewHorizons.Handlers
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (body.Config.isStellarRemnant)
|
|
||||||
{
|
|
||||||
//Skip
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateBody(body, existingPlanet);
|
UpdateBody(body, existingPlanet);
|
||||||
@ -222,10 +218,6 @@ namespace NewHorizons.Handlers
|
|||||||
// If the ground state object isn't made yet do it later
|
// If the ground state object isn't made yet do it later
|
||||||
_nextPassBodies.Add(body);
|
_nextPassBodies.Add(body);
|
||||||
}
|
}
|
||||||
else if (body.Config.isStellarRemnant)
|
|
||||||
{
|
|
||||||
//Skip
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -460,7 +452,7 @@ namespace NewHorizons.Handlers
|
|||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float GetSphereOfInfluence(NewHorizonsBody body)
|
internal static float GetSphereOfInfluence(NewHorizonsBody body)
|
||||||
{
|
{
|
||||||
var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.size : 0f;
|
var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.size : 0f;
|
||||||
float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.surfaceSize * 2f);
|
float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.surfaceSize * 2f);
|
||||||
@ -470,7 +462,7 @@ namespace NewHorizons.Handlers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// What is called both on existing planets and new planets
|
// What is called both on existing planets and new planets
|
||||||
private static GameObject SharedGenerateBody(NewHorizonsBody body, GameObject go, Sector sector, OWRigidbody rb)
|
internal static GameObject SharedGenerateBody(NewHorizonsBody body, GameObject go, Sector sector, OWRigidbody rb, bool isStellarRemnant = false)
|
||||||
{
|
{
|
||||||
var sphereOfInfluence = GetSphereOfInfluence(body);
|
var sphereOfInfluence = GetSphereOfInfluence(body);
|
||||||
|
|
||||||
@ -501,92 +493,14 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
if (body.Config.Star != null)
|
if (body.Config.Star != null)
|
||||||
{
|
{
|
||||||
StarLightController.AddStar(StarBuilder.Make(go, sector, body.Config.Star, body.Mod, body.Config.isStellarRemnant));
|
if (isStellarRemnant)
|
||||||
if (!body.Config.isStellarRemnant)
|
|
||||||
{
|
{
|
||||||
Logger.Log($"Creating stellar remnant for [{body.Config.name}]");
|
sector.GetComponent<StellarRemnantController>().SetStarController(StarBuilder.Make(go, sector, body.Config.Star, body.Mod, true));
|
||||||
try
|
}
|
||||||
{
|
else
|
||||||
var size = body.Config.Star.size;
|
{
|
||||||
var srBody = Main.BodyDict[body.Config.starSystem].Where(x => x.Config.name == body.Config.name && body.Config.isStellarRemnant).FirstOrDefault();
|
StarLightController.AddStar(StarBuilder.Make(go, sector, body.Config.Star, body.Mod, false));
|
||||||
var srSector = SectorBuilder.Make(go, rb, GetSphereOfInfluence(body));
|
StellarRemnantBuilder.Make(go, rb, body.Config, body.Mod, sphereOfInfluence);
|
||||||
srSector.name = "StellarRemnant";
|
|
||||||
var ss = srSector.GetComponent<SphereShape>();
|
|
||||||
|
|
||||||
var stellarRemnantController = srSector.gameObject.AddComponent<StellarRemnantController>();
|
|
||||||
var starEvolutionController = go.GetComponentInChildren<StarEvolutionController>(true);
|
|
||||||
stellarRemnantController.SetStarEvolutionController(starEvolutionController);
|
|
||||||
starEvolutionController.SetStellarRemnantController(stellarRemnantController);
|
|
||||||
|
|
||||||
srSector.gameObject.SetActive(false);
|
|
||||||
|
|
||||||
if (srBody != null)
|
|
||||||
{
|
|
||||||
stellarRemnantController.SetRemnantType(StellarRemnantController.RemnantType.Custom);
|
|
||||||
stellarRemnantController.SetSurfaceSize(srBody.Config.Base.surfaceSize);
|
|
||||||
stellarRemnantController.SetSurfaceGravity(srBody.Config.Base.surfaceGravity);
|
|
||||||
stellarRemnantController.SetSiderealPeriod(srBody.Config.Orbit.siderealPeriod);
|
|
||||||
var srSphereOfInfluence = GetSphereOfInfluence(srBody);
|
|
||||||
stellarRemnantController.SetSphereOfInfluence(srSphereOfInfluence);
|
|
||||||
ss.radius = srSphereOfInfluence + 10;
|
|
||||||
var alignmentRadius = srBody.Config.Atmosphere?.clouds?.outerCloudRadius ?? 1.5f * srBody.Config.Base.surfaceSize;
|
|
||||||
if (srBody.Config.Base.surfaceGravity == 0) alignmentRadius = 0;
|
|
||||||
stellarRemnantController.SetAlignmentRadius(alignmentRadius);
|
|
||||||
SharedGenerateBody(srBody, go, srSector, rb);
|
|
||||||
}
|
|
||||||
// Black Hole
|
|
||||||
else if (size > 4000)
|
|
||||||
{
|
|
||||||
stellarRemnantController.SetRemnantType(StellarRemnantController.RemnantType.BlackHole);
|
|
||||||
var bhSurfaceSize = size * 0.015f;
|
|
||||||
stellarRemnantController.SetSurfaceSize(bhSurfaceSize);
|
|
||||||
stellarRemnantController.SetSurfaceGravity(body.Config.Base.surfaceGravity * 4);
|
|
||||||
stellarRemnantController.SetSphereOfInfluence(bhSurfaceSize * 2);
|
|
||||||
stellarRemnantController.SetSiderealPeriod(0.1f);
|
|
||||||
ss.radius = (bhSurfaceSize * 2) + 10;
|
|
||||||
stellarRemnantController.SetAlignmentRadius(bhSurfaceSize * 1.5f);
|
|
||||||
SingularityBuilder.MakeBlackHole(go, srSector, Vector3.zero, bhSurfaceSize, true, string.Empty, new External.Modules.VariableSize.VariableSizeModule.TimeValuePair[0]);
|
|
||||||
}
|
|
||||||
// Neutron Star
|
|
||||||
else if (2000 < size && size < 3000)
|
|
||||||
{
|
|
||||||
stellarRemnantController.SetRemnantType(StellarRemnantController.RemnantType.NeutronStar);
|
|
||||||
var nsSurfaceSize = size * 0.03f;
|
|
||||||
stellarRemnantController.SetSurfaceSize(nsSurfaceSize);
|
|
||||||
stellarRemnantController.SetSurfaceGravity(body.Config.Base.surfaceGravity * 2);
|
|
||||||
stellarRemnantController.SetSphereOfInfluence(nsSurfaceSize * 2);
|
|
||||||
ss.radius = (nsSurfaceSize * 2) + 10;
|
|
||||||
stellarRemnantController.SetAlignmentRadius(nsSurfaceSize * 1.5f);
|
|
||||||
stellarRemnantController.SetSiderealPeriod(0.1f);
|
|
||||||
stellarRemnantController.SetStarController(StarBuilder.Make(go, srSector, new External.Modules.VariableSize.StarModule
|
|
||||||
{
|
|
||||||
size = nsSurfaceSize,
|
|
||||||
tint = MColor.cyan
|
|
||||||
}, body.Mod, true));
|
|
||||||
}
|
|
||||||
// White Dwarf
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stellarRemnantController.SetRemnantType(StellarRemnantController.RemnantType.WhiteDwarf);
|
|
||||||
var wdSurfaceSize = size * 0.15f;
|
|
||||||
stellarRemnantController.SetSurfaceSize(wdSurfaceSize);
|
|
||||||
stellarRemnantController.SetSurfaceGravity(body.Config.Base.surfaceGravity * 1.4f);
|
|
||||||
stellarRemnantController.SetSphereOfInfluence(wdSurfaceSize * 2);
|
|
||||||
ss.radius = (wdSurfaceSize * 2) + 10;
|
|
||||||
stellarRemnantController.SetAlignmentRadius(wdSurfaceSize * 1.5f);
|
|
||||||
stellarRemnantController.SetSiderealPeriod(body.Config.Orbit.siderealPeriod);
|
|
||||||
stellarRemnantController.SetStarController(StarBuilder.Make(go, srSector, new External.Modules.VariableSize.StarModule
|
|
||||||
{
|
|
||||||
size = wdSurfaceSize,
|
|
||||||
tint = MColor.white,
|
|
||||||
endTint = MColor.black
|
|
||||||
}, body.Mod, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError($"Couldn't make stellar remnant for [{body.Config.name}]:\n{ex}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -69,10 +69,6 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Does this config describe a quantum state of a custom planet defined in another file?"
|
"description": "Does this config describe a quantum state of a custom planet defined in another file?"
|
||||||
},
|
},
|
||||||
"isStellarRemnant": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "Does this config describe a stellar remnant of a custom star defined in another file?"
|
|
||||||
},
|
|
||||||
"Lava": {
|
"Lava": {
|
||||||
"description": "Add lava to this planet",
|
"description": "Add lava to this planet",
|
||||||
"$ref": "#/definitions/LavaModule"
|
"$ref": "#/definitions/LavaModule"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user