Add mod unique id to NHAstroObject

This commit is contained in:
Nick 2024-04-11 23:50:27 -04:00
parent 641b1d7b97
commit 0d99669f81
3 changed files with 14 additions and 5 deletions

View File

@ -1,6 +1,6 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.External.Configs; using NewHorizons.External;
using NewHorizons.Utility.OWML; using NewHorizons.Utility.OWML;
using UnityEngine; using UnityEngine;
@ -8,9 +8,13 @@ namespace NewHorizons.Builder.General
{ {
public static class AstroObjectBuilder public static class AstroObjectBuilder
{ {
public static NHAstroObject Make(GameObject body, AstroObject primaryBody, PlanetConfig config, bool isVanilla) public static NHAstroObject Make(GameObject body, AstroObject primaryBody, NewHorizonsBody nhBody, bool isVanilla)
{ {
NHAstroObject astroObject = body.AddComponent<NHAstroObject>(); NHAstroObject astroObject = body.AddComponent<NHAstroObject>();
astroObject.modUniqueName = nhBody.Mod.ModHelper.Manifest.UniqueName;
var config = nhBody.Config;
astroObject.isVanilla = isVanilla; astroObject.isVanilla = isVanilla;
astroObject.HideDisplayName = !config.Base.hasMapMarker; astroObject.HideDisplayName = !config.Base.hasMapMarker;
astroObject.invulnerableToSun = config.Base.invulnerableToSun; astroObject.invulnerableToSun = config.Base.invulnerableToSun;

View File

@ -14,6 +14,11 @@ namespace NewHorizons.Components.Orbital
public bool invulnerableToSun; public bool invulnerableToSun;
public bool isVanilla; public bool isVanilla;
/// <summary>
/// The unique name of the mod that created this body or, if it is an existing body being edited, the last mod to edit it
/// </summary>
public string modUniqueName;
public void SetOrbitalParametersFromConfig(OrbitModule orbit) public void SetOrbitalParametersFromConfig(OrbitModule orbit)
{ {
SetOrbitalParametersFromTrueAnomaly(orbit.eccentricity, orbit.semiMajorAxis, orbit.inclination, orbit.argumentOfPeriapsis, orbit.longitudeOfAscendingNode, orbit.trueAnomaly); SetOrbitalParametersFromTrueAnomaly(orbit.eccentricity, orbit.semiMajorAxis, orbit.inclination, orbit.argumentOfPeriapsis, orbit.longitudeOfAscendingNode, orbit.trueAnomaly);

View File

@ -371,7 +371,7 @@ namespace NewHorizons.Handlers
const float sphereOfInfluence = 2000f; const float sphereOfInfluence = 2000f;
var owRigidBody = RigidBodyBuilder.Make(go, sphereOfInfluence, body.Config); var owRigidBody = RigidBodyBuilder.Make(go, sphereOfInfluence, body.Config);
var ao = AstroObjectBuilder.Make(go, null, body.Config, false); var ao = AstroObjectBuilder.Make(go, null, body, false);
var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence); var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence);
ao._rootSector = sector; ao._rootSector = sector;
@ -447,7 +447,7 @@ namespace NewHorizons.Handlers
var sphereOfInfluence = GetSphereOfInfluence(body); var sphereOfInfluence = GetSphereOfInfluence(body);
var owRigidBody = RigidBodyBuilder.Make(go, sphereOfInfluence, body.Config); var owRigidBody = RigidBodyBuilder.Make(go, sphereOfInfluence, body.Config);
var ao = AstroObjectBuilder.Make(go, primaryBody, body.Config, false); var ao = AstroObjectBuilder.Make(go, primaryBody, body, false);
var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence * 2f); var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence * 2f);
ao._rootSector = sector; ao._rootSector = sector;
@ -788,7 +788,7 @@ namespace NewHorizons.Handlers
} }
// Just destroy the existing AO after copying everything over // Just destroy the existing AO after copying everything over
var newAO = AstroObjectBuilder.Make(go, primary, body.Config, true); var newAO = AstroObjectBuilder.Make(go, primary, body, true);
newAO._gravityVolume = ao._gravityVolume; newAO._gravityVolume = ao._gravityVolume;
newAO._moon = ao._moon; newAO._moon = ao._moon;
newAO._name = ao._name; newAO._name = ao._name;