Merge branch 'xen-42:dev' into dev

This commit is contained in:
TerrificTrifid 2022-08-10 00:05:40 -05:00 committed by GitHub
commit cc397f89fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 173 additions and 54 deletions

View File

@ -137,10 +137,12 @@ namespace NewHorizons.Builder.Body
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.atmosphere = sunAtmosphere; controller.atmosphere = sunAtmosphere;
controller.controller = starController;
controller.supernova = supernova; controller.supernova = supernova;
controller.StartColour = starModule.tint; controller.StartColour = starModule.tint;
controller.EndColour = starModule.endTint; controller.EndColour = starModule.endTint;
controller.WillExplode = starModule.goSupernova; controller.WillExplode = starModule.goSupernova;
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))
{ {
@ -173,6 +175,7 @@ namespace NewHorizons.Builder.Body
public static GameObject MakeStarProxy(GameObject planet, GameObject proxyGO, StarModule starModule, IModBehaviour mod) public static GameObject MakeStarProxy(GameObject planet, GameObject proxyGO, StarModule starModule, IModBehaviour mod)
{ {
var starGO = MakeStarGraphics(proxyGO, null, starModule, mod); var starGO = MakeStarGraphics(proxyGO, null, starModule, mod);
var ramp = starGO.GetComponentInChildren<TessellatedSphereRenderer>().sharedMaterial.GetTexture(ColorRamp);
var supernova = MakeSupernova(starGO, starModule); var supernova = MakeSupernova(starGO, starModule);
@ -185,6 +188,13 @@ namespace NewHorizons.Builder.Body
controller.supernova = supernova; controller.supernova = supernova;
controller.StartColour = starModule.tint; controller.StartColour = starModule.tint;
controller.EndColour = starModule.endTint; controller.EndColour = starModule.endTint;
controller.WillExplode = starModule.goSupernova;
controller.lifespan = starModule.lifespan;
controller.normalRamp = !string.IsNullOrEmpty(starModule.starRampTexture) ? ImageUtilities.GetTexture(mod, starModule.starRampTexture) : ramp;
if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture))
{
controller.collapseRamp = ImageUtilities.GetTexture(mod, starModule.starCollapseRampTexture);
}
controller.enabled = true; controller.enabled = true;
starGO.SetActive(true); starGO.SetActive(true);

View File

@ -14,6 +14,7 @@ namespace NewHorizons.Components.SizeControllers
public class StarEvolutionController : SizeController public class StarEvolutionController : SizeController
{ {
public GameObject atmosphere; public GameObject atmosphere;
public StarController controller;
public SupernovaEffectController supernova; public SupernovaEffectController supernova;
public bool WillExplode { get; set; } public bool WillExplode { get; set; }
public MColor StartColour { get; set; } public MColor StartColour { get; set; }
@ -29,6 +30,8 @@ namespace NewHorizons.Components.SizeControllers
private HeatHazardVolume _heatVolume; private HeatHazardVolume _heatVolume;
private DestructionVolume _destructionVolume; private DestructionVolume _destructionVolume;
private SolarFlareEmitter _flareEmitter; private SolarFlareEmitter _flareEmitter;
private MapMarker _mapMarker;
private OWRigidbody _rigidbody;
private bool _isCollapsing; private bool _isCollapsing;
private float _collapseStartSize; private float _collapseStartSize;
@ -36,7 +39,6 @@ namespace NewHorizons.Components.SizeControllers
public float collapseTime = 10f; // seconds public float collapseTime = 10f; // seconds
public float lifespan = 22f; // minutes public float lifespan = 22f; // minutes
private float _age;
private bool _isSupernova; private bool _isSupernova;
private float _supernovaStartTime; private float _supernovaStartTime;
@ -65,6 +67,9 @@ namespace NewHorizons.Components.SizeControllers
private void Start() private void Start()
{ {
_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);
_collapseEndSurfaceMaterial = new Material(sun._collapseEndSurfaceMaterial); _collapseEndSurfaceMaterial = new Material(sun._collapseEndSurfaceMaterial);
@ -110,7 +115,7 @@ namespace NewHorizons.Components.SizeControllers
else else
{ {
_endColour = EndColour.ToColor(); _endColour = EndColour.ToColor();
_endSurfaceMaterial.color = _startColour * 4.5948f; _endSurfaceMaterial.color = _endColour * 4.5948f;
} }
_heatVolume = GetComponentInChildren<HeatHazardVolume>(); _heatVolume = GetComponentInChildren<HeatHazardVolume>();
@ -122,8 +127,6 @@ namespace NewHorizons.Components.SizeControllers
_atmosphereRenderers = atmosphere?.transform?.Find("AtmoSphere")?.GetComponentsInChildren<MeshRenderer>(); _atmosphereRenderers = atmosphere?.transform?.Find("AtmoSphere")?.GetComponentsInChildren<MeshRenderer>();
} }
if (WillExplode) GlobalMessenger.AddListener("TriggerSupernova", StartCollapse);
if (scaleCurve != null) if (scaleCurve != null)
{ {
maxScale = scaleCurve.keys.Select(x => x.value).Max() * size; maxScale = scaleCurve.keys.Select(x => x.value).Max() * size;
@ -143,7 +146,6 @@ namespace NewHorizons.Components.SizeControllers
public void OnDestroy() public void OnDestroy()
{ {
if (WillExplode) GlobalMessenger.RemoveListener("TriggerSupernova", StartCollapse);
} }
public void SetProxy(StarEvolutionController proxy) public void SetProxy(StarEvolutionController proxy)
@ -157,8 +159,8 @@ namespace NewHorizons.Components.SizeControllers
// 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 the age 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 = _age / (lifespan * 60f); 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)
@ -211,6 +213,22 @@ namespace NewHorizons.Components.SizeControllers
if (Time.time > _supernovaStartTime + 45f) if (Time.time > _supernovaStartTime + 45f)
{ {
if (_rigidbody != null)
{
ReferenceFrameTracker referenceFrameTracker = Locator.GetPlayerBody().GetComponent<ReferenceFrameTracker>();
if (referenceFrameTracker.GetReferenceFrame() != null && referenceFrameTracker.GetReferenceFrame().GetOWRigidBody() == _rigidbody) referenceFrameTracker.UntargetReferenceFrame();
_rigidbody._isTargetable = false;
if (_rigidbody._attachedRFVolume != null)
{
_rigidbody._attachedRFVolume._minColliderRadius = 0;
_rigidbody._attachedRFVolume._maxColliderRadius = 0;
}
}
if (_mapMarker != null) _mapMarker.DisableMarker();
if (controller != null) StarLightController.RemoveStar(controller);
// Just turn off the star entirely // Just turn off the star entirely
base.gameObject.SetActive(false); base.gameObject.SetActive(false);
} }
@ -218,6 +236,8 @@ namespace NewHorizons.Components.SizeControllers
public void StartCollapse() public void StartCollapse()
{ {
if (_isCollapsing) return;
Logger.LogVerbose($"{gameObject.transform.root.name} started collapse"); Logger.LogVerbose($"{gameObject.transform.root.name} started collapse");
_isCollapsing = true; _isCollapsing = true;
@ -230,6 +250,8 @@ namespace NewHorizons.Components.SizeControllers
public void StopCollapse() public void StopCollapse()
{ {
if (!_isCollapsing) return;
Logger.LogVerbose($"{gameObject.transform.root.name} stopped collapse"); Logger.LogVerbose($"{gameObject.transform.root.name} stopped collapse");
_isCollapsing = false; _isCollapsing = false;
@ -240,6 +262,8 @@ namespace NewHorizons.Components.SizeControllers
public void StartSupernova() public void StartSupernova()
{ {
if (_isSupernova) return;
Logger.LogVerbose($"{gameObject.transform.root.name} started supernova"); Logger.LogVerbose($"{gameObject.transform.root.name} started supernova");
SupernovaStart.Invoke(); SupernovaStart.Invoke();
@ -248,10 +272,14 @@ namespace NewHorizons.Components.SizeControllers
_supernovaStartTime = Time.time; _supernovaStartTime = Time.time;
if (atmosphere != null) atmosphere.SetActive(false); if (atmosphere != null) atmosphere.SetActive(false);
if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova; if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova;
if (_proxy != null) _proxy.StartSupernova();
} }
public void StopSupernova() public void StopSupernova()
{ {
if (!_isSupernova) return;
Logger.LogVerbose($"{gameObject.transform.root.name} stopped supernova"); Logger.LogVerbose($"{gameObject.transform.root.name} stopped supernova");
supernova.enabled = false; supernova.enabled = false;
@ -267,12 +295,12 @@ namespace NewHorizons.Components.SizeControllers
transform.localScale = Vector3.one; transform.localScale = Vector3.one;
supernova._surface._materials[0] = _surfaceMaterial; supernova._surface._materials[0] = _surfaceMaterial;
supernova._surface.transform.localScale = Vector3.one; supernova._surface.transform.localScale = Vector3.one;
if (_proxy != null) _proxy.StopSupernova();
} }
protected new void FixedUpdate() protected new void FixedUpdate()
{ {
_age += Time.deltaTime;
// If we've gone supernova and its been 45 seconds that means it has faded out and is gone // If we've gone supernova and its been 45 seconds that means it has faded out and is gone
// The 45 is from the animation curve used for the supernova alpha // The 45 is from the animation curve used for the supernova alpha
if (_isSupernova) if (_isSupernova)
@ -285,6 +313,7 @@ namespace NewHorizons.Components.SizeControllers
{ {
base.FixedUpdate(); base.FixedUpdate();
UpdateMainSequence(); UpdateMainSequence();
if (WillExplode && (TimeLoop.GetMinutesElapsed() / lifespan) >= 1) StartCollapse();
} }
else else
{ {

View File

@ -17,6 +17,17 @@ namespace NewHorizons.External.Configs
[JsonObject(Title = "Celestial Body")] [JsonObject(Title = "Celestial Body")]
public class PlanetConfig public class PlanetConfig
{ {
/// <summary>
/// Unique name of your planet
/// </summary>
[Required]
public string name;
/// <summary>
/// Unique star system containing your planet. If you set this to be a custom solar system remember to add a Spawn module to one of the bodies, or else you can't get to the system.
/// </summary>
[DefaultValue("SolarSystem")] public string starSystem = "SolarSystem";
/// <summary> /// <summary>
/// Generate asteroids around this body /// Generate asteroids around this body
/// </summary> /// </summary>
@ -45,7 +56,7 @@ namespace NewHorizons.External.Configs
/// <summary> /// <summary>
/// Should this planet ever be shown on the title screen? /// Should this planet ever be shown on the title screen?
/// </summary> /// </summary>
public bool canShowOnTitle = true; [DefaultValue(true)] public bool canShowOnTitle = true;
#region Obsolete #region Obsolete
@ -94,12 +105,6 @@ namespace NewHorizons.External.Configs
/// </summary> /// </summary>
public LavaModule Lava; public LavaModule Lava;
/// <summary>
/// Unique name of your planet
/// </summary>
[Required]
public string name;
/// <summary> /// <summary>
/// Describes this Body's orbit (or lack there of) /// Describes this Body's orbit (or lack there of)
/// </summary> /// </summary>
@ -150,11 +155,6 @@ namespace NewHorizons.External.Configs
/// </summary> /// </summary>
public StarModule Star; public StarModule Star;
/// <summary>
/// Unique star system containing your planet. If you set this to be a custom solar system remember to add a Spawn module to one of the bodies, or else you can't get to the system.
/// </summary>
[DefaultValue("SolarSystem")] public string starSystem = "SolarSystem";
/// <summary> /// <summary>
/// Version of New Horizons this config is using (Doesn't do anything) /// Version of New Horizons this config is using (Doesn't do anything)
/// </summary> /// </summary>

View File

@ -35,6 +35,11 @@ namespace NewHorizons.External.Configs
/// </summary> /// </summary>
public string factRequiredForWarp; public string factRequiredForWarp;
/// <summary>
/// The duration of the time loop in minutes. This is the time the sun explodes. End Times plays 85 seconds before this time, and your memories get sent back about 40 seconds after this time.
/// </summary>
[DefaultValue(22f)] public float loopDuration = 22f;
/// <summary> /// <summary>
/// Should the player not be able to view the map in this system? /// Should the player not be able to view the map in this system?
/// </summary> /// </summary>
@ -209,6 +214,7 @@ namespace NewHorizons.External.Configs
canEnterViaWarpDrive = canEnterViaWarpDrive && otherConfig.canEnterViaWarpDrive; canEnterViaWarpDrive = canEnterViaWarpDrive && otherConfig.canEnterViaWarpDrive;
destroyStockPlanets = destroyStockPlanets && otherConfig.destroyStockPlanets; destroyStockPlanets = destroyStockPlanets && otherConfig.destroyStockPlanets;
enableTimeLoop = enableTimeLoop && otherConfig.enableTimeLoop; enableTimeLoop = enableTimeLoop && otherConfig.enableTimeLoop;
loopDuration = loopDuration == 22f ? otherConfig.loopDuration : loopDuration;
// If current one is null take the other // If current one is null take the other
factRequiredForWarp = string.IsNullOrEmpty(factRequiredForWarp) ? otherConfig.factRequiredForWarp : factRequiredForWarp; factRequiredForWarp = string.IsNullOrEmpty(factRequiredForWarp) ? otherConfig.factRequiredForWarp : factRequiredForWarp;

View File

@ -76,7 +76,6 @@ namespace NewHorizons.External.Modules
/// The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius. /// The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.
/// </summary> /// </summary>
[Range(0f, double.MaxValue)] [Range(0f, double.MaxValue)]
[DefaultValue(5000f)]
public float semiMajorAxis { get; set; } public float semiMajorAxis { get; set; }
/// <summary> /// <summary>

View File

@ -23,7 +23,7 @@ namespace NewHorizons.External.Modules
/// <summary> /// <summary>
/// Radius of the brackets that show up when you target this. Defaults to the sphere of influence. /// Radius of the brackets that show up when you target this. Defaults to the sphere of influence.
/// </summary> /// </summary>
[DefaultValue(-1)] public float bracketRadius = -1; [DefaultValue(-1f)] public float bracketRadius = -1f;
/// <summary> /// <summary>
/// If it should be targetable even when super close. /// If it should be targetable even when super close.

View File

@ -20,7 +20,7 @@ namespace NewHorizons.External.Modules
/// <summary> /// <summary>
/// Describe what this planet looks and like in map mode /// Describe what this planet looks and like in map mode
/// </summary> /// </summary>
public MapModeInfo mapMode = new MapModeInfo(); public MapModeInfo mapMode;
/// <summary> /// <summary>
/// A path to the folder where entry sprites are stored. /// A path to the folder where entry sprites are stored.

View File

@ -9,15 +9,21 @@ namespace NewHorizons.External.Modules.VariableSize
public class StarModule : VariableSizeModule public class StarModule : VariableSizeModule
{ {
/// <summary> /// <summary>
/// Colour of the star at the end of its life. /// Colour of the star at the end of its lifespan.
/// </summary> /// </summary>
public MColor endTint; public MColor endTint;
/// <summary> /// <summary>
/// Should this star explode after 22 minutes? /// Should this star explode at the end of its lifespan?
/// </summary> /// </summary>
[DefaultValue(true)] public bool goSupernova = true; [DefaultValue(true)] public bool goSupernova = true;
/// <summary>
/// How long in minutes this star will last until it supernovas.
/// </summary>
[DefaultValue(22f)]
public float lifespan = 22f;
/// <summary> /// <summary>
/// Should we add a star controller to this body? If you want clouds to work on a binary brown dwarf system, set this to false. /// Should we add a star controller to this body? If you want clouds to work on a binary brown dwarf system, set this to false.
/// </summary> /// </summary>

View File

@ -31,6 +31,11 @@ namespace NewHorizons.Handlers
timeLoopController.AddComponent<TimeLoopController>(); timeLoopController.AddComponent<TimeLoopController>();
} }
if (system.Config.loopDuration != 22f)
{
TimeLoopUtilities.SetLoopDuration(system.Config.loopDuration);
}
if (!string.IsNullOrEmpty(system.Config.travelAudio)) if (!string.IsNullOrEmpty(system.Config.travelAudio))
{ {
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._travelSource, system.Config.travelAudio, system.Mod)); Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._travelSource, system.Config.travelAudio, system.Mod));

View File

@ -42,7 +42,7 @@ namespace NewHorizons
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>(); public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>();
public static List<IModBehaviour> MountedAddons = new List<IModBehaviour>(); public static List<IModBehaviour> MountedAddons = new List<IModBehaviour>();
public static float SecondsLeftInLoop = -1; public static float SecondsElapsedInLoop = -1;
public static bool IsSystemReady { get; private set; } public static bool IsSystemReady { get; private set; }
public static float FurthestOrbit { get; set; } = 50000f; public static float FurthestOrbit { get; set; } = 50000f;
@ -239,9 +239,9 @@ namespace NewHorizons
} }
// Set time loop stuff if its enabled and if we're warping to a new place // Set time loop stuff if its enabled and if we're warping to a new place
if (IsChangingStarSystem && (SystemDict[_currentStarSystem].Config.enableTimeLoop || _currentStarSystem == "SolarSystem") && SecondsLeftInLoop > 0f) if (IsChangingStarSystem && (SystemDict[_currentStarSystem].Config.enableTimeLoop || _currentStarSystem == "SolarSystem") && SecondsElapsedInLoop > 0f)
{ {
TimeLoop.SetSecondsRemaining(SecondsLeftInLoop); TimeLoopUtilities.SetSecondsElapsed(SecondsElapsedInLoop);
// Prevent the OPC from firing // Prevent the OPC from firing
var launchController = GameObject.FindObjectOfType<OrbitalProbeLaunchController>(); var launchController = GameObject.FindObjectOfType<OrbitalProbeLaunchController>();
if (launchController != null) if (launchController != null)
@ -258,7 +258,7 @@ namespace NewHorizons
} }
// Reset this // Reset this
SecondsLeftInLoop = -1; SecondsElapsedInLoop = -1;
IsChangingStarSystem = false; IsChangingStarSystem = false;
@ -607,13 +607,13 @@ namespace NewHorizons
if (newStarSystem == "EyeOfTheUniverse") if (newStarSystem == "EyeOfTheUniverse")
{ {
PlayerData.SaveWarpedToTheEye(TimeLoop.GetSecondsRemaining()); PlayerData.SaveWarpedToTheEye(TimeLoopUtilities.GetVanillaSecondsRemaining());
sceneToLoad = OWScene.EyeOfTheUniverse; sceneToLoad = OWScene.EyeOfTheUniverse;
} }
else else
{ {
if (SystemDict[_currentStarSystem].Config.enableTimeLoop) SecondsLeftInLoop = TimeLoop.GetSecondsRemaining(); if (SystemDict[_currentStarSystem].Config.enableTimeLoop) SecondsElapsedInLoop = TimeLoop.GetSecondsElapsed();
else SecondsLeftInLoop = -1; else SecondsElapsedInLoop = -1;
sceneToLoad = OWScene.SolarSystem; sceneToLoad = OWScene.SolarSystem;
} }

View File

@ -24,7 +24,7 @@ namespace NewHorizons.Patches
VesselWarpController.s_playerWarpLocation = new RelativeLocationData(Locator.GetPlayerBody(), __instance.transform); VesselWarpController.s_playerWarpLocation = new RelativeLocationData(Locator.GetPlayerBody(), __instance.transform);
VesselWarpController.s_relativeLocationSaved = !debugWarp; VesselWarpController.s_relativeLocationSaved = !debugWarp;
if (!Main.Instance.IsWarpingFromVessel) if (!Main.Instance.IsWarpingFromVessel)
PlayerData.SaveWarpedToTheEye(TimeLoop.GetSecondsRemaining()); PlayerData.SaveWarpedToTheEye(TimeLoopUtilities.GetVanillaSecondsRemaining());
LoadManager.EnableAsyncLoadTransition(); LoadManager.EnableAsyncLoadTransition();
return false; return false;
} }

View File

@ -8,6 +8,16 @@
"name" "name"
], ],
"properties": { "properties": {
"name": {
"type": "string",
"description": "Unique name of your planet",
"minLength": 1
},
"starSystem": {
"type": "string",
"description": "Unique star system containing your planet. If you set this to be a custom solar system remember to add a Spawn module to one of the bodies, or else you can't get to the system.",
"default": "SolarSystem"
},
"AsteroidBelt": { "AsteroidBelt": {
"description": "Generate asteroids around this body", "description": "Generate asteroids around this body",
"$ref": "#/definitions/AsteroidBeltModule" "$ref": "#/definitions/AsteroidBeltModule"
@ -32,7 +42,8 @@
}, },
"canShowOnTitle": { "canShowOnTitle": {
"type": "boolean", "type": "boolean",
"description": "Should this planet ever be shown on the title screen?" "description": "Should this planet ever be shown on the title screen?",
"default": true
}, },
"Cloak": { "Cloak": {
"description": "Add a cloaking field to this planet", "description": "Add a cloaking field to this planet",
@ -62,11 +73,6 @@
"description": "Add lava to this planet", "description": "Add lava to this planet",
"$ref": "#/definitions/LavaModule" "$ref": "#/definitions/LavaModule"
}, },
"name": {
"type": "string",
"description": "Unique name of your planet",
"minLength": 1
},
"Orbit": { "Orbit": {
"description": "Describes this Body's orbit (or lack there of)", "description": "Describes this Body's orbit (or lack there of)",
"$ref": "#/definitions/OrbitModule" "$ref": "#/definitions/OrbitModule"
@ -110,11 +116,6 @@
"description": "Make this body a star", "description": "Make this body a star",
"$ref": "#/definitions/StarModule" "$ref": "#/definitions/StarModule"
}, },
"starSystem": {
"type": "string",
"description": "Unique star system containing your planet. If you set this to be a custom solar system remember to add a Spawn module to one of the bodies, or else you can't get to the system.",
"default": "SolarSystem"
},
"version": { "version": {
"type": "string", "type": "string",
"description": "Version of New Horizons this config is using (Doesn't do anything)" "description": "Version of New Horizons this config is using (Doesn't do anything)"
@ -2053,7 +2054,7 @@
"type": "number", "type": "number",
"description": "Radius of the brackets that show up when you target this. Defaults to the sphere of influence.", "description": "Radius of the brackets that show up when you target this. Defaults to the sphere of influence.",
"format": "float", "format": "float",
"default": -1 "default": -1.0
}, },
"targetWhenClose": { "targetWhenClose": {
"type": "boolean", "type": "boolean",
@ -2284,14 +2285,20 @@
} }
}, },
"endTint": { "endTint": {
"description": "Colour of the star at the end of its life.", "description": "Colour of the star at the end of its lifespan.",
"$ref": "#/definitions/MColor" "$ref": "#/definitions/MColor"
}, },
"goSupernova": { "goSupernova": {
"type": "boolean", "type": "boolean",
"description": "Should this star explode after 22 minutes?", "description": "Should this star explode at the end of its lifespan?",
"default": true "default": true
}, },
"lifespan": {
"type": "number",
"description": "How long in minutes this star will last until it supernovas.",
"format": "float",
"default": 22.0
},
"hasStarController": { "hasStarController": {
"type": "boolean", "type": "boolean",
"description": "Should we add a star controller to this body? If you want clouds to work on a binary brown dwarf system, set this to false.", "description": "Should we add a star controller to this body? If you want clouds to work on a binary brown dwarf system, set this to false.",

View File

@ -24,6 +24,12 @@
"type": "string", "type": "string",
"description": "Set to the FactID that must be revealed before it can be warped to. Don't set `CanEnterViaWarpDrive` to `false` if\nyou're using this, that would make no sense." "description": "Set to the FactID that must be revealed before it can be warped to. Don't set `CanEnterViaWarpDrive` to `false` if\nyou're using this, that would make no sense."
}, },
"loopDuration": {
"type": "number",
"description": "The duration of the time loop in minutes. This is the time the sun explodes. End Times plays 85 seconds before this time, and your memories get sent back about 40 seconds after this time.",
"format": "float",
"default": 22.0
},
"mapRestricted": { "mapRestricted": {
"type": "boolean", "type": "boolean",
"description": "Should the player not be able to view the map in this system?" "description": "Should the player not be able to view the map in this system?"

View File

@ -225,9 +225,7 @@ namespace NewHorizons.Utility.DebugMenu
var relativePath = filePath.Replace(loadedMod.ModHelper.Manifest.ModFolderPath, ""); var relativePath = filePath.Replace(loadedMod.ModHelper.Manifest.ModFolderPath, "");
var json = JsonConvert.SerializeObject(loadedConfigFiles[filePath], jsonSettings); var json = loadedConfigFiles[filePath].ToSerializedJson();
// Add the schema line
json = "{\n\t\"$schema\": \"https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/body_schema.json\"," + json.Substring(1);
try try
{ {

View File

@ -49,7 +49,7 @@ namespace NewHorizons.Utility.DebugUtilities
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem); Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem);
Main.SecondsLeftInLoop = -1f; Main.SecondsElapsedInLoop = -1f;
} }
} }
} }

View File

@ -1,15 +1,48 @@
using NewHorizons.External.Configs;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using UnityEngine; using UnityEngine;
using NomaiCoordinates = NewHorizons.External.Configs.StarSystemConfig.NomaiCoordinates; using NomaiCoordinates = NewHorizons.External.Configs.StarSystemConfig.NomaiCoordinates;
namespace NewHorizons.Utility namespace NewHorizons.Utility
{ {
public static class NewHorizonsExtensions public static class NewHorizonsExtensions
{ {
private static JsonSerializer jsonSerializer = new JsonSerializer
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore,
Formatting = Formatting.Indented,
};
private static StringBuilder stringBuilder = new StringBuilder();
public static string ToSerializedJson(this PlanetConfig planetConfig)
{
string json = "{}";
using (StringWriter stringWriter = new StringWriter(stringBuilder))
{
using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)
{
Formatting = Formatting.Indented,
IndentChar = '\t',
Indentation = 1
})
{
jsonSerializer.Serialize(jsonTextWriter, planetConfig);
json = "{\n\t\"$schema\": \"https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/body_schema.json\"," + stringBuilder.ToString().Substring(1);
stringBuilder.Clear();
}
}
return json;
}
public static MVector3 ToMVector3(this Vector3 vector3) public static MVector3 ToMVector3(this Vector3 vector3)
{ {
return new MVector3(vector3.x, vector3.y, vector3.z); return new MVector3(vector3.x, vector3.y, vector3.z);

View File

@ -0,0 +1,15 @@
using UnityEngine;
namespace NewHorizons.Utility
{
public static class TimeLoopUtilities
{
public const float LOOP_DURATION_IN_SECONDS = TimeLoop.LOOP_DURATION_IN_MINUTES * 60;
public static void SetLoopDuration(float minutes) => TimeLoop._loopDuration = minutes * 60f;
public static void SetSecondsElapsed(float secondsElapsed) => TimeLoop._timeOffset = secondsElapsed - Time.timeSinceLevelLoad;
public static float GetMinutesRemaining() => TimeLoop.GetSecondsRemaining() / 60f;
public static float GetVanillaSecondsRemaining() => LOOP_DURATION_IN_SECONDS - TimeLoop.GetSecondsElapsed();
public static float GetVanillaMinutesRemaining() => GetVanillaSecondsRemaining() / 60f;
public static float GetVanillaFractionElapsed() => TimeLoop.GetSecondsElapsed() / LOOP_DURATION_IN_SECONDS;
}
}

View File

@ -78,6 +78,11 @@ public static class SchemaExporter
{"description", _description} {"description", _description}
}); });
if (_title == "Celestial Body Schema")
{
schema.Definitions["OrbitModule"].Properties["semiMajorAxis"].Default = 5000f;
}
if (_title == "Star System Schema") if (_title == "Star System Schema")
{ {
schema.Definitions["NomaiCoordinates"].Properties["x"].UniqueItems = true; schema.Definitions["NomaiCoordinates"].Properties["x"].UniqueItems = true;