Allow system change volumes to specify custom targets #917

This commit is contained in:
xen-42 2024-10-04 15:04:50 -04:00
parent d2f88ed9ad
commit 4a80fa7076
9 changed files with 53 additions and 15 deletions

View File

@ -1,18 +1,17 @@
using NewHorizons.External.Configs;
using NewHorizons.Utility;
using NewHorizons.External.Modules.VariableSize;
using UnityEngine;
using System.Collections.Generic;
using NewHorizons.Components.SizeControllers;
using Color = UnityEngine.Color;
using NewHorizons.Components.Volumes;
using NewHorizons.Builder.Props;
using NewHorizons.Utility.OWML;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.External.SerializableData;
using NewHorizons.Builder.Volumes;
using NewHorizons.Components.SizeControllers;
using NewHorizons.Components.Volumes;
using NewHorizons.External.Configs;
using NewHorizons.External.Modules.VariableSize;
using NewHorizons.External.SerializableData;
using NewHorizons.Utility;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using System;
using System.Collections.Generic;
using UnityEngine;
using Color = UnityEngine.Color;
namespace NewHorizons.Builder.Body
{
@ -88,7 +87,7 @@ namespace NewHorizons.Builder.Body
Vector3 localRotation = singularity?.rotation == null ? Vector3.zero : singularity.rotation;
GameObject newSingularity = MakeSingularity(go, sector, localPosition, localRotation, polarity, horizonRadius, distortRadius,
hasHazardVolume, singularity.targetStarSystem, singularity.curve, singularity.hasWarpEffects, singularity.renderQueueOverride, singularity.rename, singularity.parentPath, singularity.isRelativeToParent);
hasHazardVolume, singularity.targetStarSystem, singularity.spawnPointID, singularity.curve, singularity.hasWarpEffects, singularity.renderQueueOverride, singularity.rename, singularity.parentPath, singularity.isRelativeToParent);
var uniqueID = string.IsNullOrEmpty(singularity.uniqueID) ? config.name : singularity.uniqueID;
@ -161,7 +160,7 @@ namespace NewHorizons.Builder.Body
}
public static GameObject MakeSingularity(GameObject planetGO, Sector sector, Vector3 position, Vector3 rotation, bool polarity, float horizon, float distort,
bool hasDestructionVolume, string targetStarSystem = null, TimeValuePair[] curve = null, bool warpEffects = true, int renderQueue = 2985, string rename = null, string parentPath = null, bool isRelativeToParent = false)
bool hasDestructionVolume, string targetStarSystem = null, string targetSpawnID = null, TimeValuePair[] curve = null, bool warpEffects = true, int renderQueue = 2985, string rename = null, string parentPath = null, bool isRelativeToParent = false)
{
// polarity true = black, false = white
@ -233,6 +232,7 @@ namespace NewHorizons.Builder.Body
{
var wormholeVolume = destructionVolumeGO.AddComponent<BlackHoleWarpVolume>();
wormholeVolume.TargetSolarSystem = targetStarSystem;
wormholeVolume.TargetSpawnID = targetSpawnID;
}
}
else

View File

@ -94,6 +94,7 @@ namespace NewHorizons.Builder.General
suitUpQueued = true;
Delay.RunWhen(() => Main.IsSystemReady, () =>
{
suitUpQueued = false;
if (Main.Instance.IsWarpingFromVessel || (!Main.Instance.IsWarpingFromShip && (PlayerSpawnInfo?.startWithSuit ?? false)))
{
SuitUp();
@ -108,7 +109,6 @@ namespace NewHorizons.Builder.General
public static void SuitUp()
{
suitUpQueued = false;
if (!Locator.GetPlayerController()._isWearingSuit)
{
Locator.GetPlayerSuit().SuitUp(false, true, true);

View File

@ -11,6 +11,7 @@ namespace NewHorizons.Builder.Volumes
var volume = VolumeBuilder.Make<WarpVolume>(planetGO, sector, info);
volume.TargetSolarSystem = info.targetStarSystem;
volume.TargetSpawnID = info.spawnPointID;
return volume;
}

View File

@ -1,8 +1,11 @@
using NewHorizons.Handlers;
namespace NewHorizons.Components.Volumes
{
public class BlackHoleWarpVolume : BlackHoleDestructionVolume
{
public string TargetSolarSystem { get; set; }
public string TargetSpawnID { get; set; }
public override void Awake()
{
@ -19,6 +22,7 @@ namespace NewHorizons.Components.Volumes
{
Locator.GetPlayerAudioController().PlayOneShotInternal(AudioType.BH_BlackHoleEmission);
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
PlayerSpawnHandler.TargetSpawnID = TargetSpawnID;
}
}
}

View File

@ -1,3 +1,4 @@
using NewHorizons.Handlers;
using UnityEngine;
namespace NewHorizons.Components.Volumes
@ -5,6 +6,7 @@ namespace NewHorizons.Components.Volumes
internal class WarpVolume : BaseVolume
{
public string TargetSolarSystem;
public string TargetSpawnID;
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
@ -13,6 +15,7 @@ namespace NewHorizons.Components.Volumes
if (Main.Instance.CurrentStarSystem != TargetSolarSystem) // Otherwise it really breaks idk why
{
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
PlayerSpawnHandler.TargetSpawnID = TargetSpawnID;
}
}
}

View File

@ -1,3 +1,4 @@
using NewHorizons.Builder.General;
using NewHorizons.External.SerializableData;
using NewHorizons.Handlers;
using Newtonsoft.Json;
@ -61,8 +62,17 @@ namespace NewHorizons.External.Modules
/// </summary>
public string makeDefaultIfPersistentCondition;
/// <summary>
/// ID used to have a black hole or warp volume bring the player to this spawn specifically
/// </summary>
public string id;
public int GetPriority()
{
if (!string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(PlayerSpawnHandler.TargetSpawnID) && id == PlayerSpawnHandler.TargetSpawnID)
{
return 3;
}
if (!string.IsNullOrEmpty(makeDefaultIfFactRevealed) && ShipLogHandler.KnowsFact(makeDefaultIfFactRevealed))
{
return 2;

View File

@ -54,6 +54,12 @@ namespace NewHorizons.External.Modules.VariableSize
/// </summary>
public string targetStarSystem;
/// <summary>
/// If this is a black hole loading a new star system, set the ID of the spawn point you want to use
/// Otherwise, will use the default spawn
/// </summary>
public string spawnPointID;
/// <summary>
/// Type of singularity (white hole or black hole)
/// </summary>

View File

@ -10,5 +10,11 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos
/// The star system that entering this volume will send you to.
/// </summary>
[DefaultValue("SolarSystem")] public string targetStarSystem;
/// <summary>
/// ID assigned to a spawn point in the other system that the player will be sent to
/// Uses the default spawn if not set
/// </summary>
public string spawnPointID;
}
}

View File

@ -9,6 +9,11 @@ namespace NewHorizons.Handlers
{
public static class PlayerSpawnHandler
{
/// <summary>
/// Set during the previous loop, force the player to spawn here
/// </summary>
public static string TargetSpawnID { get; set; }
public static void SetUpPlayerSpawn()
{
if (UsingCustomSpawn())
@ -146,6 +151,9 @@ namespace NewHorizons.Handlers
FixPlayerVelocity();
InvulnerabilityHandler.MakeInvulnerable(false);
// Done spawning
TargetSpawnID = null;
}
private static void FixPlayerVelocity(bool recenter = true)