Add volumes for changing star system and triggering credits

This commit is contained in:
Nick 2023-01-21 23:35:13 -05:00
parent 086ca65f9d
commit f1097a65d5
9 changed files with 157 additions and 4 deletions

View File

@ -203,7 +203,7 @@ namespace NewHorizons.Builder.Body
if (hasDestructionVolume) destructionVolumeGO.AddComponent<BlackHoleDestructionVolume>(); if (hasDestructionVolume) destructionVolumeGO.AddComponent<BlackHoleDestructionVolume>();
else if (targetStarSystem != null) else if (targetStarSystem != null)
{ {
var wormholeVolume = destructionVolumeGO.AddComponent<ChangeStarSystemVolume>(); var wormholeVolume = destructionVolumeGO.AddComponent<BlackHoleWarpVolume>();
wormholeVolume.TargetSolarSystem = targetStarSystem; wormholeVolume.TargetSolarSystem = targetStarSystem;
} }
} }

View File

@ -0,0 +1,18 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
internal static class ChangeStarSystemVolumeBuilder
{
public static WarpVolume Make(GameObject planetGO, Sector sector, VolumesModule.ChangeStarSystemVolumeInfo info)
{
var volume = VolumeBuilder.Make<WarpVolume>(planetGO, sector, info);
volume.TargetSolarSystem = info.targetStarSystem;
return volume;
}
}
}

View File

@ -0,0 +1,18 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
internal static class CreditsVolumeBuilder
{
public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, VolumesModule.LoadCreditsVolumeInfo info)
{
var volume = VolumeBuilder.Make<LoadCreditsVolume>(planetGO, sector, info);
volume.creditsType = info.creditsType;
return volume;
}
}
}

View File

@ -192,6 +192,20 @@ namespace NewHorizons.Builder.Volumes
VolumeBuilder.Make<LightlessLightSourceVolume>(go, sector, lightSourceVolume); VolumeBuilder.Make<LightlessLightSourceVolume>(go, sector, lightSourceVolume);
} }
} }
if (config.Volumes.solarSystemVolume != null)
{
foreach (var solarSystemVolume in config.Volumes.solarSystemVolume)
{
ChangeStarSystemVolumeBuilder.Make(go, sector, solarSystemVolume);
}
}
if (config.Volumes.creditsVolume != null)
{
foreach (var creditsVolume in config.Volumes.creditsVolume)
{
CreditsVolumeBuilder.Make(go, sector, creditsVolume);
}
}
} }
} }
} }

View File

@ -1,6 +1,6 @@
namespace NewHorizons.Components.Volumes namespace NewHorizons.Components.Volumes
{ {
public class ChangeStarSystemVolume : BlackHoleDestructionVolume public class BlackHoleWarpVolume : BlackHoleDestructionVolume
{ {
public string TargetSolarSystem { get; set; } public string TargetSolarSystem { get; set; }

View File

@ -0,0 +1,35 @@
using NewHorizons.External.Modules;
using UnityEngine;
namespace NewHorizons.Components.Volumes
{
internal class LoadCreditsVolume : BaseVolume
{
public VolumesModule.LoadCreditsVolumeInfo.CreditsType creditsType = VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast;
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
switch(creditsType)
{
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast:
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Final:
LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack);
break;
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Kazoo:
TimelineObliterationController.s_hasRealityEnded = true;
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
}
}
}
public override void OnTriggerVolumeExit(GameObject hitObj)
{
}
}
}

View File

@ -0,0 +1,31 @@
using NewHorizons.External.Modules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Components.Volumes
{
internal class WarpVolume : BaseVolume
{
public string TargetSolarSystem;
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
if (Main.Instance.CurrentStarSystem != TargetSolarSystem) // Otherwise it really breaks idk why
{
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem, PlayerState.AtFlightConsole());
}
}
}
public override void OnTriggerVolumeExit(GameObject hitObj)
{
}
}
}

View File

@ -106,6 +106,16 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public PriorityVolumeInfo[] zeroGravityVolumes; public PriorityVolumeInfo[] zeroGravityVolumes;
/// <summary>
/// Entering this volume will load a new solar system.
/// </summary>
public ChangeStarSystemVolumeInfo[] solarSystemVolume;
/// <summary>
/// Enter this volume to be sent to the end credits scene
/// </summary>
public LoadCreditsVolumeInfo[] creditsVolume;
[JsonObject] [JsonObject]
public class VolumeInfo public class VolumeInfo
{ {
@ -136,6 +146,33 @@ namespace NewHorizons.External.Modules
public string rename; public string rename;
} }
[JsonObject]
public class ChangeStarSystemVolumeInfo : VolumeInfo
{
/// <summary>
/// The star system that entering this volume will send you to.
/// </summary>
[DefaultValue("SolarSystem")]
public string targetStarSystem;
}
[JsonObject]
public class LoadCreditsVolumeInfo : VolumeInfo
{
[JsonConverter(typeof(StringEnumConverter))]
public enum CreditsType
{
[EnumMember(Value = @"fast")] Fast = 0,
[EnumMember(Value = @"final")] Final = 1,
[EnumMember(Value = @"kazoo")] Kazoo = 2
}
[DefaultValue("fast")]
public CreditsType creditsType = CreditsType.Fast;
}
[JsonObject] [JsonObject]
public class PriorityVolumeInfo : VolumeInfo public class PriorityVolumeInfo : VolumeInfo
{ {

View File

@ -4,7 +4,7 @@
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", "author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book",
"name": "New Horizons", "name": "New Horizons",
"uniqueName": "xen.NewHorizons", "uniqueName": "xen.NewHorizons",
"version": "1.8.5", "version": "1.8.6",
"owmlVersion": "2.9.0", "owmlVersion": "2.9.0",
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ],