using System.Collections; using System.Collections.Generic; using UnityEngine; using NodeCanvas.Framework; using ParadoxNotion.Design; using KairoEngine.Core; namespace KairoEngine.CharacterSystem { [Category("KairoEngine")] public class CharacteCheckForInteractionTaskAction : ActionTask { [BlackboardOnly] public BBParameter character; [BlackboardOnly] public BBParameter interactionTarget; [BlackboardOnly] public BBParameter isInteracting; public float timer = 2f; private float counter = 0f; protected override string info { get { return "Check for interaction"; } } protected override void OnExecute() { InteractionEvents.StartListening($"{character.value.unique_name}-StartDialogue", OnInteraction); counter = 0f; } protected override void OnUpdate() { counter += Time.deltaTime; if(counter > timer) { InteractionEvents.StopListening($"{character.value.unique_name}-StartDialogue", OnInteraction); EndAction(false); } } private void OnInteraction(EventData eventData) { InteractionEvents.StopListening($"{character.value.unique_name}-StartDialogue", OnInteraction); interactionTarget.value = eventData.obj; isInteracting.value = true; EndAction(true); } } }