mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Vessel spawning and parenting
This commit is contained in:
parent
8aa22a639f
commit
d7b76718f8
10
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
10
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
@ -190,6 +190,16 @@ namespace NewHorizons.External.Configs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string promptFact;
|
public string promptFact;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the vessel should spawn in this system even if it wasn't used to warp to it.
|
||||||
|
/// </summary>
|
||||||
|
public bool alwaysPresent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to always spawn the player on the vessel, even if it wasn't used to warp to the system.
|
||||||
|
/// </summary>
|
||||||
|
public bool spawnOnVessel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.
|
/// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -29,13 +29,16 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
public static void LoadVessel()
|
public static void LoadVessel()
|
||||||
{
|
{
|
||||||
|
var system = SystemDict[Instance.CurrentStarSystem];
|
||||||
if (Instance.CurrentStarSystem == "EyeOfTheUniverse")
|
if (Instance.CurrentStarSystem == "EyeOfTheUniverse")
|
||||||
{
|
{
|
||||||
_vesselSpawnPoint = SearchUtilities.Find("Vessel_Body/SPAWN_Vessel").GetComponent<EyeSpawnPoint>();
|
_vesselSpawnPoint = SearchUtilities.Find("Vessel_Body/SPAWN_Vessel").GetComponent<EyeSpawnPoint>();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Instance.IsWarpingFromVessel)
|
var vesselIsPresent = system.Config?.Vessel?.alwaysPresent ?? false;
|
||||||
|
|
||||||
|
if (Instance.IsWarpingFromVessel || vesselIsPresent)
|
||||||
_vesselSpawnPoint = Instance.CurrentStarSystem == "SolarSystem" ? UpdateVessel() : CreateVessel();
|
_vesselSpawnPoint = Instance.CurrentStarSystem == "SolarSystem" ? UpdateVessel() : CreateVessel();
|
||||||
else
|
else
|
||||||
_vesselSpawnPoint = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension").GetComponentInChildren<SpawnPoint>();
|
_vesselSpawnPoint = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension").GetComponentInChildren<SpawnPoint>();
|
||||||
@ -91,11 +94,7 @@ namespace NewHorizons.Handlers
|
|||||||
VesselObject = vesselObject;
|
VesselObject = vesselObject;
|
||||||
|
|
||||||
var vesselAO = vesselObject.AddComponent<EyeAstroObject>();
|
var vesselAO = vesselObject.AddComponent<EyeAstroObject>();
|
||||||
if (system.Config.Vessel?.hasPhysics ?? true)
|
vesselAO._owRigidbody = vesselObject.GetComponent<OWRigidbody>();
|
||||||
{
|
|
||||||
vesselAO._owRigidbody = vesselObject.GetComponent<OWRigidbody>();
|
|
||||||
vesselObject.transform.parent = null;
|
|
||||||
}
|
|
||||||
vesselAO._rootSector = vesselObject.GetComponentInChildren<Sector>(true);
|
vesselAO._rootSector = vesselObject.GetComponentInChildren<Sector>(true);
|
||||||
vesselAO._customName = "Vessel";
|
vesselAO._customName = "Vessel";
|
||||||
vesselAO._name = AstroObject.Name.CustomString;
|
vesselAO._name = AstroObject.Name.CustomString;
|
||||||
@ -159,6 +158,20 @@ namespace NewHorizons.Handlers
|
|||||||
EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren<EyeSpawnPoint>(true);
|
EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren<EyeSpawnPoint>(true);
|
||||||
system.SpawnPoint = eyeSpawnPoint;
|
system.SpawnPoint = eyeSpawnPoint;
|
||||||
|
|
||||||
|
if (system.Config.Vessel?.hasPhysics ?? true)
|
||||||
|
{
|
||||||
|
vesselObject.transform.parent = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vesselAO._owRigidbody = null;
|
||||||
|
UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent<KinematicRigidbody>());
|
||||||
|
UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent<CenterOfTheUniverseOffsetApplier>());
|
||||||
|
UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent<OWRigidbody>());
|
||||||
|
UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent<Rigidbody>());
|
||||||
|
}
|
||||||
|
vesselWarpController._targetWarpPlatform._owRigidbody = warpExit.GetAttachedOWRigidbody();
|
||||||
|
|
||||||
vesselObject.SetActive(true);
|
vesselObject.SetActive(true);
|
||||||
|
|
||||||
Delay.FireOnNextUpdate(() => SetupWarpController(vesselWarpController));
|
Delay.FireOnNextUpdate(() => SetupWarpController(vesselWarpController));
|
||||||
|
|||||||
@ -400,8 +400,11 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
if (HasWarpDrive == true) EnableWarpDrive();
|
if (HasWarpDrive == true) EnableWarpDrive();
|
||||||
|
|
||||||
|
var vesselIsPresent = SystemDict[CurrentStarSystem].Config?.Vessel?.alwaysPresent ?? false;
|
||||||
|
var shouldSpawnOnVessel = vesselIsPresent && (SystemDict[CurrentStarSystem].Config?.Vessel?.spawnOnVessel ?? false);
|
||||||
|
|
||||||
var shouldWarpInFromShip = IsWarpingFromShip && _shipWarpController != null;
|
var shouldWarpInFromShip = IsWarpingFromShip && _shipWarpController != null;
|
||||||
var shouldWarpInFromVessel = IsWarpingFromVessel && VesselWarpHandler.VesselSpawnPoint != null;
|
var shouldWarpInFromVessel = (IsWarpingFromVessel || shouldSpawnOnVessel) && VesselWarpHandler.VesselSpawnPoint != null;
|
||||||
Delay.RunWhen(() => IsSystemReady, () => OnSystemReady(shouldWarpInFromShip, shouldWarpInFromVessel));
|
Delay.RunWhen(() => IsSystemReady, () => OnSystemReady(shouldWarpInFromShip, shouldWarpInFromVessel));
|
||||||
|
|
||||||
IsWarpingFromShip = false;
|
IsWarpingFromShip = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user