HasInventoryItem not work!

This is my Evaluate in Inventory.cs

        public bool? Evaluate(string predicate, string[] parameters)
        {
            switch (predicate)
            {
                case "HasInventoryItem":
                    return HasItem(InventoryItem.GetFromID(parameters[0]));
            }

            return null;
        }

This is my Condition.cs

    [System.Serializable]
    public class Condition
    {
        [SerializeField] string predicate;
        [SerializeField] string[] parameters;

        public bool Check(IEnumerable<IPredicateEvaluator> evaluators)
        {
            foreach (var evaluator in evaluators)
            {
                bool? result = evaluator.Evaluate(predicate, parameters);
                if (result == null) continue;

                if (result == false) return false;
            }
            return true;
        }
    }

I don’t konw why but also if i have the item choosen in the dialog editor in my inventory it return always false…

This is the HasItem function

 public bool HasItem(InventoryItem item)
        {
            for (int i = 0; i < slots.Length; i++)
            {
                if (ReferenceEquals(slots[i], item))
                {
                    return true;
                }
            }
            return false;
        }



Are there any errors in the console when you get to this dialogue?

Is your InventoryItem in question found in a Resources folder?

Privacy & Terms