mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Messy Merge
This commit is contained in:
commit
c39906bbe7
@ -2,6 +2,7 @@
|
||||
using NewHorizons.OrbitalPhysics;
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using PacificEngine.OW_CommonResources.Game;
|
||||
using PacificEngine.OW_CommonResources.Game.Resource;
|
||||
using PacificEngine.OW_CommonResources.Game.State;
|
||||
@ -12,6 +13,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
@ -35,6 +37,9 @@ namespace NewHorizons.Builder.General
|
||||
{
|
||||
hb = AddHeavenlyBody(config.Name);
|
||||
}
|
||||
|
||||
if(!config.Orbit.IsStatic)
|
||||
{
|
||||
var planetoid = new Planet.Plantoid(size, gravity, body.transform.rotation, initialMotion._initAngularSpeed, parent, orbit);
|
||||
|
||||
var mapping = Planet.defaultMapping;
|
||||
@ -42,8 +47,33 @@ namespace NewHorizons.Builder.General
|
||||
Planet.defaultMapping = mapping;
|
||||
}
|
||||
|
||||
// Fix for binary focal points
|
||||
var focalPoint = Position.AstroLookup[parent].Invoke()?.gameObject.GetComponent<BinaryFocalPoint>();
|
||||
if (focalPoint != null && Planet.defaultMapping.ContainsKey(parent))
|
||||
{
|
||||
var primary = Position.getBody(GetBody(focalPoint.PrimaryName));
|
||||
var secondary = Position.getBody(GetBody(focalPoint.SecondaryName));
|
||||
|
||||
if(primary != null && secondary != null)
|
||||
{
|
||||
Logger.Log($"Fixing BinaryFocalPoint HeavenlyBody gravity value for {parent.name}");
|
||||
var exponent = ((primary?.GetAttachedGravityVolume()?._falloffExponent ?? 2f) + (secondary?.GetAttachedGravityVolume()?._falloffExponent ?? 2f)) / 2f;
|
||||
var mass = ((primary?.GetAttachedGravityVolume()?._gravitationalMass ?? ((primary?.GetMass() ?? 0f) * 1000f)) + (secondary?.GetAttachedGravityVolume()?._gravitationalMass ?? ((secondary?.GetMass() ?? 0f) * 1000f))) / 4f;
|
||||
|
||||
var currentValue = Planet.mapping[parent];
|
||||
var newValue = new Planet.Plantoid(currentValue.size, Gravity.of(exponent, mass), currentValue.state);
|
||||
Planet.defaultMapping[parent] = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Gravity getGravity(GravityVolume volume)
|
||||
{
|
||||
if (volume == null)
|
||||
{
|
||||
return Gravity.of(2, 0);
|
||||
}
|
||||
|
||||
var exponent = volume._falloffType != GravityVolume.FalloffType.linear ? 2f : 1f;
|
||||
var mass = (volume._surfaceAcceleration * Mathf.Pow(volume._upperSurfaceRadius, exponent)) / GravityVolume.GRAVITATIONAL_CONSTANT;
|
||||
|
||||
|
||||
@ -89,21 +89,23 @@ namespace NewHorizons
|
||||
(b.Config.Orbit.IsMoon ? 2 : 1)
|
||||
))).ToList();
|
||||
|
||||
var flagNoneLoadedThisPass = true;
|
||||
var count = 0;
|
||||
while(toLoad.Count != 0)
|
||||
{
|
||||
Logger.Log($"Starting body loading pass #{++count}");
|
||||
var flagNoneLoadedThisPass = true;
|
||||
foreach (var body in toLoad)
|
||||
{
|
||||
if (LoadBody(body))
|
||||
flagNoneLoadedThisPass = false;
|
||||
if (LoadBody(body)) flagNoneLoadedThisPass = false;
|
||||
}
|
||||
if (flagNoneLoadedThisPass)
|
||||
{
|
||||
Logger.LogWarning("No objects were loaded this pass");
|
||||
// Try again but default to sun
|
||||
foreach(var body in toLoad)
|
||||
{
|
||||
if (LoadBody(body, true))
|
||||
flagNoneLoadedThisPass = false;
|
||||
if (LoadBody(body, true)) flagNoneLoadedThisPass = false;
|
||||
}
|
||||
}
|
||||
if (flagNoneLoadedThisPass)
|
||||
{
|
||||
@ -111,10 +113,19 @@ namespace NewHorizons
|
||||
Logger.Log($"Couldn't finish adding bodies.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
toLoad = NextPassBodies;
|
||||
NextPassBodies = new List<NewHorizonsBody>();
|
||||
|
||||
// Infinite loop failsafe
|
||||
if (count > 10)
|
||||
{
|
||||
Logger.Log("Something went wrong");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Log("Done loading bodies");
|
||||
|
||||
// I don't know what these do but they look really weird from a distance
|
||||
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => PlanetDestroyer.RemoveDistantProxyClones());
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using NewHorizons.Utility;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.OrbitalPhysics
|
||||
{
|
||||
public class ParameterizedOrbitLine : EllipticOrbitLine
|
||||
{
|
||||
public ParameterizedAstroObject astroObject;
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
base.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,10 @@ namespace NewHorizons.Utility
|
||||
public static float GetFalloffExponent(this GravityVolume gv)
|
||||
{
|
||||
if (gv == null) return 0;
|
||||
return (float)typeof(GravityVolume).GetField("_falloffExponent", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(gv);
|
||||
if (gv._falloffType == GravityVolume.FalloffType.linear) return 1;
|
||||
if (gv._falloffType == GravityVolume.FalloffType.inverseSquared) return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static string ToCamelCase(this string str)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user