Move game over stuff to its own module, add condition

This commit is contained in:
xen-42 2025-02-14 21:51:37 -05:00
parent 392fc404f4
commit 0dfc2381a3
5 changed files with 51 additions and 9 deletions

View File

@ -12,9 +12,10 @@ namespace NewHorizons.Builder.Volumes
var volume = VolumeBuilder.Make<LoadCreditsVolume>(planetGO, sector, info); var volume = VolumeBuilder.Make<LoadCreditsVolume>(planetGO, sector, info);
volume.creditsType = info.creditsType; volume.creditsType = info.creditsType;
volume.gameOverText = info.gameOverText; volume.gameOverText = info.gameOver?.text;
volume.deathType = info.deathType == null ? null : EnumUtils.Parse(info.deathType.ToString(), DeathType.Default); volume.deathType = info.deathType == null ? null : EnumUtils.Parse(info.deathType.ToString(), DeathType.Default);
volume.colour = info.gameOverTextColour?.ToColor(); volume.colour = info.gameOver?.colour?.ToColor();
volume.condition = info.gameOver?.condition;
return volume; return volume;
} }

View File

@ -16,6 +16,7 @@ namespace NewHorizons.Components.Volumes
public DeathType? deathType = DeathType.Default; public DeathType? deathType = DeathType.Default;
public Color? colour; public Color? colour;
public string condition;
private GameOverController _gameOverController; private GameOverController _gameOverController;
private PlayerCameraEffectController _playerCameraEffectController; private PlayerCameraEffectController _playerCameraEffectController;
@ -28,7 +29,7 @@ namespace NewHorizons.Components.Volumes
public override void OnTriggerVolumeEntry(GameObject hitObj) public override void OnTriggerVolumeEntry(GameObject hitObj)
{ {
if (hitObj.CompareTag("PlayerDetector") && enabled) if (hitObj.CompareTag("PlayerDetector") && enabled && (string.IsNullOrEmpty(condition) || DialogueConditionManager.SharedInstance.GetConditionState(condition)))
{ {
// Have to run it off the mod behaviour since the game over controller disables everything // Have to run it off the mod behaviour since the game over controller disables everything
Delay.StartCoroutine(GameOver()); Delay.StartCoroutine(GameOver());
@ -106,6 +107,8 @@ namespace NewHorizons.Components.Volumes
default: default:
// GameOverController disables post processing // GameOverController disables post processing
_gameOverController._flashbackCamera.postProcessing.enabled = true; _gameOverController._flashbackCamera.postProcessing.enabled = true;
// For some reason this isn't getting set sometimes
AudioListener.volume = 1;
GlobalMessenger.FireEvent("TriggerFlashback"); GlobalMessenger.FireEvent("TriggerFlashback");
break; break;
} }

View File

@ -658,6 +658,21 @@ namespace NewHorizons.External.Configs
} }
} }
if (Volumes?.creditsVolume != null)
{
foreach (var volume in Volumes.creditsVolume)
{
if (!string.IsNullOrEmpty(volume.gameOverText))
{
if (volume.gameOver == null)
{
volume.gameOver = new();
}
volume.gameOver.text = volume.gameOverText;
}
}
}
if (Base.invulnerableToSun) if (Base.invulnerableToSun)
{ {
Base.hasFluidDetector = false; Base.hasFluidDetector = false;

View File

@ -0,0 +1,25 @@
using NewHorizons.External.SerializableData;
using Newtonsoft.Json;
namespace NewHorizons.External.Modules
{
[JsonObject]
public class GameOverModule
{
/// <summary>
/// Text displayed in orange on game over. For localization, put translations under UI.
/// </summary>
public string text;
/// <summary>
/// Change the colour of the game over text. Leave empty to use the default orange.
/// </summary>
public MColor colour;
/// <summary>
/// Condition that must be true for this game over to trigger. Leave empty to always trigger this game over.
/// Note this is a regular dialogue condition, not a persistent condition.
/// </summary>
public string condition;
}
}

View File

@ -1,6 +1,6 @@
using NewHorizons.External.SerializableData;
using NewHorizons.External.SerializableEnums; using NewHorizons.External.SerializableEnums;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.ComponentModel; using System.ComponentModel;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos namespace NewHorizons.External.Modules.Volumes.VolumeInfos
@ -10,9 +10,7 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{ {
[DefaultValue("none")] public NHCreditsType creditsType = NHCreditsType.None; [DefaultValue("none")] public NHCreditsType creditsType = NHCreditsType.None;
/// <summary> [Obsolete("Use gameOver")]
/// Text displayed in orange on game over. For localization, put translations under UI.
/// </summary>
public string gameOverText; public string gameOverText;
/// <summary> /// <summary>
@ -21,8 +19,8 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos
[DefaultValue("default")] public NHDeathType? deathType = null; [DefaultValue("default")] public NHDeathType? deathType = null;
/// <summary> /// <summary>
/// Change the colour of the game over text. Leave empty to use the default orange. /// The game over message to display. Leave empty to go straight to credits.
/// </summary> /// </summary>
public MColor gameOverTextColour; public GameOverModule gameOver;
} }
} }