using System.Collections; using System.Collections.Generic; using UnityEngine; using NodeCanvas.Framework; using ParadoxNotion.Design; using KairoEngine.Core; using KairoEngine.Inventory; namespace KairoEngine.CharacterSystem { [Category("KairoEngine")] public class CharacterReloadTaskAction : ActionTask { [BlackboardOnly, RequiredField] public BBParameter character; private bool done = false; protected override string info { get { return "Reload Firearm"; } } protected override void OnExecute() { done = false; ItemFirearmRef firearmRef = (ItemFirearmRef)character.value.GetEquipedItem(); if(firearmRef == null) EndAction(false); if(character.value.HasSpareAmmo(firearmRef)) { CharacterReloadFirearmCommand reloadCommand = new CharacterReloadFirearmCommand(character.value, firearmRef); CommandInvoker.AddCommand(reloadCommand); GenericEvents.StartListening(character.value.unique_name + "-ReloadDone", End); } else EndAction(true); } protected override void OnUpdate() { if(done == true) EndAction(true); } private void End() { GenericEvents.StopListening(character.value.unique_name + "-ReloadDone", End); done = true; } } }