added staticPosition to Orbit config

This commit is contained in:
FreezeDriedMangoes 2022-07-01 14:35:56 -04:00
parent 9a3d01bc10
commit 4b25a11fde
3 changed files with 18 additions and 6 deletions

View File

@ -25,8 +25,6 @@ namespace NewHorizons.Builder.Body
//-11096.95 -22786.44 4657.534 //-11096.95 -22786.44 4657.534
//-8716.807 -22786.44 4496.394 //-8716.807 -22786.44 4496.394
private static int DIMENSION_COUNTER = 0;
// keys are all node names that have been referenced as an exit by at least one dimension but do not (yet) exist // keys are all node names that have been referenced as an exit by at least one dimension but do not (yet) exist
// values are all dimensions' warp controllers that link to a given dimension // values are all dimensions' warp controllers that link to a given dimension
@ -49,8 +47,7 @@ namespace NewHorizons.Builder.Body
dimension.name = name.Replace(" ", "").Replace("'", "") + "_Body"; dimension.name = name.Replace(" ", "").Replace("'", "") + "_Body";
// set position // set position
ao.transform.position = new Vector3(6904.48f, 17048.44f, 5574.479f) + new Vector3(0, 3000, 0)*DIMENSION_COUNTER; ao.transform.position = body.Config.Orbit.staticPosition;
DIMENSION_COUNTER++;
// fix children's names and remove base game props (mostly just bramble nodes that are children to Interactibles) and set up the OuterWarp child // fix children's names and remove base game props (mostly just bramble nodes that are children to Interactibles) and set up the OuterWarp child
var dimensionSector = SearchUtilities.FindChild(dimension, "Sector_HubDimension"); var dimensionSector = SearchUtilities.FindChild(dimension, "Sector_HubDimension");

View File

@ -1,4 +1,4 @@
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.Utility; using NewHorizons.Utility;
@ -9,6 +9,11 @@ namespace NewHorizons.External.Modules
[JsonObject] [JsonObject]
public class OrbitModule : IOrbitalParameters public class OrbitModule : IOrbitalParameters
{ {
/// <summary>
/// Specify this if you want the body to remain stationary at a given location (ie not orbit its parent). Required for Bramble dimensions
/// </summary>
public MVector3 staticPosition;
/// <summary> /// <summary>
/// The name of the body this one will orbit around /// The name of the body this one will orbit around
/// </summary> /// </summary>

View File

@ -268,6 +268,12 @@ namespace NewHorizons.Handlers
{ {
if (body.Config?.Bramble?.dimension != null) if (body.Config?.Bramble?.dimension != null)
{ {
if (body.Config?.Orbit?.staticPosition == null)
{
Logger.LogError($"Unable to build bramble dimension {body.Config?.name} because it does not have Orbit.staticPosition defined.");
return null;
}
return GenerateBrambleDimensionBody(body); return GenerateBrambleDimensionBody(body);
} }
else else
@ -379,6 +385,10 @@ namespace NewHorizons.Handlers
{ {
DetectorBuilder.Make(go, owRigidBody, primaryBody, ao, body.Config); DetectorBuilder.Make(go, owRigidBody, primaryBody, ao, body.Config);
} }
else if (body.Config.Orbit.staticPosition != null)
{
ao.transform.position = body.Config.Orbit.staticPosition;
}
if (ao.GetAstroObjectName() == AstroObject.Name.CustomString) if (ao.GetAstroObjectName() == AstroObject.Name.CustomString)
{ {