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

39 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard/Dictionaries")]
public class TryGetValue<T> : ConditionTask
{
[RequiredField]
[BlackboardOnly]
public BBParameter<Dictionary<string, T>> targetDictionary;
[RequiredField]
public BBParameter<string> key;
[BlackboardOnly]
public BBParameter<T> saveValueAs;
protected override string info {
get { return string.Format("{0}.TryGetValue({1} as {2})", targetDictionary, key, saveValueAs); }
}
protected override bool OnCheck() {
if ( targetDictionary.value == null ) {
return false;
}
T result;
if ( targetDictionary.value.TryGetValue(key.value, out result) ) {
saveValueAs.value = result;
return true;
}
return false;
}
}
}