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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace NewHorizons.External.Configs
|
namespace NewHorizons.External.Configs
|
||||||
{
|
{
|
||||||
@ -25,9 +23,8 @@ namespace NewHorizons.External.Configs
|
|||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unique name of your planet
|
/// Unique name of your planet. If not specified, the file name (without the extension) is used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required]
|
|
||||||
public string name;
|
public string name;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -16,6 +16,11 @@ namespace NewHorizons.External.Configs
|
|||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class StarSystemConfig
|
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>
|
/// <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?
|
/// 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>
|
/// </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 NewHorizons.Utility.OWML;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -16,6 +17,12 @@ namespace NewHorizons.External
|
|||||||
Mod = mod;
|
Mod = mod;
|
||||||
RelativePath = relativePath;
|
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();
|
Migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -173,7 +173,7 @@ namespace NewHorizons
|
|||||||
|
|
||||||
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
||||||
BodyDict["EyeOfTheUniverse"] = new List<NewHorizonsBody>(); // Keep this empty tho fr
|
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 =
|
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 =
|
Config =
|
||||||
{
|
{
|
||||||
@ -677,8 +677,15 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Load
|
#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.Migrate();
|
||||||
starSystemConfig.FixCoordinates();
|
starSystemConfig.FixCoordinates();
|
||||||
|
|
||||||
@ -748,13 +755,12 @@ namespace NewHorizons
|
|||||||
|
|
||||||
foreach (var file in systemFiles)
|
foreach (var file in systemFiles)
|
||||||
{
|
{
|
||||||
var starSystemName = Path.GetFileNameWithoutExtension(file);
|
|
||||||
|
|
||||||
NHLogger.LogVerbose($"Loading system {starSystemName}");
|
|
||||||
|
|
||||||
var relativePath = file.Replace(folder, "");
|
var relativePath = file.Replace(folder, "");
|
||||||
|
|
||||||
|
NHLogger.LogVerbose($"Loading system {Path.GetFileNameWithoutExtension(relativePath)}");
|
||||||
|
|
||||||
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(relativePath, false);
|
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(relativePath, false);
|
||||||
LoadStarSystemConfig(starSystemName, starSystemConfig, relativePath, mod);
|
LoadStarSystemConfig(starSystemConfig, relativePath, mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Directory.Exists(planetsFolder))
|
if (Directory.Exists(planetsFolder))
|
||||||
@ -903,11 +909,7 @@ namespace NewHorizons
|
|||||||
{
|
{
|
||||||
if (!SystemDict.ContainsKey(config.starSystem))
|
if (!SystemDict.ContainsKey(config.starSystem))
|
||||||
{
|
{
|
||||||
// Since we didn't load it earlier there shouldn't be a star system config
|
var starSystemConfig = new StarSystemConfig() { name = config.starSystem };
|
||||||
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?");
|
|
||||||
|
|
||||||
starSystemConfig.Migrate();
|
starSystemConfig.Migrate();
|
||||||
starSystemConfig.FixCoordinates();
|
starSystemConfig.FixCoordinates();
|
||||||
|
|
||||||
|
|||||||
@ -261,7 +261,8 @@ namespace NewHorizons
|
|||||||
public void DefineStarSystem(string name, string config, IModBehaviour mod)
|
public void DefineStarSystem(string name, string config, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
var starSystemConfig = JsonConvert.DeserializeObject<StarSystemConfig>(config);
|
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)
|
public (CharacterDialogueTree, RemoteDialogueTrigger) CreateDialogueFromXML(string textAssetID, string xml, string dialogueInfo, GameObject planetGO)
|
||||||
@ -312,6 +313,7 @@ namespace NewHorizons
|
|||||||
|
|
||||||
var system = new StarSystemConfig()
|
var system = new StarSystemConfig()
|
||||||
{
|
{
|
||||||
|
name = starSystem,
|
||||||
entryPositions = entryPositions?
|
entryPositions = entryPositions?
|
||||||
.Select((pair) => new EntryPositionInfo() { id = pair.Key, position = pair.Value })
|
.Select((pair) => new EntryPositionInfo() { id = pair.Key, position = pair.Value })
|
||||||
.ToArray(),
|
.ToArray(),
|
||||||
@ -320,7 +322,7 @@ namespace NewHorizons
|
|||||||
.ToArray()
|
.ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
Main.Instance.LoadStarSystemConfig(starSystem, system, null, mod);
|
Main.Instance.LoadStarSystemConfig(system, null, mod);
|
||||||
|
|
||||||
RumorModeBuilder.AddShipLogXML(GameObject.FindObjectOfType<ShipLogManager>(), xml, body);
|
RumorModeBuilder.AddShipLogXML(GameObject.FindObjectOfType<ShipLogManager>(), xml, body);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,10 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Describes a celestial body to generate",
|
"description": "Describes a celestial body to generate",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
|
||||||
"name"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Unique name of your planet",
|
"description": "Unique name of your planet. If not specified, the file name (without the extension) is used."
|
||||||
"minLength": 1
|
|
||||||
},
|
},
|
||||||
"starSystem": {
|
"starSystem": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -1118,7 +1114,6 @@
|
|||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.",
|
"description": "The semi-major axis of the ellipse that is the body's orbit. For a circular orbit this is the radius.",
|
||||||
"format": "float",
|
"format": "float",
|
||||||
"default": 5000.0,
|
|
||||||
"minimum": 0.0
|
"minimum": 0.0
|
||||||
},
|
},
|
||||||
"inclination": {
|
"inclination": {
|
||||||
|
|||||||
@ -5,6 +5,10 @@
|
|||||||
"description": "Configuration for a specific star system",
|
"description": "Configuration for a specific star system",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Unique name of your system. If not specified, the file name (without the extension) is used."
|
||||||
|
},
|
||||||
"freeMapAngle": {
|
"freeMapAngle": {
|
||||||
"type": "boolean",
|
"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?"
|
"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)
|
switch (_title)
|
||||||
{
|
{
|
||||||
case "Celestial Body Schema":
|
case "Celestial Body Schema":
|
||||||
schema.Definitions["OrbitModule"].Properties["semiMajorAxis"].Default = 5000f;
|
|
||||||
schema.Definitions["NomaiTextType"].Enumeration.Remove("cairn");
|
schema.Definitions["NomaiTextType"].Enumeration.Remove("cairn");
|
||||||
schema.Definitions["NomaiTextType"].EnumerationNames.Remove("Cairn");
|
schema.Definitions["NomaiTextType"].EnumerationNames.Remove("Cairn");
|
||||||
schema.Definitions["NomaiTextType"].Enumeration.Remove("cairnVariant");
|
schema.Definitions["NomaiTextType"].Enumeration.Remove("cairnVariant");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user