fixed bugs

This commit is contained in:
Mister_Nebula 2020-10-25 13:17:01 +00:00
parent 3b42096d8c
commit 02ba9bd1ba
3 changed files with 43 additions and 3 deletions

View File

@ -52,6 +52,11 @@ namespace QSB.ConversationSync
public void SendCharacterDialogue(int id, string text)
{
if (id == -1)
{
DebugLog.ToConsole("Warning - Tried to send conv. event with char id -1.", MessageType.Warning);
return;
}
GlobalMessenger<uint, string, ConversationType>.FireEvent(EventNames.QSBConversation, (uint)id, text, ConversationType.Character);
}
@ -67,11 +72,21 @@ namespace QSB.ConversationSync
public void SendStart(int charId)
{
if (charId == -1)
{
DebugLog.ToConsole("Warning - Tried to send conv. start event with char id -1.", MessageType.Warning);
return;
}
GlobalMessenger<int, uint, bool>.FireEvent(EventNames.QSBConversationStartEnd, charId, PlayerRegistry.LocalPlayerId, true);
}
public void SendEnd(int charId)
{
if (charId == -1)
{
DebugLog.ToConsole("Warning - Tried to send conv. end event with char id -1.", MessageType.Warning);
return;
}
GlobalMessenger<int, uint, bool>.FireEvent(EventNames.QSBConversationStartEnd, charId, PlayerRegistry.LocalPlayerId, false);
}
@ -100,6 +115,11 @@ namespace QSB.ConversationSync
public void DisplayCharacterConversationBox(int index, string text)
{
if (WorldRegistry.OldDialogueTrees.ElementAtOrDefault(index) == null)
{
DebugLog.ToConsole($"Error - Tried to display character conversation box for id {index}! (Doesn't exist!)", MessageType.Error);
return;
}
var oldDialogueTree = WorldRegistry.OldDialogueTrees[index];
if (BoxMappings.ContainsKey(oldDialogueTree))
{

View File

@ -1,4 +1,6 @@
using QSB.WorldSync;
using OWML.Common;
using QSB.Utility;
using QSB.WorldSync;
using System.Collections.Generic;
using UnityEngine;
@ -9,16 +11,30 @@ namespace QSB.ConversationSync
public static void StartConversation(CharacterDialogueTree __instance)
{
var index = WorldRegistry.OldDialogueTrees.FindIndex(x => x == __instance);
if (index == -1)
{
DebugLog.ToConsole($"Warning - Index for tree {__instance.name} was -1.", MessageType.Warning);
}
PlayerRegistry.LocalPlayer.CurrentDialogueID = index;
ConversationManager.Instance.SendStart(index);
}
public static void EndConversation()
public static bool EndConversation(CharacterDialogueTree __instance)
{
if (!__instance.enabled)
{
return false;
}
if (PlayerRegistry.LocalPlayer.CurrentDialogueID == -1)
{
DebugLog.ToConsole($"Warning - Ending conversation with CurrentDialogueId of -1! Called from {__instance.name}", MessageType.Warning);
return false;
}
ConversationManager.Instance.SendEnd(PlayerRegistry.LocalPlayer.CurrentDialogueID);
ConversationManager.Instance.CloseBoxCharacter(PlayerRegistry.LocalPlayer.CurrentDialogueID);
PlayerRegistry.LocalPlayer.CurrentDialogueID = -1;
ConversationManager.Instance.CloseBoxPlayer();
return true;
}
public static bool InputDialogueOption(int optionIndex, DialogueBoxVer2 ____currentDialogueBox)
@ -86,7 +102,7 @@ namespace QSB.ConversationSync
QSB.Helper.HarmonyHelper.AddPostfix<DialogueNode>("GetNextPage", typeof(ConversationPatches), nameof(GetNextPage));
QSB.Helper.HarmonyHelper.AddPrefix<CharacterDialogueTree>("InputDialogueOption", typeof(ConversationPatches), nameof(InputDialogueOption));
QSB.Helper.HarmonyHelper.AddPostfix<CharacterDialogueTree>("StartConversation", typeof(ConversationPatches), nameof(StartConversation));
QSB.Helper.HarmonyHelper.AddPostfix<CharacterDialogueTree>("EndConversation", typeof(ConversationPatches), nameof(EndConversation));
QSB.Helper.HarmonyHelper.AddPrefix<CharacterDialogueTree>("EndConversation", typeof(ConversationPatches), nameof(EndConversation));
QSB.Helper.HarmonyHelper.AddPrefix<CharacterAnimController>("OnAnimatorIK", typeof(ConversationPatches), nameof(OnAnimatorIK));
QSB.Helper.HarmonyHelper.AddPrefix<CharacterAnimController>("OnZoneExit", typeof(ConversationPatches), nameof(OnZoneExit));
}

View File

@ -31,6 +31,7 @@ namespace QSB.ConversationSync
{
if (message.CharacterId == -1)
{
DebugLog.ToConsole("Warning - Received conv. start/end event with char id -1.", MessageType.Warning);
return;
}
var dialogueTree = WorldRegistry.OldDialogueTrees[message.CharacterId];
@ -46,6 +47,8 @@ namespace QSB.ConversationSync
{
animController.GetValue<Animator>("_animator").SetTrigger("Talking");
}
dialogueTree.GetComponent<InteractVolume>().DisableInteraction();
}
else
{
@ -56,6 +59,7 @@ namespace QSB.ConversationSync
{
animController.GetValue<Animator>("_animator").SetTrigger("Idle");
}
dialogueTree.GetComponent<InteractVolume>().EnableInteraction();
}
}