first commit

This commit is contained in:
Chris
2025-03-12 14:22:16 -04:00
commit 0ad0c01249
1999 changed files with 189708 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 46ede71221a68114db0fa0c2d154965e
folderAsset: yes
DefaultImporter:
userData:

View File

@@ -0,0 +1,27 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Check Parameter Bool")]
[Category("Animator")]
public class MecanimCheckBool : ConditionTask<Animator>
{
[RequiredField]
public BBParameter<string> parameter;
public BBParameter<bool> value;
protected override string info {
get { return "Mec.Bool " + parameter.ToString() + " == " + value; }
}
protected override bool OnCheck() {
return agent.GetBool(parameter.value) == value.value;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: cf588be4d9b24174ba3690e0805bf1b3
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/Animator/MecanimCheckBool.cs
uploadId: 704937

View File

@@ -0,0 +1,32 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Check Parameter Float")]
[Category("Animator")]
public class MecanimCheckFloat : ConditionTask<Animator>
{
[RequiredField]
public BBParameter<string> parameter;
public CompareMethod comparison = CompareMethod.EqualTo;
public BBParameter<float> value;
protected override string info {
get
{
return "Mec.Float " + parameter.ToString() + OperationTools.GetCompareString(comparison) + value;
}
}
protected override bool OnCheck() {
return OperationTools.Compare((float)agent.GetFloat(parameter.value), (float)value.value, comparison, 0.1f);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 8b063638c9788c6429686913f6b07da6
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/Animator/MecanimCheckFloat.cs
uploadId: 704937

View File

@@ -0,0 +1,31 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Check Parameter Int")]
[Category("Animator")]
public class MecanimCheckInt : ConditionTask<Animator>
{
[RequiredField]
public BBParameter<string> parameter;
public CompareMethod comparison = CompareMethod.EqualTo;
public BBParameter<int> value;
protected override string info {
get
{
return "Mec.Int " + parameter.ToString() + OperationTools.GetCompareString(comparison) + value;
}
}
protected override bool OnCheck() {
return OperationTools.Compare((int)agent.GetInteger(parameter.value), (int)value.value, comparison);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: d28b74746be3b404fb036f7a373bc625
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/Animator/MecanimCheckInt.cs
uploadId: 704937

View File

@@ -0,0 +1,25 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Is In Transition")]
[Category("Animator")]
public class MecanimIsInTransition : ConditionTask<Animator>
{
public BBParameter<int> layerIndex;
protected override string info {
get { return "Mec.Is In Transition"; }
}
protected override bool OnCheck() {
return agent.IsInTransition(layerIndex.value);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: a4ddce33a9d165c45a2f13d9d647b36d
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/Animator/MecanimIsInTransition.cs
uploadId: 704937

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 246c7bc4ac505c34ca639e728bae1de8
folderAsset: yes
DefaultImporter:
userData:

View File

@@ -0,0 +1,25 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
public class CheckBoolean : ConditionTask
{
[BlackboardOnly]
public BBParameter<bool> valueA;
public BBParameter<bool> valueB = true;
protected override string info {
get { return valueA + " == " + valueB; }
}
protected override bool OnCheck() {
return valueA.value == valueB.value;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 30c7d93969f69c2498ca58567bebf9ba
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/CheckBoolean.cs
uploadId: 704937

View File

@@ -0,0 +1,28 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
[Description("Check if a boolean variable is true and if so, it is immediately reset to false.")]
public class CheckBooleanTrigger : ConditionTask
{
[BlackboardOnly]
public BBParameter<bool> trigger;
protected override string info {
get { return string.Format("Trigger {0}", trigger); }
}
protected override bool OnCheck() {
if ( trigger.value ) {
trigger.value = false;
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: db4e7f34bdfd6094c9f5fd9d4a0ac7b9
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/CheckBooleanTrigger.cs
uploadId: 704937

View File

@@ -0,0 +1,36 @@
using NodeCanvas.Framework;
using NodeCanvas.Framework.Internal;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
public class CheckEnum : ConditionTask
{
[BlackboardOnly]
public BBObjectParameter valueA = new BBObjectParameter(typeof(System.Enum));
public BBObjectParameter valueB = new BBObjectParameter(typeof(System.Enum));
protected override string info {
get { return valueA + " == " + valueB; }
}
protected override bool OnCheck() {
return Equals(valueA.value, valueB.value);
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
DrawDefaultInspector();
if ( valueB.varType != valueA.refType ) { valueB.SetType(valueA.refType); }
}
#endif
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: c6fad112a61560e448dc29a11d8cb549
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/CheckEnum.cs
uploadId: 704937

View File

@@ -0,0 +1,29 @@
using System;
using NodeCanvas.Framework;
using NodeCanvas.Framework.Internal;
using ParadoxNotion.Design;
[Category("✫ Blackboard")]
public class CheckEnumFlag : ConditionTask
{
[BlackboardOnly]
[RequiredField]
public readonly BBObjectParameter Variable = new BBObjectParameter(typeof(Enum));
public readonly BBObjectParameter Flag = new BBObjectParameter(typeof(Enum));
protected override string info => $"{Variable} has {Flag} flag";
protected override bool OnCheck() => ((Enum)Variable.value).HasFlag((Enum)Flag.value);
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI()
{
DrawDefaultInspector();
if (Flag.varType != Variable.refType) Flag.SetType(Variable.refType);
}
#endif
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 74d9a3ba0701dd34e856bb15db85427b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/Blackboard/CheckEnumFlag.cs
uploadId: 704937

View File

@@ -0,0 +1,29 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
public class CheckFloat : ConditionTask
{
[BlackboardOnly]
public BBParameter<float> valueA;
public CompareMethod checkType = CompareMethod.EqualTo;
public BBParameter<float> valueB;
[SliderField(0, 0.1f)]
public float differenceThreshold = 0.05f;
protected override string info {
get { return valueA + OperationTools.GetCompareString(checkType) + valueB; }
}
protected override bool OnCheck() {
return OperationTools.Compare((float)valueA.value, (float)valueB.value, checkType, differenceThreshold);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 71df5e640f84c9845837ce31e6cdebdb
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/CheckFloat.cs
uploadId: 704937

View File

@@ -0,0 +1,26 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
public class CheckInt : ConditionTask
{
[BlackboardOnly]
public BBParameter<int> valueA;
public CompareMethod checkType = CompareMethod.EqualTo;
public BBParameter<int> valueB;
protected override string info {
get { return valueA + OperationTools.GetCompareString(checkType) + valueB; }
}
protected override bool OnCheck() {
return OperationTools.Compare((int)valueA.value, (int)valueB.value, checkType);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 5eb629b285320f84c848b226e1d259ca
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/CheckInt.cs
uploadId: 704937

View File

@@ -0,0 +1,24 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
[Description("Check whether or not a variable is null")]
public class CheckNull : ConditionTask
{
[BlackboardOnly]
public BBParameter<System.Object> variable;
protected override string info {
get { return variable + " == null"; }
}
protected override bool OnCheck() {
return ParadoxNotion.ObjectUtils.AnyEquals(variable.value, null);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ce98eb096d2095c428751cef230777e2
timeCreated: 1426526308
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/Blackboard/CheckNull.cs
uploadId: 704937

View File

@@ -0,0 +1,24 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
public class CheckString : ConditionTask
{
[BlackboardOnly]
public BBParameter<string> valueA;
public BBParameter<string> valueB;
protected override string info {
get { return valueA + " == " + valueB; }
}
protected override bool OnCheck() {
return valueA.value == valueB.value;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 5b0392f1b31c6bd43b7049cdc4fa0019
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/CheckString.cs
uploadId: 704937

View File

@@ -0,0 +1,25 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
[System.Obsolete("Use CheckVariable(T)")]
public class CheckUnityObject : ConditionTask
{
[BlackboardOnly]
public BBParameter<UnityEngine.Object> valueA;
public BBParameter<UnityEngine.Object> valueB;
protected override string info {
get { return valueA + " == " + valueB; }
}
protected override bool OnCheck() {
return valueA.value == valueB.value;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: abc2c3ffc8679a346a30f6cb197e0bd9
timeCreated: 1426526308
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/Blackboard/CheckUnityObject.cs
uploadId: 704937

View File

@@ -0,0 +1,25 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
[Description("It's best to use the respective Condition for a type if existant since they support operations as well")]
public class CheckVariable<T> : ConditionTask
{
[BlackboardOnly]
public BBParameter<T> valueA;
public BBParameter<T> valueB;
protected override string info {
get { return valueA + " == " + valueB; }
}
protected override bool OnCheck() {
return ObjectUtils.AnyEquals(valueA.value, valueB.value);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 236198dd654292446b6ac9702834864d
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/CheckVariable.cs
uploadId: 704937

View File

@@ -0,0 +1,29 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
public class CheckVectorDistance : ConditionTask
{
[BlackboardOnly]
public BBParameter<Vector3> vectorA;
[BlackboardOnly]
public BBParameter<Vector3> vectorB;
public CompareMethod comparison = CompareMethod.EqualTo;
public BBParameter<float> distance;
protected override string info {
get { return string.Format("Distance ({0}, {1}) {2} {3}", vectorA, vectorB, OperationTools.GetCompareString(comparison), distance); }
}
protected override bool OnCheck() {
var d = Vector3.Distance(vectorA.value, vectorB.value);
return OperationTools.Compare((float)d, (float)distance.value, comparison, 0f);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 84a093587aae2c34baed0954a5b627f2
timeCreated: 1506035589
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/Blackboard/CheckVectorDistance.cs
uploadId: 704937

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 04209ce429981cd4a8b4b401166b30b6
folderAsset: yes
timeCreated: 1508932206
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6074a1b42a5b07142aa489e2c1dcd57c
folderAsset: yes
timeCreated: 1508932200
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System.Collections.Generic;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard/Lists")]
[Description("Check if an element is contained in the target list")]
public class ListContainsElement<T> : ConditionTask
{
[RequiredField]
[BlackboardOnly]
public BBParameter<List<T>> targetList;
public BBParameter<T> checkElement;
protected override string info {
get { return targetList + " contains " + checkElement; }
}
protected override bool OnCheck() {
return targetList.value.Contains(checkElement.value);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 8f0b93561b5e9f74283301345e027722
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/Lists/ListContainsElement.cs
uploadId: 704937

View File

@@ -0,0 +1,25 @@
using System.Collections;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard/Lists")]
public class ListIsEmpty : ConditionTask
{
[RequiredField]
[BlackboardOnly]
public BBParameter<IList> targetList;
protected override string info {
get { return string.Format("{0} Is Empty", targetList); }
}
protected override bool OnCheck() {
return targetList.value.Count == 0;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 2259ad95d8dfb954a9ed58401aa95a21
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/Lists/ListIsEmpty.cs
uploadId: 704937

View File

@@ -0,0 +1,39 @@
using NodeCanvas.Framework;
using NodeCanvas.Framework.Internal;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Name("On Variable Changed")]
[Category("✫ Blackboard")]
public class BBVariableChanged : ConditionTask
{
[BlackboardOnly] public BBObjectParameter targetVariable;
protected override string info {
get { return targetVariable + " Changed."; }
}
protected override string OnInit() {
if ( targetVariable.isNone ) {
return "Blackboard Variable not set.";
}
return null;
}
protected override void OnEnable() {
targetVariable.varRef.onValueChanged += OnValueChanged;
}
protected override void OnDisable() {
targetVariable.varRef.onValueChanged -= OnValueChanged;
}
protected override bool OnCheck() { return false; }
private void OnValueChanged(object varValue) {
YieldReturn(true);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 1ff196daaad5993488b31a0ebb9207d7
timeCreated: 1517683305
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/Blackboard/OnVariableChange.cs
uploadId: 704937

View File

@@ -0,0 +1,25 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Conditions
{
[Category("✫ Blackboard")]
public class StringContains : ConditionTask
{
[RequiredField]
[BlackboardOnly]
public BBParameter<string> targetString;
public BBParameter<string> checkString;
protected override string info {
get { return string.Format("{0} Contains {1}", targetString, checkString); }
}
protected override bool OnCheck() {
return targetString.value.Contains(checkString.value);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: b47ef073f9055bb45998448f1854c372
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/StringContains.cs
uploadId: 704937

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 98269855e14713f49ba12c113fb4e513
folderAsset: yes
DefaultImporter:
userData:

View File

@@ -0,0 +1,77 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("GameObject")]
[Description("A combination of line of sight and view angle check")]
public class CanSeeTarget : ConditionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> target;
[Tooltip("Distance within which to look out for.")]
public BBParameter<float> maxDistance = 50;
[Tooltip("A layer mask to use for line of sight check.")]
public BBParameter<LayerMask> layerMask = (LayerMask)( -1 );
[Tooltip("Distance within which the target can be seen (or rather sensed) regardless of view angle.")]
public BBParameter<float> awarnessDistance = 0f;
[SliderField(1, 180)]
public BBParameter<float> viewAngle = 70f;
public Vector3 offset;
private RaycastHit hit;
protected override string info {
get { return "Can See " + target; }
}
protected override bool OnCheck() {
var t = target.value.transform;
if ( !t.gameObject.activeInHierarchy ) {
return false;
}
if ( Vector3.Distance(agent.position, t.position) <= awarnessDistance.value ) {
if ( Physics.Linecast(agent.position + offset, t.position + offset, out hit, layerMask.value) ) {
if ( hit.collider != t.GetComponent<Collider>() ) {
return false;
}
}
return true;
}
if ( Vector3.Distance(agent.position, t.position) > maxDistance.value ) {
return false;
}
if ( Vector3.Angle(t.position - agent.position, agent.forward) > viewAngle.value ) {
return false;
}
if ( Physics.Linecast(agent.position + offset, t.position + offset, out hit, layerMask.value) ) {
if ( hit.collider != t.GetComponent<Collider>() ) {
return false;
}
}
return true;
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) {
Gizmos.DrawLine(agent.position, agent.position + offset);
Gizmos.DrawLine(agent.position + offset, agent.position + offset + ( agent.forward * maxDistance.value ));
Gizmos.DrawWireSphere(agent.position + offset + ( agent.forward * maxDistance.value ), 0.1f);
Gizmos.DrawWireSphere(agent.position, awarnessDistance.value);
Gizmos.matrix = Matrix4x4.TRS(agent.position + offset, agent.rotation, Vector3.one);
Gizmos.DrawFrustum(Vector3.zero, viewAngle.value, 5, 0, 1f);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 24defae9036e18b49a10c8d0f1bc7b7e
timeCreated: 1428001303
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/GameObject/CanSeeTarget.cs
uploadId: 704937

View File

@@ -0,0 +1,75 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("GameObject")]
[Description("A combination of line of sight and view angle check")]
public class CanSeeTarget2D : ConditionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> target;
[Tooltip("Distance within which to look out for.")]
public BBParameter<float> maxDistance = 50;
[Tooltip("A layer mask to use for the line of sight check.")]
public BBParameter<LayerMask> layerMask = (LayerMask)( -1 );
[Tooltip("Distance within which the target can be seen (or rather sensed) regardless of view angle.")]
public BBParameter<float> awarnessDistance = 0f;
[SliderField(1, 180)]
public BBParameter<float> viewAngle = 70f;
public Vector2 offset;
private RaycastHit2D hit;
protected override string info {
get { return "Can See " + target; }
}
protected override bool OnCheck() {
var t = target.value.transform;
if ( !t.gameObject.activeInHierarchy ) {
return false;
}
if ( Vector2.Distance(agent.position, t.position) <= awarnessDistance.value ) {
var hit = Physics2D.Linecast((Vector2)agent.position + offset, (Vector2)t.position + offset, layerMask.value);
if ( hit.collider != t.GetComponent<Collider2D>() ) {
return false;
}
return true;
}
if ( Vector2.Distance(agent.position, t.position) > maxDistance.value ) {
return false;
}
if ( Vector2.Angle((Vector2)t.position - (Vector2)agent.position, agent.right) > viewAngle.value ) {
return false;
}
var hit2 = Physics2D.Linecast((Vector2)agent.position + offset, (Vector2)t.position + offset, layerMask.value);
if ( hit2.collider != t.GetComponent<Collider2D>() ) {
return false;
}
return true;
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) {
Gizmos.DrawLine((Vector2)agent.position, (Vector2)agent.position + offset);
Gizmos.DrawLine((Vector2)agent.position + offset, (Vector2)agent.position + offset + ( (Vector2)agent.right * maxDistance.value ));
Gizmos.DrawWireSphere((Vector2)agent.position + offset + ( (Vector2)agent.right * maxDistance.value ), 0.1f);
Gizmos.DrawWireSphere((Vector2)agent.position, awarnessDistance.value);
Gizmos.matrix = Matrix4x4.TRS((Vector2)agent.position + offset, Quaternion.LookRotation(agent.right), Vector3.one);
Gizmos.DrawFrustum(Vector3.zero, viewAngle.value, 5, 0, 1f);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 585731d3c9972a74084a0d4faed3a76e
timeCreated: 1428001303
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/GameObject/CanSeeTarget2D.cs
uploadId: 704937

View File

@@ -0,0 +1,92 @@
using System.Collections.Generic;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("GameObject")]
[Description("A combination of line of sight and view angle check")]
public class CanSeeTargetAny : ConditionTask<Transform>
{
public BBParameter<List<GameObject>> targetObjects;
public BBParameter<float> maxDistance = 50;
public BBParameter<LayerMask> layerMask = (LayerMask)( -1 );
public BBParameter<float> awarnessDistance = 0f;
[SliderField(1, 180)]
public BBParameter<float> viewAngle = 70f;
public Vector3 offset;
[BlackboardOnly]
public BBParameter<List<GameObject>> allResults;
[BlackboardOnly]
public BBParameter<GameObject> closerResult;
private RaycastHit hit;
protected override string info { get { return "Can See Any " + targetObjects; } }
protected override bool OnCheck() {
var r = false;
var store = !allResults.isNone || !closerResult.isNone;
var temp = store ? new List<GameObject>() : null;
foreach ( var o in targetObjects.value ) {
if ( o == agent.gameObject ) { continue; }
var t = o.transform;
if ( !t.gameObject.activeInHierarchy ) { continue; }
if ( Vector3.Distance(agent.position, t.position) < awarnessDistance.value ) {
if ( Physics.Linecast(agent.position + offset, t.position + offset, out hit, layerMask.value) ) {
if ( hit.collider != t.GetComponent<Collider>() ) { continue; }
}
if ( store ) { temp.Add(o); }
r = true;
continue;
}
if ( Vector3.Distance(agent.position, t.position) > maxDistance.value ) {
continue;
}
if ( Vector3.Angle(t.position - agent.position, agent.forward) > viewAngle.value ) {
continue;
}
if ( Physics.Linecast(agent.position + offset, t.position + offset, out hit, layerMask.value) ) {
if ( hit.collider != t.GetComponent<Collider>() ) { continue; }
}
if ( store ) { temp.Add(o); }
r = true;
}
if ( store ) {
var ordered = temp.OrderBy(x => Vector3.Distance(agent.position, x.transform.position));
if ( !allResults.isNone ) { allResults.value = ordered.ToList(); }
if ( !closerResult.isNone ) { closerResult.value = ordered.FirstOrDefault(); }
}
return r;
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) {
Gizmos.DrawLine(agent.position, agent.position + offset);
Gizmos.DrawLine(agent.position + offset, agent.position + offset + ( agent.forward * maxDistance.value ));
Gizmos.DrawWireSphere(agent.position + offset + ( agent.forward * maxDistance.value ), 0.1f);
Gizmos.DrawWireSphere(agent.position, awarnessDistance.value);
Gizmos.matrix = Matrix4x4.TRS(agent.position + offset, agent.rotation, Vector3.one);
Gizmos.DrawFrustum(Vector3.zero, viewAngle.value, 5, 0, 1f);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ec5a1168d1d24034b82ad5ef3a95d75c
timeCreated: 1428001303
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/GameObject/CanSeeTargetAny.cs
uploadId: 704937

View File

@@ -0,0 +1,88 @@
using System.Collections.Generic;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("GameObject")]
[Description("A combination of line of sight and view angle check")]
public class CanSeeTargetAny2D : ConditionTask<Transform>
{
public BBParameter<List<GameObject>> targetObjects;
public BBParameter<float> maxDistance = 50;
public BBParameter<LayerMask> layerMask = (LayerMask)( -1 );
public BBParameter<float> awarnessDistance = 0f;
[SliderField(1, 180)]
public BBParameter<float> viewAngle = 70f;
public Vector2 offset;
[BlackboardOnly]
public BBParameter<List<GameObject>> allResults;
[BlackboardOnly]
public BBParameter<GameObject> closerResult;
protected override string info { get { return "Can See Any " + targetObjects; } }
protected override bool OnCheck() {
var r = false;
var store = !allResults.isNone || !closerResult.isNone;
var temp = store ? new List<GameObject>() : null;
foreach ( var o in targetObjects.value ) {
if ( o == agent.gameObject ) { continue; }
var t = o.transform;
if ( !t.gameObject.activeInHierarchy ) { continue; }
if ( Vector2.Distance(agent.position, t.position) < awarnessDistance.value ) {
var hit = Physics2D.Linecast((Vector2)agent.position + offset, (Vector2)t.position + offset, layerMask.value);
if ( hit.collider != t.GetComponent<Collider2D>() ) { continue; }
if ( store ) { temp.Add(o); }
r = true;
continue;
}
if ( Vector2.Distance(agent.position, t.position) > maxDistance.value ) {
continue;
}
if ( Vector2.Angle((Vector2)t.position - (Vector2)agent.position, agent.right) > viewAngle.value ) {
continue;
}
var hit2 = Physics2D.Linecast((Vector2)agent.position + offset, (Vector2)t.position + offset, layerMask.value);
if ( hit2.collider != t.GetComponent<Collider2D>() ) { continue; }
if ( store ) { temp.Add(o); }
r = true;
}
if ( store ) {
var ordered = temp.OrderBy(x => Vector3.Distance(agent.position, x.transform.position));
if ( !allResults.isNone ) { allResults.value = ordered.ToList(); }
if ( !closerResult.isNone ) { closerResult.value = ordered.FirstOrDefault(); }
}
return r;
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) {
Gizmos.DrawLine((Vector2)agent.position, (Vector2)agent.position + offset);
Gizmos.DrawLine((Vector2)agent.position + offset, (Vector2)agent.position + offset + ( (Vector2)agent.right * maxDistance.value ));
Gizmos.DrawWireSphere((Vector2)agent.position + offset + ( (Vector2)agent.right * maxDistance.value ), 0.1f);
Gizmos.DrawWireSphere((Vector2)agent.position, awarnessDistance.value);
Gizmos.matrix = Matrix4x4.TRS((Vector2)agent.position + offset, agent.rotation, Vector3.one);
Gizmos.DrawFrustum(Vector3.zero, viewAngle.value, 5, 0, 1f);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: caff353d1a7b8614d9718d32ba1a56ef
timeCreated: 1428001303
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/GameObject/CanSeeTargetAny2D.cs
uploadId: 704937

View File

@@ -0,0 +1,37 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Target Within Distance")]
[Category("GameObject")]
public class CheckDistanceToGameObject : ConditionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> checkTarget;
public CompareMethod checkType = CompareMethod.LessThan;
public BBParameter<float> distance = 10;
[SliderField(0, 0.1f)]
public float floatingPoint = 0.05f;
protected override string info {
get { return "Distance" + OperationTools.GetCompareString(checkType) + distance + " to " + checkTarget; }
}
protected override bool OnCheck() {
return OperationTools.Compare(Vector3.Distance(agent.position, checkTarget.value.transform.position), distance.value, checkType, floatingPoint);
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) {
Gizmos.DrawWireSphere(agent.position, distance.value);
}
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: ee036437d1baa47408c144d0ff96e603
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/GameObject/CheckDistanceToGameObject.cs
uploadId: 704937

View File

@@ -0,0 +1,37 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Target Within Distance 2D")]
[Category("GameObject")]
public class CheckDistanceToGameObject2D : ConditionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> checkTarget;
public CompareMethod checkType = CompareMethod.LessThan;
public BBParameter<float> distance = 10;
[SliderField(0, 0.1f)]
public float floatingPoint = 0.05f;
protected override string info {
get { return "Distance" + OperationTools.GetCompareString(checkType) + distance + " to " + checkTarget; }
}
protected override bool OnCheck() {
return OperationTools.Compare(Vector2.Distance(agent.position, checkTarget.value.transform.position), distance.value, checkType, floatingPoint);
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) {
Gizmos.DrawWireSphere((Vector2)agent.position, distance.value);
}
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 040adba212104994f8e1d54ad0a79cd6
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/GameObject/CheckDistanceToGameObject2D.cs
uploadId: 704937

View File

@@ -0,0 +1,58 @@
using System.Collections.Generic;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Any Target Within Distance")]
[Category("GameObject")]
public class CheckDistanceToGameObjectAny : ConditionTask<Transform>
{
public BBParameter<List<GameObject>> targetObjects;
public CompareMethod checkType = CompareMethod.LessThan;
public BBParameter<float> distance = 10;
[SliderField(0, 0.1f)]
public float floatingPoint = 0.05f;
[BlackboardOnly]
public BBParameter<List<GameObject>> allResults;
[BlackboardOnly]
public BBParameter<GameObject> closerResult;
protected override string info {
get { return "Distance Any" + OperationTools.GetCompareString(checkType) + distance + " in " + targetObjects; }
}
protected override bool OnCheck() {
var r = false;
var temp = new List<GameObject>();
foreach ( var o in targetObjects.value ) {
if ( o == agent.gameObject ) { continue; }
if ( OperationTools.Compare(Vector3.Distance(agent.position, o.transform.position), distance.value, checkType, floatingPoint) ) {
temp.Add(o);
r = true;
}
}
if ( !allResults.isNone || !closerResult.isNone ) {
var ordered = temp.OrderBy(x => Vector3.Distance(agent.position, x.transform.position));
if ( !allResults.isNone ) { allResults.value = ordered.ToList(); }
if ( !closerResult.isNone ) { closerResult.value = ordered.FirstOrDefault(); }
}
return r;
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) { Gizmos.DrawWireSphere(agent.position, distance.value); }
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 2081a0ddb30934a4380c1c61b6e587a9
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/GameObject/CheckDistanceToGameObjectAny.cs
uploadId: 704937

View File

@@ -0,0 +1,58 @@
using System.Collections.Generic;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Any Target Within Distance 2D")]
[Category("GameObject")]
public class CheckDistanceToGameObjectAny2D : ConditionTask<Transform>
{
public BBParameter<List<GameObject>> targetObjects;
public CompareMethod checkType = CompareMethod.LessThan;
public BBParameter<float> distance = 10;
[SliderField(0, 0.1f)]
public float floatingPoint = 0.05f;
[BlackboardOnly]
public BBParameter<List<GameObject>> allResults;
[BlackboardOnly]
public BBParameter<GameObject> closerResult;
protected override string info {
get { return "Distance Any" + OperationTools.GetCompareString(checkType) + distance + " in " + targetObjects; }
}
protected override bool OnCheck() {
var r = false;
var temp = new List<GameObject>();
foreach ( var o in targetObjects.value ) {
if ( o == agent.gameObject ) { continue; }
if ( OperationTools.Compare(Vector2.Distance(agent.position, o.transform.position), distance.value, checkType, floatingPoint) ) {
temp.Add(o);
r = true;
}
}
if ( !allResults.isNone || !closerResult.isNone ) {
var ordered = temp.OrderBy(x => Vector2.Distance(agent.position, x.transform.position));
if ( !allResults.isNone ) { allResults.value = ordered.ToList(); }
if ( !closerResult.isNone ) { closerResult.value = ordered.FirstOrDefault(); }
}
return r;
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) { Gizmos.DrawWireSphere((Vector2)agent.position, distance.value); }
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: fbfc071aab573584c8f51844d1231734
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/GameObject/CheckDistanceToGameObjectAny2D.cs
uploadId: 704937

View File

@@ -0,0 +1,49 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Target In Line Of Sight")]
[Category("GameObject")]
[Description("Check of agent is in line of sight with target by doing a linecast and optionaly save the distance")]
public class CheckLOS : ConditionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> LOSTarget;
public BBParameter<LayerMask> layerMask = (LayerMask)( -1 );
public Vector3 offset;
[BlackboardOnly]
public BBParameter<float> saveDistanceAs;
private RaycastHit hit = new RaycastHit();
protected override string info {
get { return "LOS with " + LOSTarget.ToString(); }
}
protected override bool OnCheck() {
var t = LOSTarget.value.transform;
if ( Physics.Linecast(agent.position + offset, t.position + offset, out hit, layerMask.value) ) {
var targetCollider = t.GetComponent<Collider>();
if ( targetCollider == null || hit.collider != targetCollider ) {
saveDistanceAs.value = hit.distance;
return false;
}
}
return true;
}
public override void OnDrawGizmosSelected() {
if ( agent && LOSTarget.value ) {
Gizmos.DrawLine(agent.position + offset, LOSTarget.value.transform.position + offset);
}
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 3d43904d3fbdf06438821b8d1027fedb
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/GameObject/CheckLOS.cs
uploadId: 704937

View File

@@ -0,0 +1,43 @@
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Target In Line Of Sight 2D")]
[Category("GameObject")]
[Description("Check of agent is in line of sight with target by doing a linecast and optionaly save the distance")]
public class CheckLOS2D : ConditionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> LOSTarget;
public BBParameter<LayerMask> layerMask = (LayerMask)( -1 );
[BlackboardOnly]
public BBParameter<float> saveDistanceAs;
[GetFromAgent]
protected Collider2D agentCollider;
protected override string info => "LOS with " + LOSTarget.ToString();
protected override bool OnCheck() {
var hits = Physics2D.LinecastAll(agent.position, LOSTarget.value.transform.position, layerMask.value);
foreach ( var collider in hits.Select(h => h.collider) ) {
if ( collider != agentCollider && collider != LOSTarget.value.GetComponent<Collider2D>() ) {
return false;
}
}
saveDistanceAs.value = Vector2.Distance(LOSTarget.value.transform.position, agent.position);
return true;
}
public override void OnDrawGizmosSelected() {
if ( agent && LOSTarget.value ) {
Gizmos.DrawLine((Vector2)agent.position, (Vector2)LOSTarget.value.transform.position);
}
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: a094ea2888e4de84485d19ef28255a25
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/GameObject/CheckLOS2D.cs
uploadId: 704937

View File

@@ -0,0 +1,29 @@
using UnityEngine;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
namespace NodeCanvas.Tasks.Actions
{
[Category("GameObject")]
[Description("Checks the current speed of the agent against a value based on it's Rigidbody velocity")]
public class CheckSpeed : ConditionTask<Rigidbody>
{
public CompareMethod checkType = CompareMethod.EqualTo;
public BBParameter<float> value;
[SliderField(0, 0.1f)]
public float differenceThreshold = 0.05f;
protected override string info {
get { return "Speed" + OperationTools.GetCompareString(checkType) + value; }
}
protected override bool OnCheck() {
var speed = agent.linearVelocity.magnitude;
return OperationTools.Compare((float)speed, (float)value.value, checkType, differenceThreshold);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9f9579cb895fe914f91b86e4d967dc8e
timeCreated: 1441577646
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/GameObject/CheckSpeed.cs
uploadId: 704937

View File

@@ -0,0 +1,17 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("GameObject")]
public class HasComponent<T> : ConditionTask<Transform> where T : Component
{
protected override bool OnCheck() {
return agent.GetComponent<T>() != null;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 54d501a28e4c61641bbdabcd32831cee
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/GameObject/HasComponent.cs
uploadId: 704937

View File

@@ -0,0 +1,17 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("GameObject")]
public class IsActive : ConditionTask<Transform>
{
protected override string info => agentInfo + " is Active";
protected override bool OnCheck() {
return agent.gameObject.activeInHierarchy;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 9c9c80ad76ba5b4479f11d98fc4b3d7c
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/GameObject/IsActive.cs
uploadId: 704937

View File

@@ -0,0 +1,35 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Target In View Angle")]
[Category("GameObject")]
[Description("Checks whether the target is in the view angle of the agent")]
public class IsInFront : ConditionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> checkTarget;
[SliderField(1, 180)]
public BBParameter<float> viewAngle = 70f;
protected override string info {
get { return checkTarget + " in view angle"; }
}
protected override bool OnCheck() {
return Vector3.Angle(checkTarget.value.transform.position - agent.position, agent.forward) < viewAngle.value;
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) {
Gizmos.matrix = Matrix4x4.TRS(agent.position, agent.rotation, Vector3.one);
Gizmos.DrawFrustum(Vector3.zero, viewAngle.value, 5, 0, 1f);
}
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: e1a0f56b2c92a024b906e2a67a8d5aff
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/GameObject/IsInFront.cs
uploadId: 704937

View File

@@ -0,0 +1,36 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Target In View Angle 2D")]
[Category("GameObject")]
[Description("Checks whether the target is in the view angle of the agent")]
public class IsInFront2D : ConditionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> checkTarget;
[SliderField(1, 180)]
public BBParameter<float> viewAngle = 70f;
protected override string info {
get { return checkTarget + " in view angle"; }
}
protected override bool OnCheck() {
return Vector2.Angle((Vector2)checkTarget.value.transform.position - (Vector2)agent.position, agent.right) < viewAngle.value;
}
public override void OnDrawGizmosSelected() {
if ( agent != null ) {
Gizmos.matrix = Matrix4x4.TRS((Vector2)agent.position, agent.rotation, Vector3.one);
Gizmos.DrawFrustum(Vector3.zero, viewAngle.value, 5, 0, 0f);
}
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 69e73532523d4a042aa4faa4f01fecde
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/GameObject/IsInFront2D.cs
uploadId: 704937

View File

@@ -0,0 +1,19 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("GameObject")]
public class IsWithinLayerMask : ConditionTask<Transform>
{
public BBParameter<LayerMask> targetLayers;
protected override bool OnCheck() {
return ParadoxNotion.ObjectUtils.IsInLayerMask(agent.gameObject, targetLayers.value);
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 8421a25f60933284e97c3b05827cc14f
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/GameObject/IsWithinLayerMask.cs
uploadId: 704937

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 4e635e5017f6f0140afc621794f5a1b9
folderAsset: yes
DefaultImporter:
userData:

View File

@@ -0,0 +1,35 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("Input (Legacy System)")]
public class CheckButtonInput : ConditionTask
{
public PressTypes pressType = PressTypes.Down;
[RequiredField] public BBParameter<string> buttonName = "Fire1";
protected override string info {
get { return pressType.ToString() + " " + buttonName.ToString(); }
}
protected override bool OnCheck() {
if ( pressType == PressTypes.Down )
return Input.GetButtonDown(buttonName.value);
if ( pressType == PressTypes.Up )
return Input.GetButtonUp(buttonName.value);
if ( pressType == PressTypes.Pressed )
return Input.GetButton(buttonName.value);
return false;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 53529c5c403f06249ba9be1abcd1241b
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/Input/CheckButtonInput.cs
uploadId: 704937

View File

@@ -0,0 +1,50 @@
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("Input (Legacy System)")]
public class CheckKeyboardInput : ConditionTask
{
public PressTypes pressType = PressTypes.Down;
public KeyCode key = KeyCode.Space;
protected override string info {
get { return pressType.ToString() + " " + key.ToString(); }
}
protected override bool OnCheck() {
if ( pressType == PressTypes.Down )
return Input.GetKeyDown(key);
if ( pressType == PressTypes.Up )
return Input.GetKeyUp(key);
if ( pressType == PressTypes.Pressed )
return Input.GetKey(key);
return false;
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
UnityEditor.EditorGUILayout.BeginHorizontal();
pressType = (PressTypes)UnityEditor.EditorGUILayout.EnumPopup(pressType);
key = (KeyCode)UnityEditor.EditorGUILayout.EnumPopup(key);
UnityEditor.EditorGUILayout.EndHorizontal();
}
#endif
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: e79b7a152baaffc48842942208d33a61
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/Input/CheckKeyboardInput.cs
uploadId: 704937

View File

@@ -0,0 +1,47 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("Input (Legacy System)")]
public class CheckMousePick : ConditionTask
{
public ParadoxNotion.ButtonKeys buttonKey;
[LayerField] public int layer;
[BlackboardOnly] public BBParameter<GameObject> saveGoAs;
[BlackboardOnly] public BBParameter<float> saveDistanceAs;
[BlackboardOnly] public BBParameter<Vector3> savePosAs;
private RaycastHit hit;
protected override string info {
get
{
var finalString = buttonKey.ToString() + " Click";
if ( !string.IsNullOrEmpty(savePosAs.name) )
finalString += string.Format("\n<i>(SavePos As {0})</i>", savePosAs);
if ( !string.IsNullOrEmpty(saveGoAs.name) )
finalString += string.Format("\n<i>(SaveGo As {0})</i>", saveGoAs);
return finalString;
}
}
protected override bool OnCheck() {
if ( Input.GetMouseButtonDown((int)buttonKey) ) {
if ( Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, 1 << layer) ) {
saveGoAs.value = hit.collider.gameObject;
saveDistanceAs.value = hit.distance;
savePosAs.value = hit.point;
return true;
}
}
return false;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 6e9a62bf60417864c88657b1f39943d6
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/Input/CheckMousePick.cs
uploadId: 704937

View File

@@ -0,0 +1,51 @@
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Category("Input (Legacy System)")]
public class CheckMousePick2D : ConditionTask
{
public ParadoxNotion.ButtonKeys buttonKey;
public LayerMask mask = -1;
[BlackboardOnly] public BBParameter<GameObject> saveGoAs;
[BlackboardOnly] public BBParameter<float> saveDistanceAs;
[BlackboardOnly] public BBParameter<Vector3> savePosAs;
private int buttonID;
private RaycastHit2D hit;
protected override string info {
get
{
var finalString = buttonKey.ToString() + " Click";
if ( !savePosAs.isNone )
finalString += "\nSavePos As " + savePosAs;
if ( !saveGoAs.isNone )
finalString += "\nSaveGo As " + saveGoAs;
return finalString;
}
}
protected override bool OnCheck() {
buttonID = (int)buttonKey;
if ( Input.GetMouseButtonDown(buttonID) ) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity, mask);
if ( hit.collider != null ) {
savePosAs.value = hit.point;
saveGoAs.value = hit.collider.gameObject;
saveDistanceAs.value = hit.distance;
return true;
}
}
return false;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: f04e747aff6b43548b88a0733c254fff
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/Input/CheckMousePick2D.cs
uploadId: 704937

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 9eff70c4889871d41897627d1d595aa1
folderAsset: yes
DefaultImporter:
userData:

View File

@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
#if UNITY_5_5_OR_NEWER
using NavMeshAgent = UnityEngine.AI.NavMeshAgent;
using NavMeshPath = UnityEngine.AI.NavMeshPath;
using NavMeshPathStatus = UnityEngine.AI.NavMeshPathStatus;
#endif
namespace NodeCanvas.Tasks.Conditions
{
[Category("Movement")]
[Description("Check if a path exists for the agent and optionaly save the resulting path positions")]
public class PathExists : ConditionTask<NavMeshAgent>
{
public BBParameter<Vector3> targetPosition;
[BlackboardOnly]
public BBParameter<List<Vector3>> savePathAs;
protected override bool OnCheck() {
var path = new NavMeshPath();
agent.CalculatePath(targetPosition.value, path);
savePathAs.value = path.corners.ToList();
return path.status == NavMeshPathStatus.PathComplete;
}
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: e2b650f883066f648b6b9bc94fb30d25
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/Movement/PathExists.cs
uploadId: 704937

View File

@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 0e985891466328d4bbbb3d1b6980dc5d
folderAsset: yes
DefaultImporter:
userData:

View File

@@ -0,0 +1,377 @@
using System.Reflection;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using ParadoxNotion.Serialization;
using ParadoxNotion.Serialization.FullSerializer;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
///----------------------------------------------------------------------------------------------
//previous versions
class CheckCSharpEvent_0
{
[SerializeField] public System.Type targetType = null;
[SerializeField] public string eventName = null;
}
class CheckCSharpEvent_0<T>
{
[SerializeField] public System.Type targetType = null;
[SerializeField] public string eventName = null;
}
class CheckCSharpEventValue_0<T>
{
[SerializeField] public System.Type targetType = null;
[SerializeField] public string eventName = null;
}
[fsMigrateTo(typeof(CheckCSharpEvent))]
class CheckStaticCSharpEvent
{
[SerializeField] public System.Type targetType = null;
[SerializeField] public string eventName = null;
}
[fsMigrateTo(typeof(CheckCSharpEvent<>))]
class CheckStaticCSharpEvent<T>
{
[SerializeField] public System.Type targetType = null;
[SerializeField] public string eventName = null;
}
//previous versions
///----------------------------------------------------------------------------------------------
[Category("✫ Reflected/Events")]
[Description("Will subscribe to a public event of Action type and return true when the event is raised.\n(eg public event System.Action [name])")]
[fsMigrateVersions(typeof(CheckCSharpEvent_0))]
public class CheckCSharpEvent : ConditionTask, IReflectedWrapper, IMigratable<CheckCSharpEvent_0>, IMigratable<CheckStaticCSharpEvent>
{
///----------------------------------------------------------------------------------------------
void IMigratable<CheckCSharpEvent_0>.Migrate(CheckCSharpEvent_0 model) {
var info = model.targetType?.RTGetEvent(model.eventName);
if ( info != null ) { this.eventInfo = new SerializedEventInfo(info); }
}
void IMigratable<CheckStaticCSharpEvent>.Migrate(CheckStaticCSharpEvent model) {
var info = model.targetType?.RTGetEvent(model.eventName);
if ( info != null ) { this.eventInfo = new SerializedEventInfo(info); }
}
///----------------------------------------------------------------------------------------------
[SerializeField]
private SerializedEventInfo eventInfo = null;
private System.Delegate handler;
private EventInfo targetEvent => eventInfo;
public override System.Type agentType {
get
{
if ( targetEvent == null ) { return typeof(Transform); }
return targetEvent.IsStatic() ? null : targetEvent.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( eventInfo == null ) { return "No Event Selected"; }
if ( targetEvent == null ) { return eventInfo.AsString().FormatError(); }
return string.Format("'{0}' Raised", targetEvent.Name);
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return eventInfo; }
protected override string OnInit() {
if ( eventInfo == null ) { return "No Event Selected"; }
if ( targetEvent == null ) { return eventInfo.AsString().FormatError(); }
var methodInfo = this.GetType().RTGetMethod("Raised");
this.handler = methodInfo.RTCreateDelegate(targetEvent.EventHandlerType, this);
return null;
}
protected override void OnEnable() {
if ( handler != null ) targetEvent.AddEventHandler(targetEvent.IsStatic() ? null : agent, handler);
}
protected override void OnDisable() {
if ( handler != null ) targetEvent.RemoveEventHandler(targetEvent.IsStatic() ? null : agent, handler);
}
public void Raised() { YieldReturn(true); }
protected override bool OnCheck() { return false; }
void SetTargetEvent(EventInfo info) {
if ( info != null ) {
UndoUtility.RecordObject(ownerSystem.contextObject, "Set Reflection Member");
eventInfo = new SerializedEventInfo(info);
}
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Event") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => !c.hideFlags.HasFlag(HideFlags.HideInInspector)) ) {
menu = EditorUtils.GetInstanceEventSelectionMenu(comp.GetType(), null, SetTargetEvent, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticEventSelectionMenu(t, null, SetTargetEvent, menu);
if ( typeof(Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceEventSelectionMenu(t, null, SetTargetEvent, menu);
}
}
menu.ShowAsBrowser("Select Event", this.GetType());
Event.current.Use();
}
if ( targetEvent != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Selected Type", targetEvent.DeclaringType.FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Selected Event", targetEvent.Name);
GUILayout.EndVertical();
}
}
#endif
}
///----------------------------------------------------------------------------------------------
[Category("✫ Reflected/Events")]
[Description("Will subscribe to a public event of Action<T> type and return true when the event is raised.\n(eg public event System.Action<T> [name])")]
[fsMigrateVersions(typeof(CheckCSharpEvent_0<>))]
public class CheckCSharpEvent<T> : ConditionTask, IReflectedWrapper, IMigratable<CheckCSharpEvent_0<T>>, IMigratable<CheckStaticCSharpEvent<T>>
{
///----------------------------------------------------------------------------------------------
void IMigratable<CheckCSharpEvent_0<T>>.Migrate(CheckCSharpEvent_0<T> model) {
this.SetTargetEvent(model.targetType?.RTGetEvent(model.eventName));
}
void IMigratable<CheckStaticCSharpEvent<T>>.Migrate(CheckStaticCSharpEvent<T> model) {
this.SetTargetEvent(model.targetType?.RTGetEvent(model.eventName));
}
///----------------------------------------------------------------------------------------------
[SerializeField]
private SerializedEventInfo eventInfo = null;
[SerializeField, BlackboardOnly]
private BBParameter<T> saveAs = null;
private System.Delegate handler;
private EventInfo targetEvent => eventInfo;
public override System.Type agentType {
get
{
if ( targetEvent == null ) { return typeof(Transform); }
return targetEvent.IsStatic() ? null : targetEvent.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( eventInfo == null ) { return "No Event Selected"; }
if ( targetEvent == null ) { return eventInfo.AsString().FormatError(); }
return string.Format("'{0}' Raised", targetEvent.Name);
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return eventInfo; }
protected override string OnInit() {
if ( eventInfo == null ) { return "No Event Selected"; }
if ( targetEvent == null ) { return eventInfo.AsString().FormatError(); }
var methodInfo = this.GetType().RTGetMethod("Raised");
handler = methodInfo.RTCreateDelegate(targetEvent.EventHandlerType, this);
return null;
}
protected override void OnEnable() {
if ( handler != null ) targetEvent.AddEventHandler(targetEvent.IsStatic() ? null : agent, handler);
}
protected override void OnDisable() {
if ( handler != null ) targetEvent.RemoveEventHandler(targetEvent.IsStatic() ? null : agent, handler);
}
public void Raised(T eventValue) {
saveAs.value = eventValue;
YieldReturn(true);
}
protected override bool OnCheck() { return false; }
void SetTargetEvent(EventInfo info) {
if ( info != null ) {
eventInfo = new SerializedEventInfo(info);
}
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Event") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0) ) {
menu = EditorUtils.GetInstanceEventSelectionMenu(comp.GetType(), typeof(T), SetTargetEvent, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticEventSelectionMenu(t, typeof(T), SetTargetEvent, menu);
if ( typeof(Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceEventSelectionMenu(t, typeof(T), SetTargetEvent, menu);
}
}
menu.ShowAsBrowser("Select Event", this.GetType());
Event.current.Use();
}
if ( targetEvent != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Selected Type", targetEvent.DeclaringType.FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Selected Event", targetEvent.Name);
GUILayout.EndVertical();
NodeCanvas.Editor.BBParameterEditor.ParameterField("Save Value As", saveAs, true);
}
}
#endif
}
///----------------------------------------------------------------------------------------------
[Category("✫ Reflected/Events")]
[Description("Will subscribe to a public event of Action<T> type and return true when the event is raised and it's value is equal to provided value as well.\n(eg public event System.Action<T> [name])")]
[fsMigrateVersions(typeof(CheckCSharpEventValue_0<>))]
public class CheckCSharpEventValue<T> : ConditionTask, IReflectedWrapper, IMigratable<CheckCSharpEventValue_0<T>>
{
///----------------------------------------------------------------------------------------------
void IMigratable<CheckCSharpEventValue_0<T>>.Migrate(CheckCSharpEventValue_0<T> model) {
this.SetTargetEvent(model.targetType?.RTGetEvent(model.eventName));
}
///----------------------------------------------------------------------------------------------
[SerializeField]
private SerializedEventInfo eventInfo = null;
[SerializeField]
private BBParameter<T> checkValue = null;
private System.Delegate handler;
private EventInfo targetEvent => eventInfo;
public override System.Type agentType {
get
{
if ( targetEvent == null ) { return typeof(Transform); }
return targetEvent.IsStatic() ? null : targetEvent.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( eventInfo == null ) { return "No Event Selected"; }
if ( targetEvent == null ) { return eventInfo.AsString().FormatError(); }
return string.Format("'{0}' Raised && Value == {1}", targetEvent.Name, checkValue);
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return eventInfo; }
protected override string OnInit() {
if ( eventInfo == null ) { return "No Event Selected"; }
if ( targetEvent == null ) { return eventInfo.AsString().FormatError(); }
var methodInfo = this.GetType().RTGetMethod("Raised");
handler = methodInfo.RTCreateDelegate(targetEvent.EventHandlerType, this);
return null;
}
protected override void OnEnable() {
if ( handler != null ) targetEvent.AddEventHandler(targetEvent.IsStatic() ? null : agent, handler);
}
protected override void OnDisable() {
if ( handler != null ) targetEvent.RemoveEventHandler(targetEvent.IsStatic() ? null : agent, handler);
}
public void Raised(T eventValue) {
if ( ObjectUtils.AnyEquals(checkValue.value, eventValue) ) {
YieldReturn(true);
}
}
protected override bool OnCheck() { return false; }
void SetTargetEvent(EventInfo info) {
if ( info != null ) {
eventInfo = new SerializedEventInfo(info);
}
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Event") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0) ) {
menu = EditorUtils.GetInstanceEventSelectionMenu(comp.GetType(), typeof(T), SetTargetEvent, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticEventSelectionMenu(t, typeof(T), SetTargetEvent, menu);
if ( typeof(Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceEventSelectionMenu(t, typeof(T), SetTargetEvent, menu);
}
}
menu.ShowAsBrowser("Select Event", this.GetType());
Event.current.Use();
}
if ( targetEvent != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Selected Type", targetEvent.DeclaringType.FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Selected Event", targetEvent.Name);
GUILayout.EndVertical();
NodeCanvas.Editor.BBParameterEditor.ParameterField("Check Value", checkValue);
}
}
#endif
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: e6c7c29b64d410d49a2f2b6285d02827
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/ScriptControl/CheckCSharpEvent.cs
uploadId: 704937

View File

@@ -0,0 +1,132 @@
using System.Reflection;
using NodeCanvas.Framework;
using NodeCanvas.Framework.Internal;
using ParadoxNotion;
using ParadoxNotion.Design;
using ParadoxNotion.Serialization;
using ParadoxNotion.Serialization.FullSerializer;
using UnityEngine;
using System.Linq;
namespace NodeCanvas.Tasks.Conditions
{
//previous versions
class CheckField_0
{
[SerializeField] public BBParameter checkValue = null;
[SerializeField] public System.Type targetType = null;
[SerializeField] public string fieldName = null;
}
///----------------------------------------------------------------------------------------------
[Name("Check Field", 8)]
[Category("✫ Reflected")]
[Description("Check a field on a script and return if it's equal or not to a value")]
[fsMigrateVersions(typeof(CheckField_0))]
public class CheckField : ConditionTask, IReflectedWrapper, IMigratable<CheckField_0>
{
///----------------------------------------------------------------------------------------------
void IMigratable<CheckField_0>.Migrate(CheckField_0 model) {
try { this.field = new SerializedFieldInfo(model.targetType?.RTGetField(model.fieldName)); }
finally { this.checkValue = new BBObjectParameter(model.checkValue); }
}
///----------------------------------------------------------------------------------------------
[SerializeField] protected BBObjectParameter checkValue;
[SerializeField] protected CompareMethod comparison;
[SerializeField] protected SerializedFieldInfo field;
private FieldInfo targetField => field;
public override System.Type agentType {
get
{
if ( targetField == null ) { return typeof(Transform); }
return targetField.IsStatic ? null : targetField.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( field == null ) { return "No Field Selected"; }
if ( targetField == null ) { return field.AsString().FormatError(); }
var mInfo = targetField.IsStatic ? targetField.RTReflectedOrDeclaredType().FriendlyName() : agentInfo;
return string.Format("{0}.{1}{2}{3}", mInfo, targetField.Name, OperationTools.GetCompareString(comparison), checkValue);
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return field; }
//store the field info on agent set for performance
protected override string OnInit() {
if ( field == null ) { return "No Field Selected"; }
if ( targetField == null ) { return field.AsString().FormatError(); }
return null;
}
//do it by invoking field
protected override bool OnCheck() {
if ( checkValue.varType == typeof(float) ) {
return OperationTools.Compare((float)targetField.GetValue(agent), (float)checkValue.value, comparison, 0.05f);
}
if ( checkValue.varType == typeof(int) ) {
return OperationTools.Compare((int)targetField.GetValue(agent), (int)checkValue.value, comparison);
}
return ObjectUtils.AnyEquals(targetField.GetValue(agent), checkValue.value);
}
void SetTargetField(FieldInfo newField) {
if ( newField != null ) {
UndoUtility.RecordObject(ownerSystem.contextObject, "Set Reflection Member");
field = new SerializedFieldInfo(newField);
checkValue.SetType(newField.FieldType);
comparison = CompareMethod.EqualTo;
}
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Field") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => !c.hideFlags.HasFlag(HideFlags.HideInInspector)) ) {
menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(object), SetTargetField, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticFieldSelectionMenu(t, typeof(object), SetTargetField, menu);
if ( typeof(Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(object), SetTargetField, menu);
}
}
menu.ShowAsBrowser("Select Field", this.GetType());
Event.current.Use();
}
if ( targetField != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", targetField.RTReflectedOrDeclaredType().FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Field", targetField.Name);
UnityEditor.EditorGUILayout.LabelField("Field Type", targetField.FieldType.FriendlyName());
UnityEditor.EditorGUILayout.HelpBox(XMLDocs.GetMemberSummary(targetField), UnityEditor.MessageType.None);
GUILayout.EndVertical();
GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
GUI.enabled = true;
NodeCanvas.Editor.BBParameterEditor.ParameterField("Value", checkValue);
}
}
#endif
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 7637195a7276ebf40bf185672b76251e
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/ScriptControl/CheckField.cs
uploadId: 704937

View File

@@ -0,0 +1,172 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NodeCanvas.Framework;
using NodeCanvas.Framework.Internal;
using ParadoxNotion;
using ParadoxNotion.Design;
using ParadoxNotion.Serialization;
using UnityEngine;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Check Function", 10)]
[Category("✫ Reflected")]
[Description("Call a function on a component and return whether or not the return value is equal to the check value")]
public class CheckFunction_Multiplatform : ConditionTask, IReflectedWrapper
{
[SerializeField]
protected SerializedMethodInfo method;
[SerializeField]
protected List<BBObjectParameter> parameters = new List<BBObjectParameter>();
[SerializeField]
protected CompareMethod comparison;
[SerializeField, BlackboardOnly]
protected BBObjectParameter checkValue;
private object[] args;
private bool[] parameterIsByRef;
private MethodInfo targetMethod => method;
public override System.Type agentType {
get
{
if ( targetMethod == null ) { return typeof(Transform); }
return targetMethod.IsStatic ? null : targetMethod.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( method == null ) { return "No Method Selected"; }
if ( targetMethod == null ) { return method.AsString().FormatError(); }
var paramInfo = "";
for ( var i = 0; i < parameters.Count; i++ ) {
paramInfo += ( i != 0 ? ", " : "" ) + parameters[i].ToString();
}
var mInfo = targetMethod.IsStatic ? targetMethod.RTReflectedOrDeclaredType().FriendlyName() : agentInfo;
return string.Format("{0}.{1}({2}){3}", mInfo, targetMethod.Name, paramInfo, OperationTools.GetCompareString(comparison) + checkValue);
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return method; }
public override void OnValidate(ITaskSystem ownerSystem) {
if ( method != null && method.HasChanged() ) { SetMethod(method); }
}
//store the method info on agent set for performance
protected override string OnInit() {
if ( method == null ) { return "No Method Selected"; }
if ( targetMethod == null ) { return method.AsString(); }
if ( args == null ) {
var methodParameters = targetMethod.GetParameters();
args = new object[methodParameters.Length];
parameterIsByRef = new bool[methodParameters.Length];
for ( var i = 0; i < parameters.Count; i++ ) {
parameterIsByRef[i] = methodParameters[i].ParameterType.IsByRef;
}
}
return null;
}
//do it by invoking method
protected override bool OnCheck() {
for ( var i = 0; i < parameters.Count; i++ ) {
args[i] = parameters[i].value;
}
var instance = targetMethod.IsStatic ? null : agent;
bool result;
if ( checkValue.varType == typeof(float) ) {
result = OperationTools.Compare((float)targetMethod.Invoke(instance, args), (float)checkValue.value, comparison, 0.05f);
} else if ( checkValue.varType == typeof(int) ) {
result = OperationTools.Compare((int)targetMethod.Invoke(instance, args), (int)checkValue.value, comparison);
} else {
result = ObjectUtils.AnyEquals(targetMethod.Invoke(instance, args), checkValue.value);
}
for ( var i = 0; i < parameters.Count; i++ ) {
if ( parameterIsByRef[i] ) {
parameters[i].value = args[i];
}
}
return result;
}
void SetMethod(MethodInfo method) {
if ( method == null ) {
return;
}
UndoUtility.RecordObject(ownerSystem.contextObject, "Set Reflection Member");
this.method = new SerializedMethodInfo(method);
this.parameters.Clear();
var methodParameters = method.GetParameters();
for ( var i = 0; i < methodParameters.Length; i++ ) {
var p = methodParameters[i];
var pType = p.ParameterType;
var newParam = new BBObjectParameter(pType.IsByRef ? pType.GetElementType() : pType) { bb = blackboard };
if ( p.IsOptional ) { newParam.value = p.DefaultValue; }
parameters.Add(newParam);
}
this.checkValue = new BBObjectParameter(method.ReturnType) { bb = blackboard };
comparison = CompareMethod.EqualTo;
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Method") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => !c.hideFlags.HasFlag(HideFlags.HideInInspector)) ) {
menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 10, false, true, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 10, false, true, menu);
if ( typeof(UnityEngine.Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 10, false, true, menu);
}
}
menu.ShowAsBrowser("Select Method", this.GetType());
Event.current.Use();
}
if ( targetMethod != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name);
UnityEditor.EditorGUILayout.HelpBox(XMLDocs.GetMemberSummary(targetMethod), UnityEditor.MessageType.None);
GUILayout.EndVertical();
var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase()).ToArray();
for ( var i = 0; i < paramNames.Length; i++ ) {
NodeCanvas.Editor.BBParameterEditor.ParameterField(paramNames[i], parameters[i]);
}
GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
GUI.enabled = true;
NodeCanvas.Editor.BBParameterEditor.ParameterField("Check Value", checkValue);
}
}
#endif
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2689248082fe6624ead37351e25d4d81
timeCreated: 1430482904
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/ScriptControl/CheckFunction_Multiplatform.cs
uploadId: 704937

View File

@@ -0,0 +1,121 @@
using System.Reflection;
using NodeCanvas.Framework;
using NodeCanvas.Framework.Internal;
using ParadoxNotion;
using ParadoxNotion.Design;
using ParadoxNotion.Serialization;
using UnityEngine;
using System.Linq;
namespace NodeCanvas.Tasks.Conditions
{
[Name("Check Property", 9)]
[Category("✫ Reflected")]
[Description("Check a property on a script and return if it's equal or not to the check value")]
public class CheckProperty_Multiplatform : ConditionTask, IReflectedWrapper
{
[SerializeField]
protected SerializedMethodInfo method;
[SerializeField]
protected BBObjectParameter checkValue;
[SerializeField]
protected CompareMethod comparison;
private MethodInfo targetMethod => method;
public override System.Type agentType {
get
{
if ( targetMethod == null ) { return typeof(Transform); }
return targetMethod.IsStatic ? null : targetMethod.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( method == null ) { return "No Property Selected"; }
if ( targetMethod == null ) { return method.AsString().FormatError(); }
var mInfo = targetMethod.IsStatic ? targetMethod.RTReflectedOrDeclaredType().FriendlyName() : agentInfo;
return string.Format("{0}.{1}{2}", mInfo, targetMethod.Name, OperationTools.GetCompareString(comparison) + checkValue.ToString());
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return method; }
public override void OnValidate(ITaskSystem ownerSystem) {
if ( method != null && method.HasChanged() ) { SetMethod(method); }
}
//store the method info on agent set for performance
protected override string OnInit() {
if ( method == null ) { return "No Property Selected"; }
if ( targetMethod == null ) { return method.AsString(); }
return null;
}
//do it by invoking method
protected override bool OnCheck() {
var instance = targetMethod.IsStatic ? null : agent;
if ( checkValue.varType == typeof(float) ) {
return OperationTools.Compare((float)targetMethod.Invoke(instance, null), (float)checkValue.value, comparison, 0.05f);
}
if ( checkValue.varType == typeof(int) ) {
return OperationTools.Compare((int)targetMethod.Invoke(instance, null), (int)checkValue.value, comparison);
}
return ObjectUtils.AnyEquals(targetMethod.Invoke(instance, null), checkValue.value);
}
void SetMethod(MethodInfo method) {
if ( method != null ) {
UndoUtility.RecordObject(ownerSystem.contextObject, "Set Reflection Member");
this.method = new SerializedMethodInfo(method);
this.checkValue.SetType(method.ReturnType);
comparison = CompareMethod.EqualTo;
}
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Property") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => !c.hideFlags.HasFlag(HideFlags.HideInInspector)) ) {
menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 0, true, true, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu);
if ( typeof(UnityEngine.Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu);
}
}
menu.ShowAsBrowser("Select Property", this.GetType());
Event.current.Use();
}
if ( targetMethod != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name);
UnityEditor.EditorGUILayout.HelpBox(XMLDocs.GetMemberSummary(targetMethod), UnityEditor.MessageType.None);
GUILayout.EndVertical();
GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
comparison = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
GUI.enabled = true;
NodeCanvas.Editor.BBParameterEditor.ParameterField("Value", checkValue);
}
}
#endif
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: eaff4f1c6d295bc4aa9684e6f323f562
timeCreated: 1430482605
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 14914
packageName: NodeCanvas
packageVersion: 3.3.1
assetPath: Assets/ParadoxNotion/NodeCanvas/Tasks/Conditions/ScriptControl/CheckProperty_Multiplatform.cs
uploadId: 704937

View File

@@ -0,0 +1,361 @@
using System.Reflection;
using System.Linq;
using NodeCanvas.Framework;
using ParadoxNotion;
using ParadoxNotion.Design;
using UnityEngine;
using UnityEngine.Events;
using ParadoxNotion.Serialization;
using ParadoxNotion.Serialization.FullSerializer;
namespace NodeCanvas.Tasks.Conditions
{
///----------------------------------------------------------------------------------------------
//previous versions
class CheckUnityEvent_0
{
[SerializeField] public System.Type targetType = null;
[SerializeField] public string eventName = null;
}
class CheckUnityEvent_0<T>
{
[SerializeField] public System.Type targetType = null;
[SerializeField] public string eventName = null;
}
class CheckUnityEventValue_0<T>
{
[SerializeField] public System.Type targetType = null;
[SerializeField] public string eventName = null;
}
///----------------------------------------------------------------------------------------------
[Category("✫ Reflected/Events")]
[Description("Will subscribe to a public UnityEvent and return true when that event is raised.")]
[fsMigrateVersions(typeof(CheckUnityEvent_0))]
public class CheckUnityEvent : ConditionTask, IReflectedWrapper, IMigratable<CheckUnityEvent_0>
{
///----------------------------------------------------------------------------------------------
void IMigratable<CheckUnityEvent_0>.Migrate(CheckUnityEvent_0 model) {
this._eventInfo = new SerializedUnityEventInfo(model.targetType?.RTGetField(model.eventName));
}
///----------------------------------------------------------------------------------------------
[SerializeField] private SerializedUnityEventInfo _eventInfo = null;
private MemberInfo targetMember => _eventInfo != null ? _eventInfo.AsMemberInfo() : null;
private bool isStatic => _eventInfo != null ? _eventInfo.isStatic : false;
private System.Type eventType => _eventInfo != null ? _eventInfo.memberType : null;
private FieldInfo targetEventField => _eventInfo;
private PropertyInfo targetEventProp => _eventInfo;
private UnityEvent unityEvent;
public override System.Type agentType {
get
{
if ( targetMember == null ) { return typeof(Transform); }
return isStatic ? null : targetMember.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( _eventInfo == null ) { return "No Event Selected"; }
if ( targetMember == null ) { return _eventInfo.AsString().FormatError(); }
return string.Format("'{0}' Raised", targetMember.Name);
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return _eventInfo; }
protected override string OnInit() {
if ( _eventInfo == null ) { return "No Event Selected"; }
if ( targetMember == null ) { return _eventInfo.AsString(); }
if ( targetEventField != null ) { unityEvent = (UnityEvent)targetEventField.GetValue(agent); }
if ( targetEventProp != null ) { unityEvent = (UnityEvent)targetEventProp.GetValue(agent); }
return null;
}
protected override void OnEnable() {
if ( unityEvent != null ) { unityEvent.AddListener(Raised); }
}
protected override void OnDisable() {
if ( unityEvent != null ) { unityEvent.RemoveListener(Raised); }
}
public void Raised() { YieldReturn(true); }
protected override bool OnCheck() { return false; }
void SetTargetEvent(MemberInfo newMember) {
if ( newMember != null ) {
UndoUtility.RecordObject(ownerSystem.contextObject, "Set Reflection Member");
_eventInfo = new SerializedUnityEventInfo(newMember);
}
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Event") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => !c.hideFlags.HasFlag(HideFlags.HideInInspector)) ) {
menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(UnityEvent), SetTargetEvent, menu);
menu = EditorUtils.GetInstancePropertySelectionMenu(comp.GetType(), typeof(UnityEvent), SetTargetEvent, true, false, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticFieldSelectionMenu(t, typeof(UnityEvent), SetTargetEvent, menu);
menu = EditorUtils.GetStaticPropertySelectionMenu(t, typeof(UnityEvent), SetTargetEvent, true, false, menu);
if ( typeof(Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(UnityEvent), SetTargetEvent, menu);
menu = EditorUtils.GetInstancePropertySelectionMenu(t, typeof(UnityEvent), SetTargetEvent, true, false, menu);
}
}
menu.ShowAsBrowser("Select Event", this.GetType());
Event.current.Use();
}
if ( targetMember != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", targetMember.RTReflectedOrDeclaredType().FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Event", targetMember.Name);
UnityEditor.EditorGUILayout.LabelField("Event Type", eventType.FriendlyName());
GUILayout.EndVertical();
}
}
#endif
}
///----------------------------------------------------------------------------------------------
[Category("✫ Reflected/Events")]
[Description("Will subscribe to a public UnityEvent<T> and return true when that event is raised.")]
[fsMigrateVersions(typeof(CheckUnityEvent_0<>))]
public class CheckUnityEvent<T> : ConditionTask, IReflectedWrapper, IMigratable<CheckUnityEvent_0<T>>
{
///----------------------------------------------------------------------------------------------
void IMigratable<CheckUnityEvent_0<T>>.Migrate(CheckUnityEvent_0<T> model) {
this._eventInfo = new SerializedUnityEventInfo(model.targetType?.RTGetField(model.eventName));
}
///----------------------------------------------------------------------------------------------
[SerializeField]
private SerializedUnityEventInfo _eventInfo = null;
[SerializeField, BlackboardOnly]
private BBParameter<T> saveAs = null;
private MemberInfo targetMember => _eventInfo != null ? _eventInfo.AsMemberInfo() : null;
private bool isStatic => _eventInfo != null ? _eventInfo.isStatic : false;
private System.Type eventType => _eventInfo != null ? _eventInfo.memberType : null;
private FieldInfo targetEventField => _eventInfo;
private PropertyInfo targetEventProp => _eventInfo;
private UnityEvent<T> unityEvent;
public override System.Type agentType {
get
{
if ( targetMember == null ) { return typeof(Transform); }
return isStatic ? null : targetMember.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( _eventInfo == null ) { return "No Event Selected"; }
if ( targetMember == null ) { return _eventInfo.AsString().FormatError(); }
return string.Format("'{0}' Raised", targetMember.Name);
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return _eventInfo; }
protected override string OnInit() {
if ( _eventInfo == null ) { return "No Event Selected"; }
if ( targetMember == null ) { return _eventInfo.AsString(); }
if ( targetEventField != null ) { unityEvent = (UnityEvent<T>)targetEventField.GetValue(agent); }
if ( targetEventProp != null ) { unityEvent = (UnityEvent<T>)targetEventProp.GetValue(agent); }
return null;
}
protected override void OnEnable() {
if ( unityEvent != null ) { unityEvent.AddListener(Raised); }
}
protected override void OnDisable() {
if ( unityEvent != null ) { unityEvent.RemoveListener(Raised); }
}
public void Raised(T eventValue) {
saveAs.value = eventValue;
YieldReturn(true);
}
protected override bool OnCheck() { return false; }
void SetTargetEvent(MemberInfo newMember) {
if ( newMember != null ) { _eventInfo = new SerializedUnityEventInfo(newMember); }
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Event") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0) ) {
menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(UnityEvent<T>), SetTargetEvent, menu);
menu = EditorUtils.GetInstancePropertySelectionMenu(comp.GetType(), typeof(UnityEvent<T>), SetTargetEvent, true, false, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticFieldSelectionMenu(t, typeof(UnityEvent<T>), SetTargetEvent, menu);
menu = EditorUtils.GetStaticPropertySelectionMenu(t, typeof(UnityEvent<T>), SetTargetEvent, true, false, menu);
if ( typeof(Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(UnityEvent<T>), SetTargetEvent, menu);
menu = EditorUtils.GetInstancePropertySelectionMenu(t, typeof(UnityEvent<T>), SetTargetEvent, true, false, menu);
}
}
menu.ShowAsBrowser("Select Event", this.GetType());
Event.current.Use();
}
if ( targetMember != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", targetMember.RTReflectedOrDeclaredType().FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Event", targetMember.Name);
UnityEditor.EditorGUILayout.LabelField("Event Type", eventType.FriendlyName());
GUILayout.EndVertical();
NodeCanvas.Editor.BBParameterEditor.ParameterField("Save Value As", saveAs, true);
}
}
#endif
}
///----------------------------------------------------------------------------------------------
[Category("✫ Reflected/Events")]
[Description("Will subscribe to a public UnityEvent<T> and return true when that event is raised and it's value is equal to provided value as well.")]
[fsMigrateVersions(typeof(CheckUnityEventValue_0<>))]
public class CheckUnityEventValue<T> : ConditionTask, IReflectedWrapper, IMigratable<CheckUnityEventValue_0<T>>
{
///----------------------------------------------------------------------------------------------
void IMigratable<CheckUnityEventValue_0<T>>.Migrate(CheckUnityEventValue_0<T> model) {
this._eventInfo = new SerializedUnityEventInfo(model.targetType?.RTGetField(model.eventName));
}
///----------------------------------------------------------------------------------------------
[SerializeField] private SerializedUnityEventInfo _eventInfo = null;
[SerializeField] private BBParameter<T> checkValue = null;
private MemberInfo targetMember => _eventInfo != null ? _eventInfo.AsMemberInfo() : null;
private bool isStatic => _eventInfo != null ? _eventInfo.isStatic : false;
private System.Type eventType => _eventInfo != null ? _eventInfo.memberType : null;
private FieldInfo targetEventField => _eventInfo;
private PropertyInfo targetEventProp => _eventInfo;
private UnityEvent<T> unityEvent;
public override System.Type agentType {
get
{
if ( targetMember == null ) { return typeof(Transform); }
return isStatic ? null : targetMember.RTReflectedOrDeclaredType();
}
}
protected override string info {
get
{
if ( _eventInfo == null ) { return "No Event Selected"; }
if ( targetMember == null ) { return _eventInfo.AsString().FormatError(); }
return string.Format("'{0}' Raised && Value == {1}", targetMember.Name, checkValue);
}
}
ISerializedReflectedInfo IReflectedWrapper.GetSerializedInfo() { return _eventInfo; }
protected override string OnInit() {
if ( _eventInfo == null ) { return "No Event Selected"; }
if ( targetEventField == null ) { return _eventInfo.AsString(); }
if ( targetEventField != null ) { unityEvent = (UnityEvent<T>)targetEventField.GetValue(agent); }
if ( targetEventProp != null ) { unityEvent = (UnityEvent<T>)targetEventProp.GetValue(agent); }
return null;
}
protected override void OnEnable() {
if ( unityEvent != null ) { unityEvent.AddListener(Raised); }
}
protected override void OnDisable() {
if ( unityEvent != null ) { unityEvent.RemoveListener(Raised); }
}
public void Raised(T eventValue) {
if ( ObjectUtils.AnyEquals(checkValue.value, eventValue) ) {
YieldReturn(true);
}
}
protected override bool OnCheck() { return false; }
void SetTargetEvent(MemberInfo newMember) {
if ( newMember != null ) { _eventInfo = new SerializedUnityEventInfo(newMember); }
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( !Application.isPlaying && GUILayout.Button("Select Event") ) {
var menu = new UnityEditor.GenericMenu();
if ( agent != null ) {
foreach ( var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags == 0) ) {
menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(UnityEvent<T>), SetTargetEvent, menu);
menu = EditorUtils.GetInstancePropertySelectionMenu(comp.GetType(), typeof(UnityEvent<T>), SetTargetEvent, true, false, menu);
}
menu.AddSeparator("/");
}
foreach ( var t in TypePrefs.GetPreferedTypesList(typeof(object)) ) {
menu = EditorUtils.GetStaticFieldSelectionMenu(t, typeof(UnityEvent<T>), SetTargetEvent, menu);
menu = EditorUtils.GetStaticPropertySelectionMenu(t, typeof(UnityEvent<T>), SetTargetEvent, true, false, menu);
if ( typeof(Component).IsAssignableFrom(t) ) {
menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(UnityEvent<T>), SetTargetEvent, menu);
menu = EditorUtils.GetInstancePropertySelectionMenu(t, typeof(UnityEvent<T>), SetTargetEvent, true, false, menu);
}
}
menu.ShowAsBrowser("Select Event", this.GetType());
Event.current.Use();
}
if ( targetMember != null ) {
GUILayout.BeginVertical("box");
UnityEditor.EditorGUILayout.LabelField("Type", targetMember.RTReflectedOrDeclaredType().FriendlyName());
UnityEditor.EditorGUILayout.LabelField("Event", targetMember.Name);
UnityEditor.EditorGUILayout.LabelField("Event Type", eventType.FriendlyName());
GUILayout.EndVertical();
NodeCanvas.Editor.BBParameterEditor.ParameterField("Check Value", checkValue);
}
}
#endif
}
}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: fe46d20c88d90154b83bcaac3641ad85
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/ScriptControl/CheckUnityEvent.cs
uploadId: 704937

Some files were not shown because too many files have changed in this diff Show More