Allow removing vessel rigidbody

This commit is contained in:
Joshua Thome 2023-03-18 10:52:57 -05:00
parent 7c77eb7bad
commit 62dcc92dbb
2 changed files with 9 additions and 4 deletions

View File

@ -208,7 +208,10 @@ namespace NewHorizons.External.Configs
[JsonObject]
public class VesselInfo : PropModule.GeneralSolarSystemPropInfo
{
/// <summary>
/// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.
/// </summary>
[DefaultValue(true)] public bool hasPhysics = true;
}
[JsonObject]

View File

@ -88,10 +88,12 @@ namespace NewHorizons.Handlers
var vesselObject = GeneralPropBuilder.MakeFromPrefab(VesselPrefab, VesselPrefab.name, null, system.Config.Vessel?.vesselSpawn);
VesselObject = vesselObject;
vesselObject.transform.parent = null;
var vesselAO = vesselObject.AddComponent<EyeAstroObject>();
vesselAO._owRigidbody = vesselObject.GetComponent<OWRigidbody>();
if (system.Config.Vessel?.vesselSpawn.hasPhysics ?? true)
{
vesselAO._owRigidbody = vesselObject.GetComponent<OWRigidbody>();
vesselObject.transform.parent = null;
}
vesselAO._rootSector = vesselObject.GetComponentInChildren<Sector>(true);
vesselAO._customName = "Vessel";
vesselAO._name = AstroObject.Name.CustomString;