From 77e7ebb20c45b078ec6867296842f5a55a9fb801 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Wed, 15 Jun 2022 15:38:23 -0400 Subject: [PATCH] Vessel Position --- .../External/Configs/StarSystemConfig.cs | 20 +++++++++++++++++++ NewHorizons/Main.cs | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index d9cbba36..e895ff9f 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -63,6 +63,26 @@ namespace NewHorizons.External.Configs /// public NomaiCoordinates coords; + /// + /// The position in the solar system the vessel will warp to. + /// + public MVector3 vesselPosition; + + /// + /// Euler angles by which the vessel will be oriented. + /// + public MVector3 vesselRotation; + + /// + /// The relative position to the vessel that you will be teleported to when you exit the vessel through the black hole. + /// + public MVector3 warpExitPosition; + + /// + /// Euler angles by which the warp exit will be oriented. + /// + public MVector3 warpExitRotation; + public class NomaiCoordinates { public int[] x; diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 59f7b519..ae2a715a 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -359,15 +359,24 @@ namespace NewHorizons private EyeSpawnPoint CreateVessel() { + var system = SystemDict[_currentStarSystem]; Logger.Log("Checking for Vessel Prefab"); if (VesselPrefab == null) return null; Logger.Log("Creating Vessel"); var vesselObject = GameObject.Instantiate(VesselPrefab); vesselObject.name = VesselPrefab.name; vesselObject.transform.parent = null; + if (system.Config.vesselPosition != null) + vesselObject.transform.position += system.Config.vesselPosition; + if (system.Config.vesselRotation != null) + vesselObject.transform.eulerAngles = system.Config.vesselRotation; vesselObject.SetActive(true); VesselWarpController vesselWarpController = vesselObject.GetComponentInChildren(true); vesselWarpController._targetWarpPlatform.OnReceiveWarpedBody += (OWRigidbody warpedBody, NomaiWarpPlatform startPlatform, NomaiWarpPlatform targetPlatform) => OnReceiveWarpedBody(vesselObject, warpedBody, startPlatform, targetPlatform); + if (system.Config.warpExitPosition != null) + vesselWarpController._targetWarpPlatform.transform.localPosition = system.Config.warpExitPosition; + if (system.Config.warpExitRotation != null) + vesselObject.transform.localEulerAngles = system.Config.warpExitRotation; MapMarker mapMarker = vesselObject.AddComponent(); mapMarker._labelID = (UITextType)TranslationHandler.AddUI("Vessel"); mapMarker._markerType = MapMarker.MarkerType.Planet;