Move vessel config to its own module

This commit is contained in:
Joshua Thome 2022-07-23 19:22:14 -05:00
parent d7c1812741
commit d5a4ca2fa1
5 changed files with 81 additions and 37 deletions

View File

@ -69,28 +69,23 @@ namespace NewHorizons.External.Configs
public string travelAudio;
/// <summary>
/// Coordinates that the vessel can use to warp to your solar system.
/// Configure warping to this system with the vessel
/// </summary>
public VesselModule Vessel;
[Obsolete("coords is deprecated, please use Vessel.coords instead")]
public NomaiCoordinates coords;
/// <summary>
/// The position in the solar system the vessel will warp to.
/// </summary>
[Obsolete("vesselPosition is deprecated, please use Vessel.vesselPosition instead")]
public MVector3 vesselPosition;
/// <summary>
/// Euler angles by which the vessel will be oriented.
/// </summary>
[Obsolete("vesselRotation is deprecated, please use Vessel.vesselRotation instead")]
public MVector3 vesselRotation;
/// <summary>
/// The relative position to the vessel that you will be teleported to when you exit the vessel through the black hole.
/// </summary>
[Obsolete("warpExitPosition is deprecated, please use Vessel.warpExitPosition instead")]
public MVector3 warpExitPosition;
/// <summary>
/// Euler angles by which the warp exit will be oriented.
/// </summary>
[Obsolete("warpExitRotation is deprecated, please use Vessel.warpExitRotation instead")]
public MVector3 warpExitRotation;
/// <summary>
@ -189,6 +184,35 @@ namespace NewHorizons.External.Configs
public string backPath;
}
[JsonObject]
public class VesselModule
{
/// <summary>
/// Coordinates that the vessel can use to warp to your solar system.
/// </summary>
public NomaiCoordinates coords;
/// <summary>
/// The position in the solar system the vessel will warp to.
/// </summary>
public MVector3 vesselPosition;
/// <summary>
/// Euler angles by which the vessel will be oriented.
/// </summary>
public MVector3 vesselRotation;
/// <summary>
/// The relative position to the vessel that you will be teleported to when you exit the vessel through the black hole.
/// </summary>
public MVector3 warpExitPosition;
/// <summary>
/// Euler angles by which the warp exit will be oriented.
/// </summary>
public MVector3 warpExitRotation;
}
/// <summary>
/// Makes sure they are all numbers are unique and between 0 and 5.
/// </summary>
@ -196,11 +220,11 @@ namespace NewHorizons.External.Configs
public void FixCoordinates()
{
if (coords != null)
if (Vessel?.coords != null)
{
coords.x = FixAxis(coords.x);
coords.y = FixAxis(coords.y);
coords.z = FixAxis(coords.z);
Vessel.coords.x = FixAxis(Vessel.coords.x);
Vessel.coords.y = FixAxis(Vessel.coords.y);
Vessel.coords.z = FixAxis(Vessel.coords.z);
}
}
@ -226,6 +250,8 @@ namespace NewHorizons.External.Configs
mapRestricted = mapRestricted || otherConfig.mapRestricted;
startHere = startHere || otherConfig.startHere;
Vessel = Vessel == null ? otherConfig.Vessel : Vessel;
entryPositions = Concatenate(entryPositions, otherConfig.entryPositions);
curiosities = Concatenate(curiosities, otherConfig.curiosities);
initialReveal = Concatenate(initialReveal, otherConfig.initialReveal);
@ -251,6 +277,18 @@ namespace NewHorizons.External.Configs
Skybox.destroyStarField = skybox.destroyStarField;
}
}
if (coords != null || vesselPosition != null || vesselRotation != null || warpExitPosition != null || warpExitRotation != null)
{
if (Vessel == null)
{
Vessel = new VesselModule();
}
Vessel.coords = Vessel.coords ?? coords;
Vessel.vesselPosition = Vessel.vesselPosition ?? vesselPosition;
Vessel.vesselRotation = Vessel.vesselRotation ?? vesselRotation;
Vessel.warpExitPosition = Vessel.warpExitPosition ?? warpExitPosition;
Vessel.warpExitRotation = Vessel.warpExitRotation ?? warpExitRotation;
}
}
}
}

View File

@ -32,7 +32,7 @@ namespace NewHorizons.Handlers
{
var systemName = system.UniqueID;
var fact = system.Config.factRequiredForWarp;
var nomaiCoords = system.Config.coords;
var nomaiCoords = system.Config.Vessel?.coords;
if (system.UniqueID == "EyeOfTheUniverse" || nomaiCoords == null) continue;

View File

@ -88,11 +88,11 @@ namespace NewHorizons.Handlers
vesselOrbLocker.InitializeOrbs();
vesselOrbLocker.AddLocks();
if (system.Config.vesselPosition != null)
vesselObject.transform.position = system.Config.vesselPosition;
if (system.Config.Vessel?.vesselPosition != null)
vesselObject.transform.position = system.Config.Vessel.vesselPosition;
if (system.Config.vesselRotation != null)
vesselObject.transform.eulerAngles = system.Config.vesselRotation;
if (system.Config.Vessel?.vesselRotation != null)
vesselObject.transform.eulerAngles = system.Config.Vessel.vesselRotation;
vesselOrbLocker.RemoveLocks();
vesselOrbLocker.AddLockToWarpOrb();
@ -142,11 +142,11 @@ namespace NewHorizons.Handlers
vesselWarpController._targetWarpPlatform.OnReceiveWarpedBody += OnReceiveWarpedBody;
if (system.Config.warpExitPosition != null)
vesselWarpController._targetWarpPlatform.transform.localPosition = system.Config.warpExitPosition;
if (system.Config.Vessel?.warpExitPosition != null)
vesselWarpController._targetWarpPlatform.transform.localPosition = system.Config.Vessel.warpExitPosition;
if (system.Config.warpExitRotation != null)
vesselWarpController._targetWarpPlatform.transform.localEulerAngles = system.Config.warpExitRotation;
if (system.Config.Vessel?.warpExitRotation != null)
vesselWarpController._targetWarpPlatform.transform.localEulerAngles = system.Config.Vessel.warpExitRotation;
vesselObject.GetComponent<MapMarker>()._labelID = (UITextType)TranslationHandler.AddUI("VESSEL");

View File

@ -127,6 +127,8 @@ namespace NewHorizons
Config =
{
destroyStockPlanets = false,
Vessel = new StarSystemConfig.VesselModule()
{
coords = new StarSystemConfig.NomaiCoordinates
{
x = new int[5]{ 0,3,2,1,5 },
@ -134,10 +136,13 @@ namespace NewHorizons
z = new int[5]{ 4,1,2,5,0 }
}
}
}
};
SystemDict["EyeOfTheUniverse"] = new NewHorizonsSystem("EyeOfTheUniverse", new StarSystemConfig(), Instance)
{
Config =
{
Vessel = new StarSystemConfig.VesselModule()
{
coords = new StarSystemConfig.NomaiCoordinates
{
@ -146,6 +151,7 @@ namespace NewHorizons
z = new int[6]{ 1,2,3,0,5,4 }
}
}
}
};
if (!resetTranslation) return;
@ -340,7 +346,7 @@ namespace NewHorizons
else if (shouldWarpInFromVessel) VesselWarpHandler.TeleportToVessel();
else FindObjectOfType<PlayerSpawner>().DebugWarp(SystemDict[_currentStarSystem].SpawnPoint);
VesselCoordinatePromptHandler.RegisterPrompts(SystemDict.Where(system => system.Value.Config.coords != null).Select(x => x.Value).ToList());
VesselCoordinatePromptHandler.RegisterPrompts(SystemDict.Where(system => system.Value.Config.Vessel?.coords != null).Select(x => x.Value).ToList());
}
public void EnableWarpDrive()

View File

@ -158,11 +158,11 @@ namespace NewHorizons.Utility
return transform.rotation * localRotation;
}
public static bool CheckAllCoordinates(this NomaiCoordinateInterface nomaiCoordinateInterface) => Main.SystemDict.Where(system => system.Value.Config.coords != null).Select(system => new KeyValuePair<string, NomaiCoordinates>(system.Key, system.Value.Config.coords)).Any(system => nomaiCoordinateInterface.CheckCoordinates(system.Key, system.Value));
public static bool CheckAllCoordinates(this NomaiCoordinateInterface nomaiCoordinateInterface) => Main.SystemDict.Where(system => system.Value.Config.Vessel?.coords != null).Select(system => new KeyValuePair<string, NomaiCoordinates>(system.Key, system.Value.Config.Vessel.coords)).Any(system => nomaiCoordinateInterface.CheckCoordinates(system.Key, system.Value));
public static bool CheckAllCoordinates(this NomaiCoordinateInterface nomaiCoordinateInterface, out string selectedSystem)
{
foreach (KeyValuePair<string, NomaiCoordinates> cbs in Main.SystemDict.Where(system => system.Value.Config.coords != null).Select(system => new KeyValuePair<string, NomaiCoordinates>(system.Key, system.Value.Config.coords)))
foreach (KeyValuePair<string, NomaiCoordinates> cbs in Main.SystemDict.Where(system => system.Value.Config.Vessel?.coords != null).Select(system => new KeyValuePair<string, NomaiCoordinates>(system.Key, system.Value.Config.Vessel.coords)))
{
if (CheckCoordinates(nomaiCoordinateInterface, cbs.Key, cbs.Value))
{