mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Consistency in Planet/System Config Name (#727)
## Improvements - Consistency between planet and system name: use config value, otherwise use file name
This commit is contained in:
commit
0d283ac9b6
5
NewHorizons/External/Configs/PlanetConfig.cs
vendored
5
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -11,9 +11,7 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.External.Configs
|
||||
{
|
||||
@ -25,9 +23,8 @@ namespace NewHorizons.External.Configs
|
||||
{
|
||||
#region Fields
|
||||
/// <summary>
|
||||
/// Unique name of your planet
|
||||
/// Unique name of your planet. If not specified, the file name (without the extension) is used.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -16,6 +16,11 @@ namespace NewHorizons.External.Configs
|
||||
[JsonObject]
|
||||
public class StarSystemConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique name of your system. If not specified, the file name (without the extension) is used.
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// In this system should the player be able to rotate their map camera freely or be stuck above the plane of the solar system?
|
||||
/// </summary>
|
||||
|
||||
7
NewHorizons/External/NewHorizonBody.cs
vendored
7
NewHorizons/External/NewHorizonBody.cs
vendored
@ -3,6 +3,7 @@ using NewHorizons.Utility.Files;
|
||||
using NewHorizons.Utility.OWML;
|
||||
using OWML.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -16,6 +17,12 @@ namespace NewHorizons.External
|
||||
Mod = mod;
|
||||
RelativePath = relativePath;
|
||||
|
||||
// Fall back to file name if name not given
|
||||
if (!string.IsNullOrEmpty(relativePath) && string.IsNullOrEmpty(config.name))
|
||||
{
|
||||
config.name = Path.GetFileNameWithoutExtension(relativePath);
|
||||
}
|
||||
|
||||
Migrate();
|
||||
}
|
||||
|
||||
|
||||
@ -173,7 +173,7 @@ namespace NewHorizons
|
||||
|
||||
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
||||
BodyDict["EyeOfTheUniverse"] = new List<NewHorizonsBody>(); // Keep this empty tho fr
|
||||
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(), "", Instance)
|
||||
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig() { name = "SolarSystem" }, "", Instance)
|
||||
{
|
||||
Config =
|
||||
{
|
||||
@ -189,7 +189,7 @@ namespace NewHorizons
|
||||
}
|
||||
}
|
||||
};
|
||||
SystemDict["EyeOfTheUniverse"] = new NewHorizonsSystem("EyeOfTheUniverse", new StarSystemConfig(), "", Instance)
|
||||
SystemDict["EyeOfTheUniverse"] = new NewHorizonsSystem("EyeOfTheUniverse", new StarSystemConfig() { name = "EyeOfTheUniverse" }, "", Instance)
|
||||
{
|
||||
Config =
|
||||
{
|
||||
@ -677,8 +677,15 @@ namespace NewHorizons
|
||||
}
|
||||
|
||||
#region Load
|
||||
public void LoadStarSystemConfig(string starSystemName, StarSystemConfig starSystemConfig, string relativePath, IModBehaviour mod)
|
||||
public void LoadStarSystemConfig(StarSystemConfig starSystemConfig, string relativePath, IModBehaviour mod)
|
||||
{
|
||||
if (string.IsNullOrEmpty(starSystemConfig.name))
|
||||
{
|
||||
starSystemConfig.name = Path.GetFileNameWithoutExtension(relativePath);
|
||||
}
|
||||
|
||||
var starSystemName = starSystemConfig.name;
|
||||
|
||||
starSystemConfig.Migrate();
|
||||
starSystemConfig.FixCoordinates();
|
||||
|
||||
@ -748,13 +755,12 @@ namespace NewHorizons
|
||||
|
||||
foreach (var file in systemFiles)
|
||||
{
|
||||
var starSystemName = Path.GetFileNameWithoutExtension(file);
|
||||
|
||||
NHLogger.LogVerbose($"Loading system {starSystemName}");
|
||||
|
||||
var relativePath = file.Replace(folder, "");
|
||||
|
||||
NHLogger.LogVerbose($"Loading system {Path.GetFileNameWithoutExtension(relativePath)}");
|
||||
|
||||
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(relativePath, false);
|
||||
LoadStarSystemConfig(starSystemName, starSystemConfig, relativePath, mod);
|
||||
LoadStarSystemConfig(starSystemConfig, relativePath, mod);
|
||||
}
|
||||
}
|
||||
if (Directory.Exists(planetsFolder))
|
||||
@ -903,11 +909,7 @@ namespace NewHorizons
|
||||
{
|
||||
if (!SystemDict.ContainsKey(config.starSystem))
|
||||
{
|
||||
// Since we didn't load it earlier there shouldn't be a star system config
|
||||
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(Path.Combine("systems", config.starSystem + ".json"), false);
|
||||
if (starSystemConfig == null) starSystemConfig = new StarSystemConfig();
|
||||
else NHLogger.LogWarning($"Loaded system config for {config.starSystem}. Why wasn't this loaded earlier?");
|
||||
|
||||
var starSystemConfig = new StarSystemConfig() { name = config.starSystem };
|
||||
starSystemConfig.Migrate();
|
||||
starSystemConfig.FixCoordinates();
|
||||
|
||||
|
||||
@ -261,7 +261,8 @@ namespace NewHorizons
|
||||
public void DefineStarSystem(string name, string config, IModBehaviour mod)
|
||||
{
|
||||
var starSystemConfig = JsonConvert.DeserializeObject<StarSystemConfig>(config);
|
||||
Main.Instance.LoadStarSystemConfig(name, starSystemConfig, null, mod);
|
||||
starSystemConfig.name = name;
|
||||
Main.Instance.LoadStarSystemConfig(starSystemConfig, null, mod);
|
||||
}
|
||||
|
||||
public (CharacterDialogueTree, RemoteDialogueTrigger) CreateDialogueFromXML(string textAssetID, string xml, string dialogueInfo, GameObject planetGO)
|
||||
@ -312,6 +313,7 @@ namespace NewHorizons
|
||||
|
||||
var system = new StarSystemConfig()
|
||||
{
|
||||
name = starSystem,
|
||||
entryPositions = entryPositions?
|
||||
.Select((pair) => new EntryPositionInfo() { id = pair.Key, position = pair.Value })
|
||||
.ToArray(),
|
||||
@ -320,7 +322,7 @@ namespace NewHorizons
|
||||
.ToArray()
|
||||
};
|
||||
|
||||
Main.Instance.LoadStarSystemConfig(starSystem, system, null, mod);
|
||||
Main.Instance.LoadStarSystemConfig(system, null, mod);
|
||||
|
||||
RumorModeBuilder.AddShipLogXML(GameObject.FindObjectOfType<ShipLogManager>(), xml, body);
|
||||
}
|
||||
|
||||
@ -4,14 +4,10 @@
|
||||
"type": "object",
|
||||
"description": "Describes a celestial body to generate",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Unique name of your planet",
|
||||
"minLength": 1
|
||||
"description": "Unique name of your planet. If not specified, the file name (without the extension) is used."
|
||||
},
|
||||
"starSystem": {
|
||||
"type": "string",
|
||||
@ -1118,7 +1114,6 @@
|
||||
"type": "number",
|
||||
"description": "The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.",
|
||||
"format": "float",
|
||||
"default": 5000.0,
|
||||
"minimum": 0.0
|
||||
},
|
||||
"inclination": {
|
||||
|
||||
@ -5,6 +5,10 @@
|
||||
"description": "Configuration for a specific star system",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Unique name of your system. If not specified, the file name (without the extension) is used."
|
||||
},
|
||||
"freeMapAngle": {
|
||||
"type": "boolean",
|
||||
"description": "In this system should the player be able to rotate their map camera freely or be stuck above the plane of the solar system?"
|
||||
|
||||
@ -81,7 +81,6 @@ public static class SchemaExporter
|
||||
switch (_title)
|
||||
{
|
||||
case "Celestial Body Schema":
|
||||
schema.Definitions["OrbitModule"].Properties["semiMajorAxis"].Default = 5000f;
|
||||
schema.Definitions["NomaiTextType"].Enumeration.Remove("cairn");
|
||||
schema.Definitions["NomaiTextType"].EnumerationNames.Remove("Cairn");
|
||||
schema.Definitions["NomaiTextType"].Enumeration.Remove("cairnVariant");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user