mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Adds solar flare module for scale, life length, time between flares. Implements #368
This commit is contained in:
parent
2fab63e83e
commit
94441dcc4b
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using NewHorizons.Components.Stars;
|
using NewHorizons.Components.Stars;
|
||||||
using NewHorizons.Utility.OuterWilds;
|
using NewHorizons.Utility.OuterWilds;
|
||||||
using NewHorizons.Utility.Files;
|
using NewHorizons.Utility.Files;
|
||||||
|
using NewHorizons.Utility.OWML;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Body
|
namespace NewHorizons.Builder.Body
|
||||||
{
|
{
|
||||||
@ -348,11 +349,19 @@ namespace NewHorizons.Builder.Body
|
|||||||
solarFlareEmitter.name = "SolarFlareEmitter";
|
solarFlareEmitter.name = "SolarFlareEmitter";
|
||||||
solarFlareEmitter.SetActive(true);
|
solarFlareEmitter.SetActive(true);
|
||||||
|
|
||||||
|
var emitter = solarFlareEmitter.GetComponent<SolarFlareEmitter>();
|
||||||
|
|
||||||
|
if (starModule.solarFlareSettings != null)
|
||||||
|
{
|
||||||
|
emitter._minTimeBetweenFlares = starModule.solarFlareSettings.minTimeBetweenFlares;
|
||||||
|
emitter._maxTimeBetweenFlares = starModule.solarFlareSettings.maxTimeBetweenFlares;
|
||||||
|
emitter._lifeLength = starModule.solarFlareSettings.lifeLength;
|
||||||
|
}
|
||||||
|
|
||||||
if (starModule.tint != null)
|
if (starModule.tint != null)
|
||||||
{
|
{
|
||||||
var flareTint = starModule.tint.ToColor();
|
emitter.tint = starModule.tint.ToColor();
|
||||||
var emitter = solarFlareEmitter.GetComponent<SolarFlareEmitter>();
|
}
|
||||||
emitter.tint = flareTint;
|
|
||||||
|
|
||||||
var material = new Material(_flareMaterial);
|
var material = new Material(_flareMaterial);
|
||||||
// Since the star isn't awake yet the controllers haven't been made
|
// Since the star isn't awake yet the controllers haven't been made
|
||||||
@ -360,17 +369,22 @@ namespace NewHorizons.Builder.Body
|
|||||||
{
|
{
|
||||||
var controller = prefab.GetComponent<SolarFlareController>();
|
var controller = prefab.GetComponent<SolarFlareController>();
|
||||||
// controller._meshRenderer doesn't exist yet since Awake hasn't been called
|
// controller._meshRenderer doesn't exist yet since Awake hasn't been called
|
||||||
|
if (starModule.tint != null)
|
||||||
|
{
|
||||||
controller.GetComponent<MeshRenderer>().sharedMaterial = material;
|
controller.GetComponent<MeshRenderer>().sharedMaterial = material;
|
||||||
controller._color = Color.white;
|
controller._color = Color.white;
|
||||||
controller._tint = flareTint;
|
controller._tint = starModule.tint.ToColor();
|
||||||
controller._scaleFactor = Vector3.one * starModule.solarFlareScaleFactor;
|
}
|
||||||
|
if (starModule.solarFlareSettings != null)
|
||||||
|
{
|
||||||
|
controller._scaleFactor = Vector3.one * starModule.solarFlareSettings.scaleFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
starGO.transform.position = rootObject.transform.position;
|
starGO.transform.position = rootObject.transform.position;
|
||||||
starGO.transform.localScale = starModule.size * Vector3.one;
|
starGO.transform.localScale = starModule.size * Vector3.one;
|
||||||
|
|
||||||
TessellatedSphereRenderer surface = sunSurface.GetComponent<TessellatedSphereRenderer>();
|
var surface = sunSurface.GetComponent<TessellatedSphereRenderer>();
|
||||||
|
|
||||||
if (starModule.tint != null)
|
if (starModule.tint != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -105,10 +105,38 @@ namespace NewHorizons.External.Modules.VariableSize
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue("default")] public StellarRemnantType stellarRemnantType = StellarRemnantType.Default;
|
[DefaultValue("default")] public StellarRemnantType stellarRemnantType = StellarRemnantType.Default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows overriding solar flare graphical settings.
|
||||||
|
/// </summary>
|
||||||
|
public SolarFlareModule solarFlareSettings;
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class SolarFlareModule
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Size multiuplier for solar flares. Defaults to 1.
|
/// Size multiuplier for solar flares. Defaults to 1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float solarFlareScaleFactor = 1f;
|
[DefaultValue(1)]
|
||||||
|
public float scaleFactor = 1f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long a solar flare is visible for. Defaults to 15.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(15f)]
|
||||||
|
public float lifeLength = 15f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Solar flares are emitted randomly. This is the minimum ammount of time between solar flares.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(5f)]
|
||||||
|
public float minTimeBetweenFlares = 5f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Solar flares are emitted randomly. This is the maximum ammount of time between solar flares.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(30f)]
|
||||||
|
public float maxTimeBetweenFlares = 30f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user