Merge branch 'dev' into fix-remove-children

This commit is contained in:
Nick 2022-07-05 18:57:22 -04:00
commit 0ec1d51211
10 changed files with 102 additions and 69 deletions

View File

@ -44,15 +44,9 @@ namespace NewHorizons.Builder.General
public static void SetDetector(AstroObject primaryBody, AstroObject astroObject, ConstantForceDetector forceDetector)
{
GravityVolume parentGravityVolume = primaryBody?.GetAttachedOWRigidbody()?.GetAttachedGravityVolume();
if (parentGravityVolume != null)
{
forceDetector._detectableFields = new ForceVolume[] { parentGravityVolume };
}
else if (astroObject != null)
{
// It's probably a focal point (or its just broken)
var binaryFocalPoint = primaryBody?.gameObject?.GetComponent<BinaryFocalPoint>();
var parentGravityVolume = primaryBody?.GetAttachedOWRigidbody()?.GetAttachedGravityVolume();
if (binaryFocalPoint != null)
{
if (astroObject.GetCustomName().Equals(binaryFocalPoint.PrimaryName))
@ -78,11 +72,13 @@ namespace NewHorizons.Builder.General
// It's a planet
if (binaryFocalPoint.Primary != null && binaryFocalPoint.Secondary != null)
{
var fakeBarycenterGravityVolume = binaryFocalPoint.FakeMassBody.GetComponent<AstroObject>().GetGravityVolume();
forceDetector._detectableFields = new ForceVolume[] { fakeBarycenterGravityVolume };
forceDetector._detectableFields = new ForceVolume[] { parentGravityVolume };
}
}
}
else
{
forceDetector._detectableFields = new ForceVolume[] { parentGravityVolume };
}
}

View File

@ -4,6 +4,7 @@ using NewHorizons.External.Modules;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using OWML.Common;
using System.Linq;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Orbital
@ -18,12 +19,10 @@ namespace NewHorizons.Builder.Orbital
binary.PrimaryName = module.primary;
binary.SecondaryName = module.secondary;
// Below is the stupid fix for making circumbinary planets or wtv
// Grab the bodies from the main dictionary
NewHorizonsBody primary = null;
NewHorizonsBody secondary = null;
foreach (var body in Main.BodyDict[Main.Instance.CurrentStarSystem])
foreach (var body in Main.BodyDict[config.starSystem])
{
if (body.Config.name == module.primary)
{
@ -44,28 +43,26 @@ namespace NewHorizons.Builder.Orbital
Logger.LogError($"Couldn't make focal point between [{module.primary} = {primary}] and [{module.secondary} = {secondary}]");
return;
}
}
public static void ValidateConfig(PlanetConfig config)
{
var primary = Main.BodyDict[config.starSystem].Where(x => x.Config.name == config.FocalPoint.primary).FirstOrDefault();
var secondary = Main.BodyDict[config.starSystem].Where(x => x.Config.name == config.FocalPoint.secondary).FirstOrDefault();
var gravitationalMass = GetGravitationalMass(primary.Config) + GetGravitationalMass(secondary.Config);
// Copying it because I don't want to modify the actual config
var fakeMassConfig = new PlanetConfig();
// Now need to fake the 3 values to make it return this mass
fakeMassConfig.Base.surfaceSize = 1;
fakeMassConfig.Base.surfaceGravity = gravitationalMass * GravityVolume.GRAVITATIONAL_CONSTANT;
fakeMassConfig.Base.gravityFallOff = primary.Config.Base.gravityFallOff;
config.Base.surfaceSize = 1;
config.Base.surfaceGravity = gravitationalMass * GravityVolume.GRAVITATIONAL_CONSTANT;
config.Base.gravityFallOff = primary.Config.Base.gravityFallOff;
// Other stuff to make the fake barycenter not interact with anything in any way
fakeMassConfig.name = config.name + "_FakeBarycenterMass";
fakeMassConfig.Base.soiOverride = 0;
fakeMassConfig.Base.hasMapMarker = false;
fakeMassConfig.ReferenceFrame.enabled = false;
fakeMassConfig.ReferenceFrame.hideInMap = true;
// Other stuff to make the barycenter not interact with anything in any way
config.Base.soiOverride = 0;
fakeMassConfig.Orbit = new OrbitModule();
fakeMassConfig.Orbit.CopyPropertiesFrom(config.Orbit);
binary.FakeMassBody = PlanetCreationHandler.GenerateBody(new NewHorizonsBody(fakeMassConfig, mod));
var separation = primary.Config.Orbit.semiMajorAxis + secondary.Config.Orbit.semiMajorAxis;
config.ReferenceFrame.bracketRadius = separation;
config.ReferenceFrame.targetColliderRadius = separation;
}
private static float GetGravitationalMass(PlanetConfig config)

View File

@ -70,8 +70,8 @@ namespace NewHorizons.Builder.Orbital
else
{
// It's a circumbinary moon/planet
var fakePrimaryBody = focalPoint.FakeMassBody.GetComponent<AstroObject>();
SetMotionFromPrimary(fakePrimaryBody, secondaryBody, secondaryBody as NHAstroObject, initialMotion);
var focalPointAO = focalPoint.GetComponent<AstroObject>();
SetMotionFromPrimary(focalPointAO, secondaryBody, secondaryBody as NHAstroObject, initialMotion);
}
}
else if (primaryBody.GetGravityVolume())
@ -107,11 +107,11 @@ namespace NewHorizons.Builder.Orbital
// Might make binaries with binaries with binaries work
if (primaryBody.GetGravityVolume() == null)
{
primaryGravity = new Gravity(primaryBody.GetComponent<BinaryFocalPoint>()?.FakeMassBody?.GetComponent<AstroObject>()?.GetGravityVolume());
primaryGravity = new Gravity(primaryBody.GetGravityVolume());
}
if (secondaryBody.GetGravityVolume() == null)
{
secondaryGravity = new Gravity(secondaryBody.GetComponent<BinaryFocalPoint>()?.FakeMassBody?.GetComponent<AstroObject>()?.GetGravityVolume());
secondaryGravity = new Gravity(secondaryBody.GetGravityVolume());
}
// Update the positions

View File

@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
namespace NewHorizons.Components.Orbital
{
public class BinaryFocalPoint : MonoBehaviour
@ -9,14 +9,6 @@ namespace NewHorizons.Components.Orbital
public AstroObject Primary { get; set; }
public AstroObject Secondary { get; set; }
public GameObject FakeMassBody { get; set; }
void Start()
{
// Make sure its active but maybe it hasn't been set yet
if (FakeMassBody) FakeMassBody.SetActive(true);
}
void Update()
{
if (Primary == null || Secondary == null)
@ -48,8 +40,6 @@ namespace NewHorizons.Components.Orbital
{
component2.DisableMarker();
}
FakeMassBody.SetActive(false);
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using NewHorizons.Builder.Orbital;
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.VariableSize;
using Newtonsoft.Json;

View File

@ -267,6 +267,9 @@ namespace NewHorizons.Handlers
// Only called when making new planets
public static GameObject GenerateBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
{
// Focal points are weird
if (body.Config.FocalPoint != null) FocalPointBuilder.ValidateConfig(body.Config);
AstroObject primaryBody;
if (body.Config.Orbit.primaryBody != null)
{

View File

@ -1,6 +1,6 @@
---
Title: Detailing
Sort_Priority: 90
Sort_Priority: 85
---
# Details/Scatterer

View File

@ -0,0 +1,46 @@
---
Title: Star System
Description: A guide to editing a custom star system in New Horizons
Sort_Priority: 90
---
# Intro
Welcome! This page outlines how to edit a custom star system.
## Getting Started
Star Systems are placed in a folder called systems within your mod folder.
The name of your star system config must be the same as the unique id used in the `starSystem` field of your planet configs. Example: `xen.RealSolarSystem.json`.
A star system config file will look something like this:
```json
{
"$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/star_system_schema.json",
"coords": {
"x": [ 4, 0, 3, 1 ],
"y": [ 0, 5, 4 ],
"z": [ 5, 4, 0, 3, 1 ]
},
"vesselPosition": {
"x": 0,
"y": 0,
"z": 8000
}
}
```
To see all the different things you can put into a config file check out the [Star System Schema]({{ 'Star System Schema'|route}}).
## Vessel Coordinates
You can warp to custom star systems via the Nomai vessel. Each coordinate has to be 2-6 points long.
These are the points for each coordinate node. When making your unique coordinate you should only use each point once.
![nomaiCoordinateIndexes]({{ "images/star_system/nomai_coordinate_indexes.webp"|static }})
### Hearthian Solar System Vessel Coordinates
You can use these coordinates to warp back to the hearthian solar system.
![hearthianSolarSystemCoordinates]({{ "images/star_system/hearthian_solar_system_coordinates.webp"|static }})

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB