From 9aa436c60f1856e7fa55e5bcc6e62079197d407f Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Tue, 21 Mar 2023 21:17:45 -0500 Subject: [PATCH] Vessel fixes --- .../External/Configs/StarSystemConfig.cs | 7 +++- NewHorizons/Handlers/VesselWarpHandler.cs | 34 ++++++++++++++++--- NewHorizons/Main.cs | 3 +- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index c007787d..f3ffcf21 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -191,7 +191,7 @@ namespace NewHorizons.External.Configs public string promptFact; /// - /// Whether the vessel should spawn in this system even if it wasn't used to warp to it. + /// Whether the vessel should spawn in this system even if it wasn't used to warp to it. This will automatically power on the vessel. /// public bool alwaysPresent; @@ -205,6 +205,11 @@ namespace NewHorizons.External.Configs /// [DefaultValue(true)] public bool hasPhysics = true; + /// + /// Whether the vessel should have a zero-gravity volume around it that ignores any other sources of gravity, like the vessel works in Dark Bramble. + /// + public bool hasZeroGravityVolume; + /// /// The location that the vessel will warp to. /// diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 085f6a09..2cc08a91 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -27,19 +27,25 @@ namespace NewHorizons.Handlers VesselPrefab = Main.NHPrivateAssetBundle.LoadAsset("Vessel_Body"); } - public static bool IsVesselPresent() + public static bool IsVesselPresentAndActive() { var vesselConfig = SystemDict[Instance.CurrentStarSystem].Config?.Vessel; - var isDefaultSolarSystem = Instance.CurrentStarSystem == "SolarSystem"; - var vesselIsPresent = vesselConfig?.alwaysPresent ?? isDefaultSolarSystem; + var vesselIsPresent = vesselConfig?.alwaysPresent ?? false; return Instance.IsWarpingFromVessel || vesselIsPresent; } + public static bool IsVesselPresent() + { + var isDefaultSolarSystem = Instance.CurrentStarSystem == "SolarSystem"; + var isEyeOfTheUniverse = Instance.CurrentStarSystem == "EyeOfTheUniverse"; + return IsVesselPresentAndActive() || isDefaultSolarSystem || isEyeOfTheUniverse; + } + public static bool ShouldSpawnAtVessel() { var vesselConfig = SystemDict[Instance.CurrentStarSystem].Config?.Vessel; var shouldSpawnOnVessel = IsVesselPresent() && (vesselConfig?.spawnOnVessel ?? false); - return Instance.IsWarpingFromVessel || (IsVesselPresent() && shouldSpawnOnVessel); + return Instance.IsWarpingFromVessel || shouldSpawnOnVessel; } public static void LoadVessel() @@ -51,7 +57,7 @@ namespace NewHorizons.Handlers return; } - if (IsVesselPresent()) + if (IsVesselPresentAndActive()) _vesselSpawnPoint = Instance.CurrentStarSystem == "SolarSystem" ? UpdateVessel() : CreateVessel(); else _vesselSpawnPoint = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension").GetComponentInChildren(); @@ -182,9 +188,23 @@ namespace NewHorizons.Handlers UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); + var rfVolume = vesselObject.transform.Find("RFVolume"); + if (rfVolume != null) + { + GameObject.Destroy(rfVolume.gameObject); + } } vesselWarpController._targetWarpPlatform._owRigidbody = warpExit.GetAttachedOWRigidbody(); + if (system.Config.Vessel?.hasZeroGravityVolume ?? false) + { + var zeroGVolume = vesselObject.transform.Find("Sector_VesselBridge/Volumes_VesselBridge/ZeroGVolume"); + if (zeroGVolume != null) + { + GameObject.Destroy(zeroGVolume.gameObject); + } + } + vesselObject.SetActive(true); Delay.FireOnNextUpdate(() => SetupWarpController(vesselWarpController)); @@ -274,6 +294,10 @@ namespace NewHorizons.Handlers vesselWarpController._cageAnimator.OnTranslationComplete -= new TransformAnimator.AnimationEvent(vesselWarpController.OnCageAnimationComplete); vesselWarpController._cageAnimator.OnTranslationComplete += new TransformAnimator.AnimationEvent(vesselWarpController.OnCageAnimationComplete); } + + // Normally the power-on sound is 2D/global, we set it to 3D/local so it isn't audible if the player isn't nearby + vesselWarpController._audioSource.spatialBlend = 1f; + vesselWarpController._audioSource.rolloffMode = AudioRolloffMode.Linear; } } } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 390072a7..73f717cb 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -146,8 +146,7 @@ namespace NewHorizons x = new int[5]{ 0,3,2,1,5 }, y = new int[5]{ 4,5,3,2,1 }, z = new int[5]{ 4,1,2,5,0 } - }, - alwaysPresent = true, + } } } };