diff --git a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs index bdd5083a..39440b45 100644 --- a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs @@ -12,9 +12,10 @@ namespace NewHorizons.Builder.Volumes var volume = VolumeBuilder.Make(planetGO, sector, info); 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.colour = info.gameOverTextColour?.ToColor(); + volume.colour = info.gameOver?.colour?.ToColor(); + volume.condition = info.gameOver?.condition; return volume; } diff --git a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs index b611b97b..4ea5e6cd 100644 --- a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs +++ b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs @@ -16,6 +16,7 @@ namespace NewHorizons.Components.Volumes public DeathType? deathType = DeathType.Default; public Color? colour; + public string condition; private GameOverController _gameOverController; private PlayerCameraEffectController _playerCameraEffectController; @@ -28,7 +29,7 @@ namespace NewHorizons.Components.Volumes 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 Delay.StartCoroutine(GameOver()); @@ -106,6 +107,8 @@ namespace NewHorizons.Components.Volumes default: // GameOverController disables post processing _gameOverController._flashbackCamera.postProcessing.enabled = true; + // For some reason this isn't getting set sometimes + AudioListener.volume = 1; GlobalMessenger.FireEvent("TriggerFlashback"); break; } diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 6184ed36..65c4c8f0 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -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) { Base.hasFluidDetector = false; diff --git a/NewHorizons/External/Modules/GameOverModule.cs b/NewHorizons/External/Modules/GameOverModule.cs new file mode 100644 index 00000000..20bd74e4 --- /dev/null +++ b/NewHorizons/External/Modules/GameOverModule.cs @@ -0,0 +1,25 @@ +using NewHorizons.External.SerializableData; +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules +{ + [JsonObject] + public class GameOverModule + { + /// + /// Text displayed in orange on game over. For localization, put translations under UI. + /// + public string text; + + /// + /// Change the colour of the game over text. Leave empty to use the default orange. + /// + public MColor colour; + + /// + /// 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. + /// + public string condition; + } +} diff --git a/NewHorizons/External/Modules/Volumes/VolumeInfos/LoadCreditsVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/VolumeInfos/LoadCreditsVolumeInfo.cs index b798b396..6866e226 100644 --- a/NewHorizons/External/Modules/Volumes/VolumeInfos/LoadCreditsVolumeInfo.cs +++ b/NewHorizons/External/Modules/Volumes/VolumeInfos/LoadCreditsVolumeInfo.cs @@ -1,6 +1,6 @@ -using NewHorizons.External.SerializableData; using NewHorizons.External.SerializableEnums; using Newtonsoft.Json; +using System; using System.ComponentModel; namespace NewHorizons.External.Modules.Volumes.VolumeInfos @@ -10,9 +10,7 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos { [DefaultValue("none")] public NHCreditsType creditsType = NHCreditsType.None; - /// - /// Text displayed in orange on game over. For localization, put translations under UI. - /// + [Obsolete("Use gameOver")] public string gameOverText; /// @@ -21,8 +19,8 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos [DefaultValue("default")] public NHDeathType? deathType = null; /// - /// 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. /// - public MColor gameOverTextColour; + public GameOverModule gameOver; } }