IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Blackboard/Dictionary Specific/GetDictionaryElement.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

35 lines
874 B
C#

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