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,9 +25,7 @@ namespace NewHorizons.Builder.Body
//-11096.95 -22786.44 4657.534
//-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
// values are all dimensions' warp controllers that link to a given dimension
// unpairedNodes[name of node that doesn't exist yet] => List{warp controller for dimension that exits to that node, ...}
@ -49,8 +47,7 @@ namespace NewHorizons.Builder.Body
dimension.name = name.Replace(" ", "").Replace("'", "") + "_Body";
// set position
ao.transform.position = new Vector3(6904.48f, 17048.44f, 5574.479f) + new Vector3(0, 3000, 0)*DIMENSION_COUNTER;
DIMENSION_COUNTER++;
ao.transform.position = body.Config.Orbit.staticPosition;
// 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");

View File

@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using NewHorizons.Components.Orbital;
using NewHorizons.Utility;
@ -8,7 +8,12 @@ namespace NewHorizons.External.Modules
{
[JsonObject]
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>
/// The name of the body this one will orbit around
/// </summary>

View File

@ -268,6 +268,12 @@ namespace NewHorizons.Handlers
{
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);
}
else
@ -378,6 +384,10 @@ namespace NewHorizons.Handlers
if (!body.Config.Orbit.isStatic)
{
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)