mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add global music module
This commit is contained in:
parent
ad72afb6fc
commit
e776fb2564
41
NewHorizons/Components/EOTE/DreamWorldEndTimes.cs
Normal file
41
NewHorizons/Components/EOTE/DreamWorldEndTimes.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using NewHorizons.Utility.Files;
|
||||||
|
using OWML.Common;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Components.EOTE
|
||||||
|
{
|
||||||
|
public class DreamWorldEndTimes : MonoBehaviour
|
||||||
|
{
|
||||||
|
private IModBehaviour _mod;
|
||||||
|
private string _endTimesAudio;
|
||||||
|
private IModBehaviour _dreamMod;
|
||||||
|
private string _endTimesDreamAudio;
|
||||||
|
|
||||||
|
public void SetEndTimesAudio(string audio, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
_mod = mod;
|
||||||
|
_endTimesAudio = audio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AssignEndTimes(OWAudioSource endTimesSource) => Assign(endTimesSource, _endTimesAudio, _mod, AudioType.EndOfTime);
|
||||||
|
|
||||||
|
public void SetEndTimesDreamAudio(string audio, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
_dreamMod = mod;
|
||||||
|
_endTimesDreamAudio = audio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AssignEndTimesDream(OWAudioSource endTimesSource) => Assign(endTimesSource, _endTimesDreamAudio, _dreamMod, AudioType.EndOfTime_Dream);
|
||||||
|
|
||||||
|
public static void Assign(OWAudioSource endTimesSource, string endTimesClip, IModBehaviour mod, AudioType defaultClip)
|
||||||
|
{
|
||||||
|
endTimesSource.Stop();
|
||||||
|
if (!string.IsNullOrWhiteSpace(endTimesClip))
|
||||||
|
{
|
||||||
|
AudioUtilities.SetAudioClip(endTimesSource, endTimesClip, mod);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
endTimesSource.AssignAudioLibraryClip(defaultClip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
69
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
69
NewHorizons/External/Configs/StarSystemConfig.cs
vendored
@ -82,11 +82,14 @@ namespace NewHorizons.External.Configs
|
|||||||
[Obsolete("travelAudioFilePath is deprecated, please use travelAudio instead")]
|
[Obsolete("travelAudioFilePath is deprecated, please use travelAudio instead")]
|
||||||
public string travelAudioFilePath;
|
public string travelAudioFilePath;
|
||||||
|
|
||||||
/// <summary>
|
[Obsolete("travelAudio is deprecated, please use travelAudio instead")]
|
||||||
/// The audio that will play when travelling in space. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
|
||||||
/// </summary>
|
|
||||||
public string travelAudio;
|
public string travelAudio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replace music that plays globally
|
||||||
|
/// </summary>
|
||||||
|
public GlobalMusicModule GlobalMusic;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configure warping to this system with the vessel
|
/// Configure warping to this system with the vessel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -192,6 +195,45 @@ namespace NewHorizons.External.Configs
|
|||||||
public string backPath;
|
public string backPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class GlobalMusicModule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The audio that will play when travelling in space. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
||||||
|
/// </summary>
|
||||||
|
public string travelAudio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The audio that will play right before the loop ends. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
||||||
|
/// </summary>
|
||||||
|
public string endTimesAudio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The audio that will play right before the loop ends while inside the dreamworld. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
||||||
|
/// </summary>
|
||||||
|
public string endTimesDreamAudio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The audio that will play when travelling through a bramble dimension. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
||||||
|
/// </summary>
|
||||||
|
public string brambleDimensionAudio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The audio that will play when you leave the ash twin project after taking out the advanced warp core. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
||||||
|
/// </summary>
|
||||||
|
public string finalEndTimesIntroAudio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The audio that will loop after the final end times intro. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
||||||
|
/// </summary>
|
||||||
|
public string finalEndTimesLoopAudio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The audio that will loop after the final end times intro while inside a bramble dimension. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
||||||
|
/// </summary>
|
||||||
|
public string finalEndTimesBrambleDimensionAudio;
|
||||||
|
}
|
||||||
|
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class VesselModule
|
public class VesselModule
|
||||||
{
|
{
|
||||||
@ -283,7 +325,6 @@ namespace NewHorizons.External.Configs
|
|||||||
// If current one is null take the other
|
// If current one is null take the other
|
||||||
factRequiredForWarp = string.IsNullOrEmpty(factRequiredForWarp) ? otherConfig.factRequiredForWarp : factRequiredForWarp;
|
factRequiredForWarp = string.IsNullOrEmpty(factRequiredForWarp) ? otherConfig.factRequiredForWarp : factRequiredForWarp;
|
||||||
Skybox = Skybox == null ? otherConfig.Skybox : Skybox;
|
Skybox = Skybox == null ? otherConfig.Skybox : Skybox;
|
||||||
travelAudio = string.IsNullOrEmpty(travelAudio) ? otherConfig.travelAudio : travelAudio;
|
|
||||||
|
|
||||||
// False by default so if one is true go true
|
// False by default so if one is true go true
|
||||||
mapRestricted = mapRestricted || otherConfig.mapRestricted;
|
mapRestricted = mapRestricted || otherConfig.mapRestricted;
|
||||||
@ -302,6 +343,21 @@ namespace NewHorizons.External.Configs
|
|||||||
Vessel ??= otherConfig.Vessel;
|
Vessel ??= otherConfig.Vessel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GlobalMusic != null && otherConfig.GlobalMusic != null)
|
||||||
|
{
|
||||||
|
GlobalMusic.travelAudio = string.IsNullOrEmpty(GlobalMusic.travelAudio) ? otherConfig.GlobalMusic.travelAudio : GlobalMusic.travelAudio;
|
||||||
|
GlobalMusic.endTimesAudio = string.IsNullOrEmpty(GlobalMusic.endTimesAudio) ? otherConfig.GlobalMusic.endTimesAudio : GlobalMusic.endTimesAudio;
|
||||||
|
GlobalMusic.endTimesDreamAudio = string.IsNullOrEmpty(GlobalMusic.endTimesDreamAudio) ? otherConfig.GlobalMusic.endTimesDreamAudio : GlobalMusic.endTimesDreamAudio;
|
||||||
|
GlobalMusic.brambleDimensionAudio = string.IsNullOrEmpty(GlobalMusic.brambleDimensionAudio) ? otherConfig.GlobalMusic.brambleDimensionAudio : GlobalMusic.brambleDimensionAudio;
|
||||||
|
GlobalMusic.finalEndTimesIntroAudio = string.IsNullOrEmpty(GlobalMusic.finalEndTimesIntroAudio) ? otherConfig.GlobalMusic.finalEndTimesIntroAudio : GlobalMusic.finalEndTimesIntroAudio;
|
||||||
|
GlobalMusic.finalEndTimesLoopAudio = string.IsNullOrEmpty(GlobalMusic.finalEndTimesLoopAudio) ? otherConfig.GlobalMusic.finalEndTimesLoopAudio : GlobalMusic.finalEndTimesLoopAudio;
|
||||||
|
GlobalMusic.finalEndTimesBrambleDimensionAudio = string.IsNullOrEmpty(GlobalMusic.finalEndTimesBrambleDimensionAudio) ? otherConfig.GlobalMusic.finalEndTimesBrambleDimensionAudio : GlobalMusic.finalEndTimesBrambleDimensionAudio;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalMusic ??= otherConfig.GlobalMusic;
|
||||||
|
}
|
||||||
|
|
||||||
entryPositions = Concatenate(entryPositions, otherConfig.entryPositions);
|
entryPositions = Concatenate(entryPositions, otherConfig.entryPositions);
|
||||||
curiosities = Concatenate(curiosities, otherConfig.curiosities);
|
curiosities = Concatenate(curiosities, otherConfig.curiosities);
|
||||||
initialReveal = Concatenate(initialReveal, otherConfig.initialReveal);
|
initialReveal = Concatenate(initialReveal, otherConfig.initialReveal);
|
||||||
@ -319,6 +375,11 @@ namespace NewHorizons.External.Configs
|
|||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
if (!string.IsNullOrEmpty(travelAudioClip)) travelAudio = travelAudioClip;
|
if (!string.IsNullOrEmpty(travelAudioClip)) travelAudio = travelAudioClip;
|
||||||
if (!string.IsNullOrEmpty(travelAudioFilePath)) travelAudio = travelAudioFilePath;
|
if (!string.IsNullOrEmpty(travelAudioFilePath)) travelAudio = travelAudioFilePath;
|
||||||
|
if (!string.IsNullOrEmpty(travelAudio))
|
||||||
|
{
|
||||||
|
if (GlobalMusic == null) GlobalMusic = new GlobalMusicModule();
|
||||||
|
if (string.IsNullOrEmpty(GlobalMusic.travelAudio)) GlobalMusic.travelAudio = travelAudio;
|
||||||
|
}
|
||||||
if (coords != null || vesselPosition != null || vesselRotation != null || warpExitPosition != null || warpExitRotation != null)
|
if (coords != null || vesselPosition != null || vesselRotation != null || warpExitPosition != null || warpExitRotation != null)
|
||||||
{
|
{
|
||||||
if (Vessel == null)
|
if (Vessel == null)
|
||||||
|
|||||||
@ -8,6 +8,7 @@ using NewHorizons.Utility.OuterWilds;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
using NewHorizons.OtherMods;
|
using NewHorizons.OtherMods;
|
||||||
|
using NewHorizons.Components.EOTE;
|
||||||
|
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
{
|
{
|
||||||
@ -46,9 +47,42 @@ namespace NewHorizons.Handlers
|
|||||||
TimeLoopUtilities.SetLoopDuration(system.Config.loopDuration);
|
TimeLoopUtilities.SetLoopDuration(system.Config.loopDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(system.Config.travelAudio))
|
if (!string.IsNullOrEmpty(system.Config.GlobalMusic.travelAudio))
|
||||||
{
|
{
|
||||||
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._travelSource, system.Config.travelAudio, system.Mod));
|
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._travelSource, system.Config.GlobalMusic.travelAudio, system.Mod));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(system.Config.GlobalMusic.endTimesAudio))
|
||||||
|
{
|
||||||
|
Delay.FireOnNextUpdate(() => {
|
||||||
|
Locator.GetGlobalMusicController().gameObject.GetAddComponent<DreamWorldEndTimes>().SetEndTimesAudio(system.Config.GlobalMusic.endTimesAudio, system.Mod);
|
||||||
|
AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._endTimesSource, system.Config.GlobalMusic.endTimesAudio, system.Mod);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(system.Config.GlobalMusic.endTimesDreamAudio))
|
||||||
|
{
|
||||||
|
Delay.FireOnNextUpdate(() => Locator.GetGlobalMusicController().gameObject.GetAddComponent<DreamWorldEndTimes>().SetEndTimesDreamAudio(system.Config.GlobalMusic.endTimesDreamAudio, system.Mod));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(system.Config.GlobalMusic.brambleDimensionAudio))
|
||||||
|
{
|
||||||
|
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._darkBrambleSource, system.Config.GlobalMusic.brambleDimensionAudio, system.Mod));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(system.Config.GlobalMusic.finalEndTimesIntroAudio))
|
||||||
|
{
|
||||||
|
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._finalEndTimesIntroSource, system.Config.GlobalMusic.finalEndTimesIntroAudio, system.Mod));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(system.Config.GlobalMusic.finalEndTimesLoopAudio))
|
||||||
|
{
|
||||||
|
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._finalEndTimesLoopSource, system.Config.GlobalMusic.finalEndTimesLoopAudio, system.Mod));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(system.Config.GlobalMusic.finalEndTimesBrambleDimensionAudio))
|
||||||
|
{
|
||||||
|
Delay.FireOnNextUpdate(() => AudioUtilities.SetAudioClip(Locator.GetGlobalMusicController()._finalEndTimesDarkBrambleSource, system.Config.GlobalMusic.finalEndTimesBrambleDimensionAudio, system.Mod));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -690,7 +690,7 @@ namespace NewHorizons
|
|||||||
|
|
||||||
if (SystemDict.ContainsKey(starSystemName))
|
if (SystemDict.ContainsKey(starSystemName))
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(SystemDict[starSystemName].Config.travelAudio) && SystemDict[starSystemName].Config.Skybox == null)
|
if (SystemDict[starSystemName].Config.GlobalMusic == null && SystemDict[starSystemName].Config.Skybox == null)
|
||||||
SystemDict[starSystemName].Mod = mod;
|
SystemDict[starSystemName].Mod = mod;
|
||||||
SystemDict[starSystemName].Config.Merge(starSystemConfig);
|
SystemDict[starSystemName].Config.Merge(starSystemConfig);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using NewHorizons.Components.EOTE;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NewHorizons.Patches;
|
namespace NewHorizons.Patches;
|
||||||
@ -35,4 +36,59 @@ public class GlobalMusicControllerPatches
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(nameof(GlobalMusicController.OnEnterDreamWorld))]
|
||||||
|
public static bool GlobalMusicController_OnEnterDreamWorld(GlobalMusicController __instance)
|
||||||
|
{
|
||||||
|
if (__instance._playingFinalEndTimes)
|
||||||
|
{
|
||||||
|
__instance._finalEndTimesIntroSource.Stop();
|
||||||
|
__instance._finalEndTimesLoopSource.Stop();
|
||||||
|
__instance._finalEndTimesDarkBrambleSource.FadeIn(1f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (__instance.TryGetComponent(out DreamWorldEndTimes dreamWorldEndTimes))
|
||||||
|
{
|
||||||
|
dreamWorldEndTimes.AssignEndTimesDream(__instance._endTimesSource);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__instance._endTimesSource.Stop();
|
||||||
|
__instance._endTimesSource.AssignAudioLibraryClip(AudioType.EndOfTime_Dream);
|
||||||
|
}
|
||||||
|
__instance._playingEndTimes = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(nameof(GlobalMusicController.OnExitDreamWorld))]
|
||||||
|
public static bool GlobalMusicController_OnExitDreamWorld(GlobalMusicController __instance)
|
||||||
|
{
|
||||||
|
if (__instance._playingFinalEndTimes)
|
||||||
|
{
|
||||||
|
__instance._finalEndTimesLoopSource.FadeIn(1f);
|
||||||
|
__instance._finalEndTimesDarkBrambleSource.Stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (__instance.TryGetComponent(out DreamWorldEndTimes dreamWorldEndTimes))
|
||||||
|
{
|
||||||
|
dreamWorldEndTimes.AssignEndTimesDream(__instance._endTimesSource);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__instance._endTimesSource.Stop();
|
||||||
|
__instance._endTimesSource.AssignAudioLibraryClip(AudioType.EndOfTime);
|
||||||
|
}
|
||||||
|
__instance._playingEndTimes = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user