IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Blackboard/Dictionary Specific/AddElementToDictionary.cs

33 lines
847 B
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00
using UnityEngine;
using System.Collections.Generic;
using ParadoxNotion.Design;
using NodeCanvas.Framework;
namespace NodeCanvas.Tasks.Actions
{
[Category("✫ Blackboard/Dictionaries")]
public class AddElementToDictionary<T> : ActionTask
{
[BlackboardOnly]
[RequiredField]
public BBParameter<Dictionary<string, T>> dictionary;
public BBParameter<string> key;
public BBParameter<T> value;
protected override string info {
get { return string.Format("{0}[{1}] = {2}", dictionary, key, value); }
}
protected override void OnExecute() {
if ( dictionary.value == null ) {
EndAction(false);
return;
}
dictionary.value[key.value] = value.value;
EndAction();
}
}
}