Example #1
0
        public static bool AnimController_OnAnimatorIK(float ___headTrackingWeight,
                                                       bool ___lookOnlyWhenTalking,
                                                       bool ____playerInHeadZone,
                                                       bool ____inConversation,
                                                       ref float ____currentLookWeight,
                                                       ref Vector3 ____currentLookTarget,
                                                       DampedSpring3D ___lookSpring,
                                                       Animator ____animator,
                                                       CharacterDialogueTree ____dialogueTree)
        {
            var     playerId = ConversationManager.Instance.GetPlayerTalkingToTree(____dialogueTree);
            Vector3 position;

            if (playerId == uint.MaxValue)
            {
                position = Locator.GetActiveCamera().transform.position;
            }
            else
            {
                var player = QSBPlayerManager.GetPlayer(playerId);
                position = player.CameraBody == null
                                        ? Locator.GetActiveCamera().transform.position
                                        : player.CameraBody.transform.position;
            }
            var localPosition = ____animator.transform.InverseTransformPoint(position);
            var targetWeight  = ___headTrackingWeight * Mathf.Min(1, !___lookOnlyWhenTalking
                                                ? !____playerInHeadZone ? 0 : 1
                                                : !____inConversation || !____playerInHeadZone ? 0 : 1);

            ____currentLookWeight = Mathf.Lerp(____currentLookWeight, targetWeight, Time.deltaTime * 2f);
            ____currentLookTarget = ___lookSpring.Update(____currentLookTarget, localPosition, Time.deltaTime);
            ____animator.SetLookAtPosition(____animator.transform.TransformPoint(____currentLookTarget));
            ____animator.SetLookAtWeight(____currentLookWeight);
            return(false);
        }
 private static void EndConversation(
     uint playerId,
     CharacterDialogueTree tree)
 {
     QSBPlayerManager.GetPlayer(playerId).CurrentCharacterDialogueTreeId = -1;
     tree.GetInteractVolume().EnableInteraction();
 }
Example #3
0
        public uint GetPlayerTalkingToTree(CharacterDialogueTree tree)
        {
            var treeIndex = QSBWorldSync.OldDialogueTrees.IndexOf(tree);

            return(QSBPlayerManager.PlayerList.All(x => x.CurrentCharacterDialogueTreeId != treeIndex)
                                ? uint.MaxValue
                                : QSBPlayerManager.PlayerList.First(x => x.CurrentCharacterDialogueTreeId == treeIndex).PlayerId);
        }
 private static void StartConversation(
     uint playerId,
     int treeId,
     CharacterDialogueTree tree)
 {
     QSBPlayerManager.GetPlayer(playerId).CurrentCharacterDialogueTreeId = treeId;
     tree.GetInteractVolume().DisableInteraction();
 }
Example #5
0
        public static void Tree_StartConversation(CharacterDialogueTree __instance)
        {
            var index = QSBWorldSync.OldDialogueTrees.FindIndex(x => x == __instance);

            if (index == -1)
            {
                DebugLog.ToConsole($"Warning - Index for tree {__instance.name} was -1.", MessageType.Warning);
            }
            QSBPlayerManager.LocalPlayer.CurrentDialogueID = index;
            ConversationManager.Instance.SendConvState(index, true);
        }
        public static bool EndConversation(CharacterDialogueTree __instance)
        {
            var allNpcAnimControllers = QSBWorldSync.GetWorldObjects <INpcAnimController>();
            var ownerOfThis           = allNpcAnimControllers.FirstOrDefault(x => x.GetDialogueTree() == __instance);

            if (ownerOfThis == default)
            {
                return(true);
            }

            ownerOfThis.SendMessage(new NpcAnimationMessage(false));
            return(true);
        }
Example #7
0
        public static bool CharacterDialogueTree_InputDialogueOption(CharacterDialogueTree __instance, int optionIndex)
        {
            if (optionIndex < 0)
            {
                // in a page where there is no selectable options
                ConversationManager.Instance.CloseBoxPlayer();
                return(true);
            }

            var selectedOption = __instance._currentDialogueBox.OptionFromUIIndex(optionIndex);

            ConversationManager.Instance.SendPlayerOption(selectedOption.Text);
            return(true);
        }
 private void EndConversation(
     uint playerId,
     CharacterAnimController controller,
     CharacterDialogueTree tree)
 {
     QSBPlayerManager.GetPlayer(playerId).CurrentDialogueID = -1;
     controller.SetValue("_inConversation", false);
     controller.SetValue("_playerInHeadZone", false);
     if (controller.GetValue <bool>("_hasTalkAnimation"))
     {
         controller.GetValue <Animator>("_animator").SetTrigger("Idle");
     }
     tree.GetInteractVolume().EnableInteraction();
 }
 private void StartConversation(
     uint playerId,
     int characterId,
     CharacterAnimController controller,
     CharacterDialogueTree tree)
 {
     QSBPlayerManager.GetPlayer(playerId).CurrentDialogueID = characterId;
     controller.SetValue("_inConversation", true);
     controller.SetValue("_playerInHeadZone", true);
     if (controller.GetValue <bool>("_hasTalkAnimation"))
     {
         controller.GetValue <Animator>("_animator").SetTrigger("Talking");
     }
     tree.GetInteractVolume().DisableInteraction();
 }
Example #10
0
 public static bool Tree_EndConversation(CharacterDialogueTree __instance)
 {
     if (!__instance.enabled)
     {
         return(false);
     }
     if (QSBPlayerManager.LocalPlayer.CurrentDialogueID == -1)
     {
         DebugLog.ToConsole($"Warning - Ending conversation with CurrentDialogueId of -1! Called from {__instance.name}", MessageType.Warning);
         return(true);
     }
     ConversationManager.Instance.SendConvState(QSBPlayerManager.LocalPlayer.CurrentDialogueID, false);
     ConversationManager.Instance.CloseBoxCharacter(QSBPlayerManager.LocalPlayer.CurrentDialogueID);
     QSBPlayerManager.LocalPlayer.CurrentDialogueID = -1;
     ConversationManager.Instance.CloseBoxPlayer();
     return(true);
 }
Example #11
0
        public static bool AnimController_OnZoneExit(CharacterDialogueTree ____dialogueTree)
        {
            var playerId = ConversationManager.Instance.GetPlayerTalkingToTree(____dialogueTree);

            return(playerId == uint.MaxValue);
        }
Example #12
0
 private static void PreStartConversation(CharacterDialogueTree __instance)
 {
     _attentionPoint = __instance.GetValue <Transform>("_attentionPoint");
 }