first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23a553d2db12b1a42a75b68abd94988f
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 14914
|
||||
packageName: NodeCanvas
|
||||
packageVersion: 3.3.1
|
||||
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/Blackboard/Dictionaries/TryGetValue.cs
|
||||
uploadId: 704937
|
||||
Reference in New Issue
Block a user