From 3b42096d8cef290c1313b93e80bd8edd1fe4b413 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sat, 24 Oct 2020 19:04:50 +0100 Subject: [PATCH] fixed bugs --- QSB/ConversationSync/ConversationManager.cs | 1 + QSB/ConversationSync/ConversationPatches.cs | 12 ++++++- .../ConversationStartEndEvent.cs | 33 ++++++++++--------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/QSB/ConversationSync/ConversationManager.cs b/QSB/ConversationSync/ConversationManager.cs index e4814118..8e68f3f2 100644 --- a/QSB/ConversationSync/ConversationManager.cs +++ b/QSB/ConversationSync/ConversationManager.cs @@ -31,6 +31,7 @@ namespace QSB.ConversationSync DebugLog.ToConsole("Error - Font is null!", MessageType.Error); } BoxPrefab.GetComponent().font = font; + BoxPrefab.GetComponent().color = Color.white; DebugLog.LogState("BoxPrefab", BoxPrefab); } diff --git a/QSB/ConversationSync/ConversationPatches.cs b/QSB/ConversationSync/ConversationPatches.cs index 4ddba1dd..e7c4cd70 100644 --- a/QSB/ConversationSync/ConversationPatches.cs +++ b/QSB/ConversationSync/ConversationPatches.cs @@ -63,13 +63,22 @@ namespace QSB.ConversationSync { position = PlayerRegistry.GetPlayer(playerId).Camera.transform.position; } - float b = ___headTrackingWeight * (float)Mathf.Min(1, (!___lookOnlyWhenTalking) ? ((!____playerInHeadZone) ? 0 : 1) : ((!____inConversation || !____playerInHeadZone) ? 0 : 1)); + float b = ___headTrackingWeight * Mathf.Min(1, (!___lookOnlyWhenTalking) ? ((!____playerInHeadZone) ? 0 : 1) : ((!____inConversation || !____playerInHeadZone) ? 0 : 1)); ____currentLookWeight = Mathf.Lerp(____currentLookWeight, b, Time.deltaTime * 2f); ____currentLookTarget = ___lookSpring.Update(____currentLookTarget, position, Time.deltaTime); ____animator.SetLookAtPosition(____currentLookTarget); ____animator.SetLookAtWeight(____currentLookWeight); return false; + } + public static bool OnZoneExit(CharacterDialogueTree ____dialogueTree) + { + var playerId = ConversationManager.Instance.GetPlayerTalkingToTree(____dialogueTree); + if (playerId == uint.MaxValue) + { + return true; + } + return false; } public static void AddPatches() @@ -79,6 +88,7 @@ namespace QSB.ConversationSync QSB.Helper.HarmonyHelper.AddPostfix("StartConversation", typeof(ConversationPatches), nameof(StartConversation)); QSB.Helper.HarmonyHelper.AddPostfix("EndConversation", typeof(ConversationPatches), nameof(EndConversation)); QSB.Helper.HarmonyHelper.AddPrefix("OnAnimatorIK", typeof(ConversationPatches), nameof(OnAnimatorIK)); + QSB.Helper.HarmonyHelper.AddPrefix("OnZoneExit", typeof(ConversationPatches), nameof(OnZoneExit)); } } } diff --git a/QSB/ConversationSync/ConversationStartEndEvent.cs b/QSB/ConversationSync/ConversationStartEndEvent.cs index 2b8a6cf3..a5599cd4 100644 --- a/QSB/ConversationSync/ConversationStartEndEvent.cs +++ b/QSB/ConversationSync/ConversationStartEndEvent.cs @@ -34,25 +34,28 @@ namespace QSB.ConversationSync return; } var dialogueTree = WorldRegistry.OldDialogueTrees[message.CharacterId]; - var animController = Resources.FindObjectsOfTypeAll().First(x => x.GetValue("_dialogueTree") == dialogueTree); - if (message.State) + var animController = Resources.FindObjectsOfTypeAll().FirstOrDefault(x => x.GetValue("_dialogueTree") == dialogueTree); + if (animController != default(CharacterAnimController)) { - PlayerRegistry.GetPlayer(message.PlayerId).CurrentDialogueID = message.CharacterId; - animController.SetValue("_inConversation", true); - animController.SetValue("_playerInHeadZone", true); - if (animController.GetValue("_hasTalkAnimation")) + if (message.State) { - animController.GetValue("_animator").SetTrigger("Talking"); + PlayerRegistry.GetPlayer(message.PlayerId).CurrentDialogueID = message.CharacterId; + animController.SetValue("_inConversation", true); + animController.SetValue("_playerInHeadZone", true); + if (animController.GetValue("_hasTalkAnimation")) + { + animController.GetValue("_animator").SetTrigger("Talking"); + } } - } - else - { - PlayerRegistry.GetPlayer(message.PlayerId).CurrentDialogueID = -1; - animController.SetValue("_inConversation", false); - animController.SetValue("_playerInHeadZone", false); - if (animController.GetValue("_hasTalkAnimation")) + else { - animController.GetValue("_animator").SetTrigger("Idle"); + PlayerRegistry.GetPlayer(message.PlayerId).CurrentDialogueID = -1; + animController.SetValue("_inConversation", false); + animController.SetValue("_playerInHeadZone", false); + if (animController.GetValue("_hasTalkAnimation")) + { + animController.GetValue("_animator").SetTrigger("Idle"); + } } }