[Help] i need to access a list in my script, but its not showing in blackboard

Forums 💬 NodeCanvas ⚙️ Support [Help] i need to access a list in my script, but its not showing in blackboard

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15946
    viole
    Participant

      i have this script for my cooldowns. I’m trying to check if an id or item is still in this list. I usually use

      public bool Check_If_Skill_Is_OnCoolDown(int id)

      { return coolDownSystem.IsOnCoolDown(id); }

      how can I add this coolDown list to nodeCanvas???

      using System;

      using System.Collections;

      using System.Collections.Generic;

      using UnityEngine;

       

      public class CoolDownSystem : MonoBehaviour

      {

      public List<CoolDownData> coolDowns = new List<CoolDownData>();

      private void Update() => ProcessCoolDowns();

       

      public void PutOnCoolDown(IHasCoolDown coolDown)

      {

      coolDowns.Add(new CoolDownData (coolDown));

      }

      public bool IsOnCoolDown(int id)

      {

      foreach(CoolDownData coolDown in coolDowns)

      {

      if(coolDown.Id == id) { return true; }

      }

      return false;

      }

       

      public float GetRemainingDuration (int id)

      {

      foreach (CoolDownData coolDown in coolDowns)

      {

      if (coolDown.Id != id) { continue; }

      return coolDown.RemainingTime;

      }

      return 0f;

      }

       

       

      private void ProcessCoolDowns()

      {

      float deltaTime = Time.deltaTime;

      for (int i = coolDowns.Count – 1; i >= 0; i–)

      {

      if(coolDowns[i].DecrementCoolDown(deltaTime))

      {

      coolDowns.RemoveAt(i);

      }

      }

      }

      }

       

      public class CoolDownData

      {

      public CoolDownData (IHasCoolDown coolDown)

      {

      Id = coolDown.Id;

      RemainingTime = coolDown.CoolDownDuration;

      }

      public int Id { get; }

      public float RemainingTime { get; private set; }

       

      public bool DecrementCoolDown(float deltaTime)

      {

      RemainingTime = Mathf.Max(RemainingTime – deltaTime, 0f);

      return RemainingTime == 0.0f;

      }

      }

       

      #15947
      Gavalakis
      Keymaster

        Hello,

        Do you mean you want to add a Blackboard variable that is data bound to the List field?
        If so, then by selecting “Add Variable” in blackboard, it will show under “Bound(Self)/ColldownSystem/cooldowns”. Please note that CooldownSystem component should be attached on the same gameobject as the blackboard.
        If you mean something different please let me know.
        Thanks!

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.