mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Patch UpdateEndTimesMusic
This commit is contained in:
parent
c0b8d9ebc9
commit
63cd86883b
@ -204,12 +204,12 @@ namespace NewHorizons.External.Configs
|
|||||||
public string travelAudio;
|
public string travelAudio;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The audio that will play for 85 seconds before the loop ends. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
/// 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>
|
/// </summary>
|
||||||
public string endTimesAudio;
|
public string endTimesAudio;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The audio that will play for 85 seconds before the loop ends while inside the dreamworld. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
|
/// 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>
|
/// </summary>
|
||||||
public string endTimesDreamAudio;
|
public string endTimesDreamAudio;
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using NewHorizons.Components.EOTE;
|
using NewHorizons.Components.EOTE;
|
||||||
|
using NewHorizons.Utility;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection.Emit;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NewHorizons.Patches;
|
namespace NewHorizons.Patches;
|
||||||
|
|
||||||
[HarmonyPatch(typeof(GlobalMusicController))]
|
[HarmonyPatch(typeof(GlobalMusicController))]
|
||||||
public class GlobalMusicControllerPatches
|
public static class GlobalMusicControllerPatches
|
||||||
{
|
{
|
||||||
private static AudioDetector _audioDetector;
|
private static AudioDetector _audioDetector;
|
||||||
|
|
||||||
@ -37,6 +40,38 @@ public class GlobalMusicControllerPatches
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces any <c>85f</c> with <see cref="NewHorizonsExtensions.GetSecondsBeforeSupernovaPlayTime(GlobalMusicController)"/>
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyTranspiler]
|
||||||
|
[HarmonyPatch(nameof(GlobalMusicController.UpdateEndTimesMusic))]
|
||||||
|
public static IEnumerable<CodeInstruction> GlobalMusicController_UpdateEndTimesMusic(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
|
{
|
||||||
|
return new CodeMatcher(instructions, generator).MatchForward(true,
|
||||||
|
new CodeMatch(OpCodes.Call),
|
||||||
|
new CodeMatch(OpCodes.Ldc_R4, 85f),
|
||||||
|
new CodeMatch(OpCodes.Ble_Un)
|
||||||
|
).Advance(-1).RemoveInstruction().Insert(
|
||||||
|
new CodeInstruction(OpCodes.Ldarg_0),
|
||||||
|
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(NewHorizonsExtensions), nameof(NewHorizonsExtensions.GetSecondsBeforeSupernovaPlayTime)))
|
||||||
|
).MatchForward(true,
|
||||||
|
new CodeMatch(OpCodes.Call),
|
||||||
|
new CodeMatch(OpCodes.Ldc_R4, 85f),
|
||||||
|
new CodeMatch(OpCodes.Bge_Un)
|
||||||
|
).Advance(-1).RemoveInstruction().Insert(
|
||||||
|
new CodeInstruction(OpCodes.Ldarg_0),
|
||||||
|
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(NewHorizonsExtensions), nameof(NewHorizonsExtensions.GetSecondsBeforeSupernovaPlayTime)))
|
||||||
|
).MatchForward(false,
|
||||||
|
new CodeMatch(OpCodes.Ldc_R4, 85f),
|
||||||
|
new CodeMatch(OpCodes.Call),
|
||||||
|
new CodeMatch(OpCodes.Sub)
|
||||||
|
).RemoveInstruction().Insert(
|
||||||
|
new CodeInstruction(OpCodes.Ldarg_0),
|
||||||
|
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(NewHorizonsExtensions), nameof(NewHorizonsExtensions.GetSecondsBeforeSupernovaPlayTime)))
|
||||||
|
).InstructionEnumeration();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom end times for dreamworld
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(nameof(GlobalMusicController.OnEnterDreamWorld))]
|
[HarmonyPatch(nameof(GlobalMusicController.OnEnterDreamWorld))]
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using HarmonyLib;
|
||||||
using NewHorizons.External.Configs;
|
using NewHorizons.External.Configs;
|
||||||
using NewHorizons.External.Modules.VariableSize;
|
using NewHorizons.External.Modules.VariableSize;
|
||||||
using NewHorizons.External.SerializableData;
|
using NewHorizons.External.SerializableData;
|
||||||
@ -425,5 +426,28 @@ namespace NewHorizons.Utility
|
|||||||
playerCameraEffectController._owCamera.postProcessingSettings.bloom.threshold = 0f;
|
playerCameraEffectController._owCamera.postProcessingSettings.bloom.threshold = 0f;
|
||||||
playerCameraEffectController._owCamera.postProcessingSettings.eyeMaskEnabled = true;
|
playerCameraEffectController._owCamera.postProcessingSettings.eyeMaskEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float GetSecondsBeforeSupernovaPlayTime(this GlobalMusicController globalMusicController)
|
||||||
|
{
|
||||||
|
var clip = globalMusicController._endTimesSource.audioLibraryClip;
|
||||||
|
if (clip == AudioType.EndOfTime || clip == AudioType.EndOfTime_Dream)
|
||||||
|
return GlobalMusicController.secondsBeforeSupernovaPlayTime;
|
||||||
|
return globalMusicController._endTimesSource.clip.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CodeMatcher LogInstructions(this CodeMatcher matcher, string prefix)
|
||||||
|
{
|
||||||
|
matcher.InstructionEnumeration().LogInstructions(prefix);
|
||||||
|
return matcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<CodeInstruction> LogInstructions(this IEnumerable<CodeInstruction> instructions, string prefix)
|
||||||
|
{
|
||||||
|
var message = prefix;
|
||||||
|
foreach (var instruction in instructions)
|
||||||
|
message += $"\n{instruction}";
|
||||||
|
Debug.LogError(message);
|
||||||
|
return instructions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user