mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Just use separate config
>:(
This commit is contained in:
parent
39f1ad6ac1
commit
a12b714f28
@ -18,14 +18,15 @@ namespace NewHorizons.Builder.Body
|
||||
{
|
||||
public static class StellarRemnantBuilder
|
||||
{
|
||||
public static void Make(GameObject go, OWRigidbody rb, PlanetConfig config, IModBehaviour mod, float sphereOfInfluence)
|
||||
public static void Make(NewHorizonsBody star, GameObject go, OWRigidbody rb, IModBehaviour mod, NewHorizonsBody stellarRemnant = null)
|
||||
{
|
||||
Logger.Log($"Creating stellar remnant for [{config.name}]");
|
||||
Logger.Log($"Creating stellar remnant for [{star.Config.name}]");
|
||||
try
|
||||
{
|
||||
var starModule = config.Star;
|
||||
var config = star.Config;
|
||||
var starModule = star.Config.Star;
|
||||
var size = starModule.size;
|
||||
var sector = SectorBuilder.Make(go, rb, sphereOfInfluence);
|
||||
var sector = SectorBuilder.Make(go, rb, 0);
|
||||
sector.name = "StellarRemnant";
|
||||
var ss = sector.GetComponent<SphereShape>();
|
||||
|
||||
@ -36,21 +37,19 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
sector.gameObject.SetActive(false);
|
||||
|
||||
if (starModule.stellarRemnant != null)
|
||||
if (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.SetSurfaceSize(stellarRemnant.Config.Base.surfaceSize);
|
||||
stellarRemnantController.SetSurfaceGravity(stellarRemnant.Config.Base.surfaceGravity);
|
||||
stellarRemnantController.SetSiderealPeriod(stellarRemnant.Config.Orbit.siderealPeriod);
|
||||
var srSphereOfInfluence = PlanetCreationHandler.GetSphereOfInfluence(stellarRemnant);
|
||||
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;
|
||||
var alignmentRadius = stellarRemnant.Config.Atmosphere?.clouds?.outerCloudRadius ?? 1.5f * stellarRemnant.Config.Base.surfaceSize;
|
||||
if (stellarRemnant.Config.Base.surfaceGravity == 0) alignmentRadius = 0;
|
||||
stellarRemnantController.SetAlignmentRadius(alignmentRadius);
|
||||
PlanetCreationHandler.SharedGenerateBody(srBody, go, sector, rb, true);
|
||||
PlanetCreationHandler.SharedGenerateBody(stellarRemnant, go, sector, rb, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -127,7 +126,7 @@ namespace NewHorizons.Builder.Body
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Couldn't make stellar remnant for [{config.name}]:\n{ex}");
|
||||
Logger.LogError($"Couldn't make stellar remnant for [{star.Config.name}]:\n{ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
NewHorizons/External/Configs/PlanetConfig.cs
vendored
5
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -100,6 +100,11 @@ namespace NewHorizons.External.Configs
|
||||
/// </summary>
|
||||
public bool isQuantumState;
|
||||
|
||||
/// <summary>
|
||||
/// Does this config describe a stellar remnant of a custom star defined in another file?
|
||||
/// </summary>
|
||||
public bool isStellarRemnant;
|
||||
|
||||
/// <summary>
|
||||
/// Add lava to this planet
|
||||
/// </summary>
|
||||
|
||||
@ -97,113 +97,6 @@ namespace NewHorizons.External.Modules.VariableSize
|
||||
/// 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))]
|
||||
|
||||
@ -200,6 +200,10 @@ namespace NewHorizons.Handlers
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (body.Config.isStellarRemnant)
|
||||
{
|
||||
//Skip
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBody(body, existingPlanet);
|
||||
@ -218,6 +222,10 @@ namespace NewHorizons.Handlers
|
||||
// If the ground state object isn't made yet do it later
|
||||
_nextPassBodies.Add(body);
|
||||
}
|
||||
else if (body.Config.isStellarRemnant)
|
||||
{
|
||||
//Skip
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
@ -500,7 +508,7 @@ namespace NewHorizons.Handlers
|
||||
else
|
||||
{
|
||||
StarLightController.AddStar(StarBuilder.Make(go, sector, body.Config.Star, body.Mod, false));
|
||||
StellarRemnantBuilder.Make(go, rb, body.Config, body.Mod, sphereOfInfluence);
|
||||
StellarRemnantBuilder.Make(body, go, rb, body.Mod, Main.BodyDict[body.Config.starSystem].Where(x => x.Config.name == body.Config.name && body.Config.isStellarRemnant).FirstOrDefault());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,6 +69,10 @@
|
||||
"type": "boolean",
|
||||
"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": {
|
||||
"description": "Add lava to this planet",
|
||||
"$ref": "#/definitions/LavaModule"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user