123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 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<CharacterController> character;
- [BlackboardOnly] public BBParameter<GameObject> interactionTarget;
- [BlackboardOnly] public BBParameter<bool> 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);
- }
- }
- }
|