Fix getting locked into the ship log warp drive dialogue when spawning

This commit is contained in:
Nick 2024-03-23 16:56:36 -04:00
parent 568f8a757e
commit 41fcb476db

View File

@ -1,4 +1,6 @@
using HarmonyLib;
using System.Collections;
using UnityEngine.InputSystem;
namespace NewHorizons.Patches.DialoguePatches
{
@ -7,6 +9,29 @@ namespace NewHorizons.Patches.DialoguePatches
{
private static bool _wasLastDialogueInactive = false;
[HarmonyPostfix]
[HarmonyPatch(nameof(RemoteDialogueTrigger.Awake))]
public static void RemoteDialogueTrigger_Awake(RemoteDialogueTrigger __instance)
{
// Wait for player to be up and moving before allowing them to trigger remote dialogue
// Stops you getting locked into dialogue while waking up
if (OWInput.GetInputMode() != InputMode.Character)
{
__instance._collider.enabled = false;
__instance.StartCoroutine(AwakeCoroutine(__instance));
}
}
private static IEnumerator AwakeCoroutine(RemoteDialogueTrigger instance)
{
while (OWInput.GetInputMode() != InputMode.Character)
{
yield return null;
}
instance._collider.enabled = true;
}
/// <summary>
/// Should fix a bug where disabled a CharacterDialogueTree makes its related RemoteDialogueTriggers softlock your game
/// </summary>