Fix tidal lock alignment (comet tails broken tho)

This commit is contained in:
Nick 2022-03-11 11:24:00 -05:00
parent f89a27922d
commit 4eb50ebdfa
4 changed files with 19 additions and 5 deletions

View File

@ -1,4 +1,5 @@
using NewHorizons.External;
using NewHorizons.External.Configs;
using OWML.Utils;
using System;
using System.Collections.Generic;
@ -11,13 +12,17 @@ namespace NewHorizons.Builder.Body
{
public static class CometTailBuilder
{
public static void Make(GameObject go, BaseModule module, AstroObject primary)
public static void Make(GameObject go, IPlanetConfig config, AstroObject primary)
{
var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), go.transform);
cometTail.transform.localPosition = Vector3.zero;
cometTail.name = "CometTail";
cometTail.transform.localScale = Vector3.one * module.SurfaceSize / 110;
cometTail.transform.localRotation = Quaternion.Euler(180, 0, 0);
cometTail.transform.localScale = Vector3.one * config.Base.SurfaceSize / 110;
Vector3 alignmentAxis = new Vector3(0, -1, 0);
if (config.Orbit.AlignmentAxis != null) alignmentAxis = config.Orbit.AlignmentAxis;
cometTail.transform.localRotation = Quaternion.Euler(0, 270, 90) * Quaternion.FromToRotation(new Vector3(0, -1, 0), alignmentAxis);
}
}
}

View File

@ -66,7 +66,15 @@ namespace NewHorizons.Builder.General
var alignment = body.AddComponent<AlignWithTargetBody>();
alignment.SetTargetBody(primaryBody?.GetAttachedOWRigidbody());
alignment.SetValue("_usePhysicsToRotate", true);
alignment._localAlignmentAxis = Vector3.left;
if(config.Orbit.AlignmentAxis == null)
{
alignment._localAlignmentAxis = new Vector3(0, -1, 0);
}
else
{
alignment._localAlignmentAxis = config.Orbit.AlignmentAxis;
}
}
if (config.Base.CenterOfSolarSystem)

View File

@ -22,6 +22,7 @@ namespace NewHorizons.External
public float AxialTilt { get; set; }
public float SiderealPeriod { get; set; }
public bool IsTidallyLocked { get; set; }
public MVector3 AlignmentAxis { get; set; }
public bool ShowOrbitLine { get; set; } = true;
public bool IsStatic { get; set; }
public MColor Tint { get; set; }

View File

@ -292,7 +292,7 @@ namespace NewHorizons.Handlers
AsteroidBeltBuilder.Make(body.Config.Name, body.Config, body.Mod);
if (body.Config.Base.HasCometTail)
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
CometTailBuilder.Make(go, body.Config, go.GetComponent<AstroObject>().GetPrimaryBody());
// Backwards compatability
if (body.Config.Base.LavaSize != 0)