chore: initial commit

This commit is contained in:
2026-05-08 11:04:00 +08:00
commit f55d2a57c3
6278 changed files with 866081 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
/// <summary>
/// A TaskObject implementation of the Action task.
/// </summary>
[NodeIcon("3bbdfa553da4d554e9d74f8d88915aac", "6437308e972f99f48953f20198fd4e94")]
public abstract class Action : Task, IAction
{
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 24e232a868c7a0d439cb82feeb963c8e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using UnityEngine;
/// <summary>
/// A TaskObject implementation of the Action task. This class can be used when the task should not be grouped by the StackedAction task.
/// </summary>
[NodeIcon("3bbdfa553da4d554e9d74f8d88915aac", "6437308e972f99f48953f20198fd4e94")]
public abstract class ActionNode : Task, ITreeLogicNode, IAction
{
[Tooltip("The index of the node.")]
[SerializeField] ushort m_Index;
[Tooltip("The parent index of the node. ushort.MaxValue indicates no parent.")]
[SerializeField] ushort m_ParentIndex;
[Tooltip("The sibling index of the node. ushort.MaxValue indicates no sibling.")]
[SerializeField] ushort m_SiblingIndex;
public ushort Index { get => m_Index; set => m_Index = value; }
public ushort ParentIndex { get => m_ParentIndex; set => m_ParentIndex = value; }
public ushort SiblingIndex { get => m_SiblingIndex; set => m_SiblingIndex = value; }
public ushort RuntimeIndex { get; set; }
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f95ceadf4eaf7df499091158c2ba5178
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a57b0c8b5bd7c5142963151eb3723e6e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a boolean value to a float value (true = 1.0, false = 0.0).")]
[Shared.Utility.Category("Conversions")]
public class ConvertBoolToFloat : Action
{
[Tooltip("The boolean value to convert.")]
[SerializeField] protected SharedVariable<bool> m_Value;
[Tooltip("The variable that should be set to the converted float value.")]
[RequireShared] [SerializeField] protected SharedVariable<float> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value ? 1.0f : 0.0f;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73c605544c0648e4bbf8dcfe72348337
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a boolean value to an integer value (true = 1, false = 0).")]
[Shared.Utility.Category("Conversions")]
public class ConvertBoolToInt : Action
{
[Tooltip("The boolean value to convert.")]
[SerializeField] protected SharedVariable<bool> m_Value;
[Tooltip("The variable that should be set to the converted integer value.")]
[RequireShared] [SerializeField] protected SharedVariable<int> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value ? 1 : 0;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3955564edbd009346b730327375e3d48
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a boolean value to a string value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertBoolToString : Action
{
[Tooltip("The boolean value to convert.")]
[SerializeField] protected SharedVariable<bool> m_Value;
[Tooltip("The variable that should be set to the converted string value.")]
[RequireShared] [SerializeField] protected SharedVariable<string> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value.ToString();
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 888e5ecfd2f882346ad4879020c18283
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a float value to a boolean value (0.0 = false, non-zero = true).")]
[Shared.Utility.Category("Conversions")]
public class ConvertFloatToBool : Action
{
[Tooltip("The float value to convert.")]
[SerializeField] protected SharedVariable<float> m_Value;
[Tooltip("The variable that should be set to the converted boolean value.")]
[RequireShared] [SerializeField] protected SharedVariable<bool> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value != 0.0f;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 49e265c8db111534fab491cfc5672622
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a float value to an integer value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertFloatToInt : Action
{
[Tooltip("The float value to convert.")]
[SerializeField] protected SharedVariable<float> m_Value;
[Tooltip("The variable that should be set to the converted integer value.")]
[RequireShared] [SerializeField] protected SharedVariable<int> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = Mathf.RoundToInt(m_Value.Value);
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7e596c94da53a4a45ad9113b33a1aea4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a float value to a string value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertFloatToString : Action
{
[Tooltip("The float value to convert.")]
[SerializeField] protected SharedVariable<float> m_Value;
[Tooltip("The variable that should be set to the converted string value.")]
[RequireShared] [SerializeField] protected SharedVariable<string> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value.ToString();
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc1ceef260c01c645b8b47ce20199dc6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a GameObject value to a Transform value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertGameObjectToTransform : Action
{
[Tooltip("The GameObject value to convert.")]
[SerializeField] protected SharedVariable<GameObject> m_Value;
[Tooltip("The variable that should be set to the converted Transform value.")]
[RequireShared] [SerializeField] protected SharedVariable<Transform> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_Value.Value != null) {
m_StoreResult.Value = m_Value.Value.transform;
return TaskStatus.Success;
}
m_StoreResult.Value = null;
return TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a297e510d0a945c449c2d125813fe9d9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts an integer value to a boolean value (0 = false, non-zero = true).")]
[Shared.Utility.Category("Conversions")]
public class ConvertIntToBool : Action
{
[Tooltip("The integer value to convert.")]
[SerializeField] protected SharedVariable<int> m_Value;
[Tooltip("The variable that should be set to the converted boolean value.")]
[RequireShared] [SerializeField] protected SharedVariable<bool> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value != 0;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67e0599636ba3b7419611ae159070c04
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts an integer value to a float value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertIntToFloat : Action
{
[Tooltip("The integer value to convert.")]
[SerializeField] protected SharedVariable<int> m_Value;
[Tooltip("The variable that should be set to the converted float value.")]
[RequireShared] [SerializeField] protected SharedVariable<float> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 07440ccf7d92b14498b7e4c7b9e08e5e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts an integer value to a string value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertIntToString : Action
{
[Tooltip("The integer value to convert.")]
[SerializeField] protected SharedVariable<int> m_Value;
[Tooltip("The variable that should be set to the converted string value.")]
[RequireShared] [SerializeField] protected SharedVariable<string> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value.ToString();
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eeadd74b13bc65d45af983c98b9f3e01
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a string value to a boolean value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertStringToBool : Action
{
[Tooltip("The string value to convert.")]
[SerializeField] protected SharedVariable<string> m_Value;
[Tooltip("The variable that should be set to the converted boolean value.")]
[RequireShared] [SerializeField] protected SharedVariable<bool> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (bool.TryParse(m_Value.Value, out bool result)) {
m_StoreResult.Value = result;
return TaskStatus.Success;
}
return TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 336754ea3fd33e44e91733089662ebd7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a string value to a float value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertStringToFloat : Action
{
[Tooltip("The string value to convert.")]
[SerializeField] protected SharedVariable<string> m_Value;
[Tooltip("The variable that should be set to the converted float value.")]
[RequireShared] [SerializeField] protected SharedVariable<float> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (float.TryParse(m_Value.Value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out float result)) {
m_StoreResult.Value = result;
return TaskStatus.Success;
}
return TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d22d87f8a2847f34185c0ff330b89209
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a string value to an integer value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertStringToInt : Action
{
[Tooltip("The string value to convert.")]
[SerializeField] protected SharedVariable<string> m_Value;
[Tooltip("The variable that should be set to the converted integer value.")]
[RequireShared] [SerializeField] protected SharedVariable<int> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (int.TryParse(m_Value.Value, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out int result)) {
m_StoreResult.Value = result;
return TaskStatus.Success;
}
return TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e2d95d3a42e27184da971d47c792ff72
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Converts a Transform value to a GameObject value.")]
[Shared.Utility.Category("Conversions")]
public class ConvertTransformToGameObject : Action
{
[Tooltip("The Transform value to convert.")]
[SerializeField] protected SharedVariable<Transform> m_Value;
[Tooltip("The variable that should be set to the converted GameObject value.")]
[RequireShared] [SerializeField] protected SharedVariable<GameObject> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_Value.Value != null) {
m_StoreResult.Value = m_Value.Value.gameObject;
return TaskStatus.Success;
}
m_StoreResult.Value = null;
return TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 36617d392cb63e24184a825b05f4f78a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 31447ed8785ef5146bbb37d6466c1954
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.UnityObjects
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using Opsive.Shared.Utility;
using UnityEngine;
[Opsive.Shared.Utility.Description("Adds the GameObject to the array.")]
[Shared.Utility.Category("Lists")]
public class AddGameObjectToArray : TargetGameObjectAction
{
[Tooltip("The list of possible GameObjects.")]
[RequireShared] [SerializeField] protected SharedVariable<GameObject[]> m_StoreResult;
[Tooltip("Are duplicates allowed to be added?")]
[SerializeField] protected SharedVariable<bool> m_AllowDuplicates = true;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (!m_AllowDuplicates.Value && m_StoreResult.Value.Contains(m_ResolvedGameObject)) {
return TaskStatus.Failure;
}
var array = m_StoreResult.Value;
if (array == null) {
array = new GameObject[1];
} else {
System.Array.Resize(ref array, array.Length + 1);
}
m_StoreResult.Value = array;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0e15921d659313647b2d4d2b3c76c6ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.UnityObjects
{
using Opsive.GraphDesigner.Runtime.Variables;
using System.Collections.Generic;
using UnityEngine;
[Opsive.Shared.Utility.Description("Adds the GameObject to the list.")]
[Shared.Utility.Category("Lists")]
public class AddGameObjectToList : TargetGameObjectAction
{
[Tooltip("The list of possible GameObjects.")]
[RequireShared] [SerializeField] protected SharedVariable<List<GameObject>> m_StoreResult;
[Tooltip("Are duplicates allowed to be added?")]
[SerializeField] protected SharedVariable<bool> m_AllowDuplicates = true;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (!m_AllowDuplicates.Value && m_StoreResult.Value.Contains(m_ResolvedGameObject)) {
return TaskStatus.Failure;
}
m_StoreResult.Value.Add(m_ResolvedGameObject);
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 771474f9417f55641b0b1a23028e05d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.UnityObjects
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Sets a random GameObject value from the GameObject array.")]
[Shared.Utility.Category("Lists")]
public class RandomGameObjectFromArray : Action
{
[Tooltip("The list of possible GameObjects.")]
[SerializeField] protected SharedVariable<GameObject[]> m_GameObjects;
[Tooltip("The variable that should be set.")]
[RequireShared] [SerializeField] protected SharedVariable<GameObject> m_StoreResult;
[Tooltip("The seed of the random number generator. Set to 0 to disable.")]
[SerializeField] protected int m_Seed;
/// <summary>
/// Callback when the behavior tree is initialized.
/// </summary>
public override void OnAwake()
{
if (m_Seed != 0) {
Random.InitState(m_Seed);
}
}
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_GameObjects.Value == null || m_GameObjects.Value.Length == 0) {
return TaskStatus.Failure;
}
m_StoreResult.Value = m_GameObjects.Value[Random.Range(0, m_GameObjects.Value.Length)];
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a32475ebd3e6d3145bd238c01607ea15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.UnityObjects
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
using System.Collections.Generic;
[Opsive.Shared.Utility.Description("Sets a random GameObject value from the GameObject list.")]
[Shared.Utility.Category("Lists")]
public class RandomGameObjectFromList : Action
{
[Tooltip("The list of possible GameObjects.")]
[SerializeField] protected SharedVariable<List<GameObject>> m_GameObjects;
[Tooltip("The variable that should be set.")]
[RequireShared] [SerializeField] protected SharedVariable<GameObject> m_StoreResult;
[Tooltip("The seed of the random number generator. Set to 0 to disable.")]
[SerializeField] protected int m_Seed;
/// <summary>
/// Callback when the behavior tree is initialized.
/// </summary>
public override void OnAwake()
{
if (m_Seed != 0) {
Random.InitState(m_Seed);
}
}
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_GameObjects.Value == null || m_GameObjects.Value.Count == 0) {
return TaskStatus.Failure;
}
m_StoreResult.Value = m_GameObjects.Value[Random.Range(0, m_GameObjects.Value.Count)];
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b7809ab5aee37184c9a3f0c4b013ab0a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,57 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.UnityObjects
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Removes the GameObject from the array.")]
[Shared.Utility.Category("Lists")]
public class RemoveGameObjectFromArray : TargetGameObjectAction
{
[Tooltip("The list of possible GameObjects.")]
[RequireShared] [SerializeField] protected SharedVariable<GameObject[]> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
var array = m_StoreResult.Value;
if (array == null) {
return TaskStatus.Failure;
}
// Find the index of the GameObject to remove.
var indexToRemove = -1;
for (int i = 0; i < array.Length; i++) {
if (array[i] == m_ResolvedGameObject) {
indexToRemove = i;
break;
}
}
if (indexToRemove == -1) {
return TaskStatus.Failure;
}
// Create a new array with the GameObject removed.
var newArray = new GameObject[array.Length - 1];
for (int i = 0, j = 0; i < array.Length; ++i) {
if (i != indexToRemove) {
newArray[j] = array[i];
++j;
}
}
m_StoreResult.Value = newArray;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29d1b655a839c324c9ca4b12f3af0351
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.UnityObjects
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using System.Collections.Generic;
using UnityEngine;
[Opsive.Shared.Utility.Description("Removes the GameObject from the list.")]
[Shared.Utility.Category("Lists")]
public class RemoveGameObjectFromList : TargetGameObjectAction
{
[Tooltip("The list of possible GameObjects.")]
[RequireShared] [SerializeField] protected SharedVariable<List<GameObject>> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
return m_StoreResult.Value.Remove(m_ResolvedGameObject) ? TaskStatus.Success : TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 89e178d0be1b41b4b933d144dc32aef1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.UnityObjects
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Selects the GameObject from the array.")]
[Shared.Utility.Category("Lists")]
public class SelectGameObjectFromArray : Action
{
[Tooltip("The list of possible GameObjects.")]
[SerializeField] protected SharedVariable<GameObject[]> m_GameObjects;
[Tooltip("The index of the GameObject that should be selected.")]
[SerializeField] protected SharedVariable<int> m_ElementIndex;
[Tooltip("The selected GameObject.")]
[RequireShared] [SerializeField] protected SharedVariable<GameObject> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_GameObjects.Value == null || m_ElementIndex.Value < 0 || m_ElementIndex.Value > m_GameObjects.Value.Length) {
return TaskStatus.Failure;
}
m_StoreResult.Value = m_GameObjects.Value[m_ElementIndex.Value];
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d082de8064bdd7c4dada3c5a48e46fef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.UnityObjects
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using System.Collections.Generic;
using UnityEngine;
[Opsive.Shared.Utility.Description("Selects the GameObject from the list.")]
[Shared.Utility.Category("Lists")]
public class SelectGameObjectFromList : Action
{
[Tooltip("The list of possible GameObjects.")]
[SerializeField] protected SharedVariable<List<GameObject>> m_GameObjects;
[Tooltip("The index of the GameObject that should be selected.")]
[SerializeField] protected SharedVariable<int> m_ElementIndex;
[Tooltip("The selected GameObject.")]
[RequireShared] [SerializeField] protected SharedVariable<GameObject> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_GameObjects.Value == null || m_ElementIndex.Value < 0 || m_ElementIndex.Value > m_GameObjects.Value.Count) {
return TaskStatus.Failure;
}
m_StoreResult.Value = m_GameObjects.Value[m_ElementIndex.Value];
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0dab44acdb589c4a8d2966c9ddc73a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,96 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.BehaviorDesigner.Runtime.Components;
using Opsive.GraphDesigner.Runtime;
using Unity.Entities;
using Unity.Burst;
using UnityEngine;
/// <summary>
/// A node representation of the idle task.
/// </summary>
[NodeIcon("fc4d1b83384913b4abfbd8455db6df5b", "79a6985a753bb244fb5b32dc0f26addb")]
[Opsive.Shared.Utility.Description("Returns a TaskStatus of running. The task will only stop when interrupted or a conditional abort is triggered.")]
public class Idle : ECSActionTask<IdleTaskSystem, IdleComponent>
{
/// <summary>
/// The type of tag that should be enabled when the task is running.
/// </summary>
public override ComponentType Flag { get => typeof(IdleFlag); }
/// <summary>
/// Returns a new TBufferElement for use by the system.
/// </summary>
/// <returns>A new TBufferElement for use by the system.</returns>
public override IdleComponent GetBufferElement()
{
return new IdleComponent() {
Index = RuntimeIndex
};
}
}
/// <summary>
/// The DOTS data structure for the Idle class.
/// </summary>
public struct IdleComponent : IBufferElementData
{
[Tooltip("The index of the node.")]
public ushort Index;
}
/// <summary>
/// A DOTS tag indicating when a Idle node is active.
/// </summary>
public struct IdleFlag : IComponentData, IEnableableComponent { }
/// <summary>
/// Runs the Idle logic.
/// </summary>
[DisableAutoCreation]
public partial struct IdleTaskSystem : ISystem
{
/// <summary>
/// Creates the job.
/// </summary>
/// <param name="state">The current state of the system.</param>
[BurstCompile]
private void OnUpdate(ref SystemState state)
{
var query = SystemAPI.QueryBuilder().WithAllRW<TaskComponent>().WithAll<IdleComponent, IdleFlag, EvaluateFlag>().Build();
state.Dependency = new IdleJob().ScheduleParallel(query, state.Dependency);
}
/// <summary>
/// Job which executes the task logic.
/// </summary>
[BurstCompile]
private partial struct IdleJob : IJobEntity
{
/// <summary>
/// Executes the idle logic.
/// </summary>
/// <param name="taskComponents">An array of TaskComponents.</param>
/// <param name="idleComponents">An array of IdleComponents.</param>
[BurstCompile]
public void Execute(ref DynamicBuffer<TaskComponent> taskComponents, ref DynamicBuffer<IdleComponent> idleComponents)
{
for (int i = 0; i < idleComponents.Length; ++i) {
var idleComponent = idleComponents[i];
var taskComponent = taskComponents[idleComponent.Index];
if (taskComponent.Status == TaskStatus.Queued) {
taskComponent.Status = TaskStatus.Running;
taskComponents[idleComponent.Index] = taskComponent;
}
}
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3cbbfc0d48db475498ad454651507929
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
/// <summary>
/// Logs the specified string.
/// </summary>
[NodeIcon("c97bee71424b3e247a161d1279643506", "138439e3588de5d449b7949d68d32ad8")]
[Opsive.Shared.Utility.Description("A simple task which will output the specified text and return success. It can be used for debugging.")]
public class Log : Action
{
[Tooltip("The string that should be outputted to the console.")]
[SerializeField] protected SharedVariable<string> m_Text;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
Debug.Log(m_Text.Value);
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74a01e8c621648b44bb6cf0cff363e59
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
/// <summary>
/// Logs the specified value.
/// </summary>
[NodeIcon("c97bee71424b3e247a161d1279643506", "138439e3588de5d449b7949d68d32ad8")]
public class LogValue : Action
{
[Tooltip("The value that should be outputted to the console.")]
[RequireShared] [SerializeField] protected SharedVariable m_Value;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_Value == null || m_Value.Scope == SharedVariable.SharingScope.Empty) {
Debug.LogWarning("Warning: The LogValue.Value variable must be set.");
return TaskStatus.Failure;
}
Debug.Log(m_Value.GetValue());
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0e6b3f8ede31f634ea1aa5727a7df673
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7177abfd9732b2d45aec5e96e4415d68
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Flips the value of the boolean.")]
[Shared.Utility.Category("Math")]
public class BoolFlip : Action
{
[Tooltip("The bool that should be flipped.")]
[SerializeField] protected SharedVariable<bool> m_Bool;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_Bool.Value = !m_Bool.Value;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6654554de66a1340bff69fd22ffcacf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,61 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Performs a math operation on the two booleans.")]
[Shared.Utility.Category("Math")]
public class BoolOperator : Action
{
/// <summary>
/// Specifies the type of bool operation that should be performed.
/// </summary>
protected enum Operation
{
AND, // Returns the AND between two booleans.
OR, // Returns the OR between two booleans.
NAND, // Returns the NAND between two booleans.
XOR, // Returns the XOR between two booleans.
}
[Tooltip("The operation to perform.")]
[SerializeField] protected SharedVariable<Operation> m_Operation;
[Tooltip("The first boolean.")]
[SerializeField] protected SharedVariable<bool> m_Bool1;
[Tooltip("The second boolean.")]
[SerializeField] protected SharedVariable<bool> m_Bool2;
[Tooltip("The variable to store the result.")]
[RequireShared] [SerializeField] protected SharedVariable<bool> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
switch (m_Operation.Value) {
case Operation.AND:
m_StoreResult.Value = m_Bool1.Value && m_Bool2.Value;
break;
case Operation.OR:
m_StoreResult.Value = m_Bool1.Value || m_Bool2.Value;
break;
case Operation.NAND:
m_StoreResult.Value = !(m_Bool1.Value && m_Bool2.Value);
break;
case Operation.XOR:
m_StoreResult.Value = (m_Bool1.Value ^ m_Bool2.Value);
break;
}
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf243997f53145143915ba48268817b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Performs a math operation on the two floats.")]
[Shared.Utility.Category("Math")]
public class FloatOperator : Action
{
/// <summary>
/// Specifies the type of float operation that should be performed.
/// </summary>
protected enum Operation
{
Add, // Returns the addition between two floats.
Subtract, // Returns the division between two floats.
Multiply, // Returns the multiplication between two floats.
Divide, // Returns the division between two floats.
Modulo, // Returns the modulo between two floats.
Min, // Returns the minimum of two floats.
Max, // Returns the maximum of two floats.
}
[Tooltip("The operation to perform.")]
[SerializeField] protected SharedVariable<Operation> m_Operation;
[Tooltip("The first float.")]
[SerializeField] protected SharedVariable<float> m_Float1;
[Tooltip("The second float.")]
[SerializeField] protected SharedVariable<float> m_Float2;
[Tooltip("The variable to store the result.")]
[RequireShared] [SerializeField] protected SharedVariable<float> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
switch (m_Operation.Value) {
case Operation.Add:
m_StoreResult.Value = m_Float1.Value + m_Float2.Value;
break;
case Operation.Subtract:
m_StoreResult.Value = m_Float1.Value - m_Float2.Value;
break;
case Operation.Multiply:
m_StoreResult.Value = m_Float1.Value * m_Float2.Value;
break;
case Operation.Divide:
m_StoreResult.Value = m_Float1.Value / m_Float2.Value;
break;
case Operation.Modulo:
m_StoreResult.Value = m_Float1.Value % m_Float2.Value;
break;
case Operation.Min:
m_StoreResult.Value = Mathf.Min(m_Float1.Value, m_Float2.Value);
break;
case Operation.Max:
m_StoreResult.Value = Mathf.Max(m_Float1.Value, m_Float2.Value);
break;
}
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd85a074520c85b4aac9a2e02a37fe47
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Performs a math operation on the two integers.")]
[Shared.Utility.Category("Math")]
public class IntOperator : Action
{
/// <summary>
/// Specifies the type of int operation that should be performed.
/// </summary>
protected enum Operation
{
Add, // Returns the addition between two integers.
Subtract, // Returns the division between two integers.
Multiply, // Returns the multiplication between two integers.
Divide, // Returns the division between two integers.
Modulo, // Returns the modulo between two integers.
Min, // Returns the minimum of two integers.
Max, // Returns the maximum of two integers.
}
[Tooltip("The operation to perform.")]
[SerializeField] protected SharedVariable<Operation> m_Operation;
[Tooltip("The first integer.")]
[SerializeField] protected SharedVariable<int> m_Integer1;
[Tooltip("The second integer.")]
[SerializeField] protected SharedVariable<int> m_Integer2;
[Tooltip("The variable to store the result.")]
[RequireShared] [SerializeField] protected SharedVariable<int> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
switch (m_Operation.Value) {
case Operation.Add:
m_StoreResult.Value = m_Integer1.Value + m_Integer2.Value;
break;
case Operation.Subtract:
m_StoreResult.Value = m_Integer1.Value - m_Integer2.Value;
break;
case Operation.Multiply:
m_StoreResult.Value = m_Integer1.Value * m_Integer2.Value;
break;
case Operation.Divide:
m_StoreResult.Value = m_Integer1.Value / m_Integer2.Value;
break;
case Operation.Modulo:
m_StoreResult.Value = m_Integer1.Value % m_Integer2.Value;
break;
case Operation.Min:
m_StoreResult.Value = Mathf.Min(m_Integer1.Value, m_Integer2.Value);
break;
case Operation.Max:
m_StoreResult.Value = Mathf.Max(m_Integer1.Value, m_Integer2.Value);
break;
}
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77d11b9520f296b43a19d4a987844d73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Tasks.Actions.Math
{
using Opsive.BehaviorDesigner.Runtime.Tasks;
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Tooltip("Returns a random bool value.")]
[Shared.Utility.Category("Math")]
public class RandomBool : Action
{
[Tooltip("The stored random bool value.")]
[RequireShared] [SerializeField] protected SharedVariable<bool> m_StoreResult;
[Tooltip("The seed of the random number generator. Set to 0 to disable.")]
[SerializeField] protected int m_Seed;
/// <summary>
/// Callback when the behavior tree is initialized.
/// </summary>
public override void OnAwake()
{
if (m_Seed != 0) {
Random.InitState(m_Seed);
}
}
/// <summary>
/// Executes the task logic.
/// </summary>
/// <returns>The status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = Random.value > 0.5;
return base.OnUpdate();
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e39f6d31610d07b4ca1c977ce86198bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Tasks.Actions.Math
{
using Opsive.BehaviorDesigner.Runtime.Tasks;
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Tooltip("Returns a random float between the specified values (inclusive).")]
[Shared.Utility.Category("Math")]
public class RandomFloat : Action
{
[Tooltip("The minimum float value (inclusive).")]
[SerializeField] protected SharedVariable<float> m_MinimumFloat;
[Tooltip("The maximum float value (inclusive).")]
[SerializeField] protected SharedVariable<float> m_MaximumFloat;
[Tooltip("The stored random float value.")]
[RequireShared] [SerializeField] protected SharedVariable<float> m_StoreResult;
[Tooltip("The seed of the random number generator. Set to 0 to disable.")]
[SerializeField] protected int m_Seed;
/// <summary>
/// Callback when the behavior tree is initialized.
/// </summary>
public override void OnAwake()
{
if (m_Seed != 0) {
Random.InitState(m_Seed);
}
}
/// <summary>
/// Executes the task logic.
/// </summary>
/// <returns>The status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = Random.Range(m_MinimumFloat.Value, m_MaximumFloat.Value);
return base.OnUpdate();
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4cd0328bf01f2a46a89268dcaf0cd26
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Tasks.Actions.Math
{
using Opsive.BehaviorDesigner.Runtime.Tasks;
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Tooltip("Returns a random integer between the specified values (inclusive).")]
[Shared.Utility.Category("Math")]
public class RandomInteger : Action
{
[Tooltip("The minimum integer value (inclusive).")]
[SerializeField] protected SharedVariable<int> m_MinimumInteger;
[Tooltip("The maximum integer value (inclusive).")]
[SerializeField] protected SharedVariable<int> m_MaximumInteger;
[Tooltip("The stored random integer value.")]
[RequireShared] [SerializeField] protected SharedVariable<int> m_StoreResult;
[Tooltip("The seed of the random number generator. Set to 0 to disable.")]
[SerializeField] protected int m_Seed;
/// <summary>
/// Callback when the behavior tree is initialized.
/// </summary>
public override void OnAwake()
{
if (m_Seed != 0) {
Random.InitState(m_Seed);
}
}
/// <summary>
/// Executes the task logic.
/// </summary>
/// <returns>The status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = Random.Range(m_MinimumInteger.Value, m_MaximumInteger.Value);
return base.OnUpdate();
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf8b675bf82b06f44a19056eedc9e3f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Set the boolean value.")]
[Shared.Utility.Category("Math")]
public class SetBool : Action
{
[Tooltip("The bool value to set.")]
[SerializeField] protected SharedVariable<bool> m_Value;
[Tooltip("The variable that should be set.")]
[RequireShared] [SerializeField] protected SharedVariable<bool> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77b177a61d9c7c94889fe58326045014
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Set the float value.")]
[Shared.Utility.Category("Math")]
public class SetFloat : Action
{
[Tooltip("The float value to set.")]
[SerializeField] protected SharedVariable<float> m_Value;
[Tooltip("The variable that should be set.")]
[RequireShared] [SerializeField] protected SharedVariable<float> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7114039f3b7a3ff439a901637ba04235
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Set the integer value.")]
[Shared.Utility.Category("Math")]
public class SetInt : Action
{
[Tooltip("The int value to set.")]
[SerializeField] protected SharedVariable<int> m_Value;
[Tooltip("The variable that should be set.")]
[RequireShared] [SerializeField] protected SharedVariable<int> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eed961f4064f9024f8e51b3ddb69020a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Set the string value.")]
[Shared.Utility.Category("Math")]
public class SetString : Action
{
[Tooltip("The string value to set.")]
[SerializeField] protected SharedVariable<string> m_Value;
[Tooltip("The variable that should be set.")]
[RequireShared] [SerializeField] protected SharedVariable<string> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 450ec74688a332e42a42173708a621c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Set the Vector2 value.")]
[Shared.Utility.Category("Math")]
public class SetVector2 : Action
{
[Tooltip("The Vector2 value to set.")]
[SerializeField] protected SharedVariable<Vector2> m_Value;
[Tooltip("The variable that should be set.")]
[RequireShared] [SerializeField] protected SharedVariable<Vector2> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1507af45b59e2d642a8372f952ef5bec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Math
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[Opsive.Shared.Utility.Description("Set the Vector3 value.")]
[Shared.Utility.Category("Math")]
public class SetVector3 : Action
{
[Tooltip("The Vector3 value to set.")]
[SerializeField] protected SharedVariable<Vector3> m_Value;
[Tooltip("The variable that should be set.")]
[RequireShared] [SerializeField] protected SharedVariable<Vector3> m_StoreResult;
/// <summary>
/// Executes the task.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
m_StoreResult.Value = m_Value.Value;
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8fd35c62b935e674da0ed3b7d450a049
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,160 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.BehaviorDesigner.Runtime.Components;
using Opsive.BehaviorDesigner.Runtime.Utility;
using Opsive.GraphDesigner.Runtime;
using Unity.Entities;
using Unity.Burst;
using UnityEngine;
using Unity.Collections;
[NodeIcon("7c0aba0d8377aac48966d8e3f817a2a8", "90105f40f82a30e45b08d150c1928950")]
[Opsive.Shared.Utility.Description("Performs the actual interruption. This will immediately stop the specified tasks from running and will return success or failure depending on the value of interrupt success.")]
public class PerformInterruption : ECSActionTask<PerformInterruptionTaskSystem, PerformInterruptionComponent>
{
[Tooltip("The task that should be interrupted.")]
[SerializeField] ILogicNode[] m_InterruptTasks;
[Tooltip("Should the interrupted task return success?")]
[SerializeField] bool m_InterruptSuccess;
/// <summary>
/// The type of tag that should be enabled when the task is running.
/// </summary>
public override ComponentType Flag { get => typeof(PerformInterruptionFlag); }
/// <summary>
/// Returns a new TBufferElement for use by the system.
/// </summary>
/// <returns>A new TBufferElement for use by the system.</returns>
public override PerformInterruptionComponent GetBufferElement()
{
if (m_InterruptTasks == null || m_InterruptTasks.Length == 0) {
UnityEngine.Debug.LogError("Error: At least one interrupt task must be specified.");
return new PerformInterruptionComponent();
}
var indicies = new ushort[m_InterruptTasks.Length];
var nullTaskCount = 0;
for (int i = 0; i < m_InterruptTasks.Length; ++i) {
if (m_InterruptTasks[i] == null) {
nullTaskCount++;
continue;
}
indicies[i - nullTaskCount] = m_InterruptTasks[i].Index;
}
if (nullTaskCount > 0) {
System.Array.Resize(ref indicies, indicies.Length - nullTaskCount);
}
var builder = new BlobBuilder(Allocator.Temp);
ref var root = ref builder.ConstructRoot<IndiciesBlob>();
var indicesArray = builder.Allocate(ref root.Indicies, indicies.Length);
for (int i = 0; i < indicies.Length; i++) {
indicesArray[i] = indicies[i];
}
var blobAsset = builder.CreateBlobAssetReference<IndiciesBlob>(Allocator.Persistent);
builder.Dispose();
return new PerformInterruptionComponent() {
Index = RuntimeIndex,
InterruptIndicies = blobAsset,
InterruptSuccess = m_InterruptSuccess
};
}
/// <summary>
/// Adds the IBufferElementData to the entity.
/// </summary>
/// <param name="world">The world that the entity exists in.</param>
/// <param name="entity">The entity that the IBufferElementData should be assigned to.</param>
/// <param name="gameObject">The GameObject that the entity is attached to.</param>
/// <returns>The index of the element within the buffer.</returns>
public override int AddBufferElement(World world, Entity entity, GameObject gameObject)
{
var index = base.AddBufferElement(world, entity, gameObject);
ComponentUtility.AddInterruptComponents(world.EntityManager, entity);
return index;
}
}
/// <summary>
/// The DOTS data structure for the PerformInterruption class.
/// </summary>
public struct PerformInterruptionComponent : IBufferElementData
{
[Tooltip("The index of the node.")]
[SerializeField] public ushort Index;
[Tooltip("The indicies of the tasks that should be interrupted.")]
[SerializeField] public BlobAssetReference<IndiciesBlob> InterruptIndicies;
[Tooltip("Should the interrupted tasks return success?")]
[SerializeField] public bool InterruptSuccess;
}
/// <summary>
/// A DOTS flag indicating when a PerformInterruption node is active.
/// </summary>
public struct PerformInterruptionFlag : IComponentData, IEnableableComponent { }
/// <summary>
/// Runs the PerformInterruption logic.
/// </summary>
[DisableAutoCreation]
public partial struct PerformInterruptionTaskSystem : ISystem
{
/// <summary>
/// Updates the logic.
/// </summary>
/// <param name="state">The current state of the system.</param>
[BurstCompile]
private void OnUpdate(ref SystemState state)
{
foreach (var (branchComponents, taskComponents, performInterruptionComponents, entity) in
SystemAPI.Query<DynamicBuffer<BranchComponent>, DynamicBuffer<TaskComponent>, DynamicBuffer<PerformInterruptionComponent>>().WithAll<PerformInterruptionFlag, EvaluateFlag>().WithEntityAccess()) {
for (int i = 0; i < performInterruptionComponents.Length; ++i) {
var performInterruptionComponent = performInterruptionComponents[i];
var taskComponent = taskComponents[performInterruptionComponent.Index];
if (taskComponent.Status == TaskStatus.Queued) {
taskComponent.Status = TaskStatus.Success;
var taskComponentsBuffer = taskComponents;
taskComponentsBuffer[taskComponent.Index] = taskComponent;
var branchComponentsBuffer = branchComponents;
for (int j = 0; j < performInterruptionComponent.InterruptIndicies.Value.Indicies.Length; ++j) {
var interruptTaskComponent = taskComponents[performInterruptionComponent.InterruptIndicies.Value.Indicies[j]];
var interruptBranchComponent = branchComponents[interruptTaskComponent.BranchIndex];
interruptBranchComponent.InterruptType = performInterruptionComponent.InterruptSuccess ? InterruptType.ImmediateSuccess : InterruptType.ImmediateFailure;
interruptBranchComponent.InterruptIndex = interruptTaskComponent.Index;
branchComponentsBuffer[interruptTaskComponent.BranchIndex] = interruptBranchComponent;
}
state.EntityManager.SetComponentEnabled<InterruptFlag>(entity, true);
}
}
}
}
/// <summary>
/// The task has been destroyed.
/// </summary>
/// <param name="state">The current state of the system.</param>
private void OnDestroy(ref SystemState state)
{
foreach (var performInterruptionComponents in SystemAPI.Query<DynamicBuffer<PerformInterruptionComponent>>()) {
for (int i = 0; i < performInterruptionComponents.Length; ++i) {
var performInterruptionComponent = performInterruptionComponents[i];
if (performInterruptionComponent.InterruptIndicies.IsCreated) {
performInterruptionComponent.InterruptIndicies.Dispose();
}
}
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9407f1f7d7a4efc43928e2885fbd047d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,60 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using System.Collections;
using UnityEngine;
[NodeIcon("e0a8f1df788b6274a9a24003859dfa7e")]
[Opsive.Shared.Utility.Description("Restarts the specified behavior tree.")]
public class RestartBehaviorTree : TargetBehaviorTreeAction
{
private TaskStatus m_Status;
/// <summary>
/// The task has started.
/// </summary>
public override void OnStart()
{
m_Status = TaskStatus.Queued;
}
/// <summary>
/// Executes the task logic.
/// </summary>
/// <returns>The status of the task.</returns>
public override TaskStatus OnUpdate()
{
// The coroutine has already been started if the status is not queued.
if (m_Status != TaskStatus.Queued) {
return m_Status;
}
if (m_ResolvedBehaviorTree == null) {
return TaskStatus.Failure;
}
m_Status = TaskStatus.Running;
StartCoroutine(RestartBehavior());
return m_Status;
}
/// <summary>
/// Restarts the behavior tree using a coroutine to allow structural changes.
/// </summary>
private IEnumerator RestartBehavior()
{
yield return new WaitForEndOfFrame();
m_Status = m_ResolvedBehaviorTree.RestartBehavior() ? TaskStatus.Success : TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1240560819407764d95369a091d6f5e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,121 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.BehaviorDesigner.Runtime.Components;
using Opsive.GraphDesigner.Runtime;
using Unity.Entities;
using Unity.Burst;
using UnityEngine;
using System;
/// <summary>
/// A node representation of the return status task.
/// </summary>
[Opsive.Shared.Utility.Description("The return status task will immediately return sucess or failure.")]
public class ReturnStatus : ECSActionTask<ReturnStatusTaskSystem, ReturnStatusComponent>, ICloneable
{
[Tooltip("Should a success status be returned? If false then failure will be returned.")]
[SerializeField] bool m_Success;
public bool Success { get => m_Success; set => m_Success = value; }
/// <summary>
/// The type of tag that should be enabled when the task is running.
/// </summary>
public override ComponentType Flag { get => typeof(ReturnStatusFlag); }
/// <summary>
/// Returns a new TBufferElement for use by the system.
/// </summary>
/// <returns>A new TBufferElement for use by the system.</returns>
public override ReturnStatusComponent GetBufferElement()
{
return new ReturnStatusComponent() {
Index = RuntimeIndex,
Success = m_Success
};
}
/// <summary>
/// Creates a deep clone of the component.
/// </summary>
/// <returns>A deep clone of the component.</returns>
public object Clone()
{
var clone = Activator.CreateInstance<ReturnStatus>();
clone.Index = Index;
clone.ParentIndex = ParentIndex;
clone.SiblingIndex = SiblingIndex;
clone.Success = Success;
return clone;
}
}
/// <summary>
/// The DOTS data structure for the ReturnStatus class.
/// </summary>
public struct ReturnStatusComponent : IBufferElementData
{
[Tooltip("The index of the node.")]
[SerializeField] ushort m_Index;
[Tooltip("Should a success status be returned? If false then failure will be returned.")]
[SerializeField] bool m_Success;
public ushort Index { get => m_Index; set => m_Index = value; }
public bool Success { get => m_Success; set => m_Success = value; }
}
/// <summary>
/// A DOTS tag indicating when a ReturnStatus node is active.
/// </summary>
public struct ReturnStatusFlag : IComponentData, IEnableableComponent { }
/// <summary>
/// Runs the ReturnStatus logic.
/// </summary>
[DisableAutoCreation]
public partial struct ReturnStatusTaskSystem : ISystem
{
/// <summary>
/// Creates the job.
/// </summary>
/// <param name="state">The current state of the system.</param>
[BurstCompile]
private void OnUpdate(ref SystemState state)
{
var query = SystemAPI.QueryBuilder().WithAllRW<TaskComponent>().WithAllRW<ReturnStatusComponent>().WithAll<ReturnStatusFlag, EvaluateFlag>().Build();
state.Dependency = new ReturnStatusJob().ScheduleParallel(query, state.Dependency);
}
/// <summary>
/// Job which executes the task logic.
/// </summary>
[BurstCompile]
private partial struct ReturnStatusJob : IJobEntity
{
/// <summary>
/// Executes the return status logic.
/// </summary>
/// <param name="taskComponents">An array of TaskComponents.</param>
/// <param name="returnStatusComponents">An array of ReturnStatusComponents.</param>
[BurstCompile]
public void Execute(ref DynamicBuffer<TaskComponent> taskComponents, ref DynamicBuffer<ReturnStatusComponent> returnStatusComponents)
{
for (int i = 0; i < returnStatusComponents.Length; ++i) {
var returnStatusComponent = returnStatusComponents[i];
var taskComponent = taskComponents[returnStatusComponent.Index];
if (taskComponent.Status != TaskStatus.Queued) {
continue;
}
taskComponent.Status = returnStatusComponent.Success ? TaskStatus.Success : TaskStatus.Failure;
taskComponents[returnStatusComponent.Index] = taskComponent;
}
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 837791748c4f57c4293429e8e94fd32c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using Opsive.Shared.Events;
using UnityEngine;
/// <summary>
/// Executes the specified event.
/// </summary>
[NodeIcon("bde76446ddfbd234488e8d591bc75e2f", "6d03b96c0f79bee4ab2e14fc82aa0031")]
[Opsive.Shared.Utility.Description("Sends an event to the behavior tree, returns success after sending the event.")]
public class SendEvent : TargetBehaviorTreeAction
{
[Tooltip("The name of the event.")]
[SerializeField] protected SharedVariable<string> m_EventName;
[Tooltip("Is the event a global event?")]
[SerializeField] protected SharedVariable<bool> m_GlobalEvent;
[Tooltip("Optionally specify a first argument to send.")]
[RequireShared] [SerializeField] protected SharedVariable m_Argument1;
[Tooltip("Optionally specify a second argument to send.")]
[RequireShared] [SerializeField] protected SharedVariable m_Argument2;
[Tooltip("Optionally specify a third argument to send.")]
[RequireShared] [SerializeField] protected SharedVariable m_Argument3;
/// <summary>
/// Executes the event.
/// </summary>
/// <returns>The execution status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_ResolvedBehaviorTree == null) {
return TaskStatus.Failure;
}
if (string.IsNullOrEmpty(m_EventName.Value)) {
Debug.LogError("Error: Unable to send event. The event name is empty.");
return TaskStatus.Failure;
}
if (m_Argument1 == null || !m_Argument1.IsShared) {
if (m_GlobalEvent.Value) {
EventHandler.ExecuteEvent(m_EventName.Value);
} else {
EventHandler.ExecuteEvent(m_ResolvedBehaviorTree, m_EventName.Value);
}
} else {
if (m_Argument2 == null || !m_Argument2.IsShared) {
if (m_GlobalEvent.Value) {
EventHandler.ExecuteEvent(m_EventName.Value, m_Argument1.GetValue());
} else {
EventHandler.ExecuteEvent(m_ResolvedBehaviorTree, m_EventName.Value, m_Argument1.GetValue());
}
} else {
if (m_Argument3 == null || !m_Argument3.IsShared) {
if (m_GlobalEvent.Value) {
EventHandler.ExecuteEvent(m_EventName.Value, m_Argument1.GetValue(), m_Argument2.GetValue());
} else {
EventHandler.ExecuteEvent(m_ResolvedBehaviorTree, m_EventName.Value, m_Argument1.GetValue(), m_Argument2.GetValue());
}
} else {
if (m_GlobalEvent.Value) {
EventHandler.ExecuteEvent(m_EventName.Value, m_Argument1.GetValue(), m_Argument2.GetValue(), m_Argument3.GetValue());
} else {
EventHandler.ExecuteEvent(m_ResolvedBehaviorTree, m_EventName.Value, m_Argument1.GetValue(), m_Argument2.GetValue(), m_Argument3.GetValue());
}
}
}
}
return TaskStatus.Success;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6af31db67c14aba458ffd11cd0b671aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using System.Collections;
using UnityEngine;
[NodeIcon("e0a8f1df788b6274a9a24003859dfa7e")]
[Opsive.Shared.Utility.Description("Sets the specified subtree.")]
public class SetSubtree : TargetBehaviorTreeAction
{
[Tooltip("The subtree that should be set.")]
[SerializeField] protected Subtree m_Subtree;
[Tooltip("Should the behavior tree be started after the subtree is set?")]
[SerializeField] protected bool m_StartBehavior = true;
private TaskStatus m_Status;
/// <summary>
/// The task has started.
/// </summary>
public override void OnStart()
{
m_Status = TaskStatus.Queued;
}
/// <summary>
/// Executes the task logic.
/// </summary>
/// <returns>The status of the task.</returns>
public override TaskStatus OnUpdate()
{
// The coroutine has already been started if the status is not queued.
if (m_Status != TaskStatus.Queued) {
return m_Status;
}
if (m_ResolvedBehaviorTree == null) {
return TaskStatus.Failure;
}
m_Status = TaskStatus.Running;
StartCoroutine(DoSetSubtree());
return m_Status;
}
/// <summary>
/// Sets the subtree using a coroutine to allow structural changes.
/// </summary>
private IEnumerator DoSetSubtree()
{
yield return new WaitForEndOfFrame();
m_ResolvedBehaviorTree.Subgraph = m_Subtree;
m_Status = TaskStatus.Success;
if (m_StartBehavior) {
m_ResolvedBehaviorTree.StartBehavior();
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 881cf86206c0dfa458723d1cde9e0e13
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
/// <summary>
/// The StackedAction task allows for multiple actions to be added to the same node.
/// </summary>
[NodeIcon("dacf20a036b1f5e41886d84ac4a47779", "2df1cb3efc025214cbab4df573bb3515")]
[Opsive.Shared.Utility.Description("Allows multiple action tasks to be added to a single node.")]
public class StackedAction : StackedTask, IAction
{
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4342d213dec4aa5458c9e9969ef98fc7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using System.Collections;
using UnityEngine;
[NodeIcon("e0a8f1df788b6274a9a24003859dfa7e")]
[Opsive.Shared.Utility.Description("Starts the specified behavior tree.")]
public class StartBehaviorTree : TargetBehaviorTreeAction
{
private TaskStatus m_Status;
/// <summary>
/// The task has started.
/// </summary>
public override void OnStart()
{
m_Status = TaskStatus.Queued;
}
/// <summary>
/// Executes the task logic.
/// </summary>
/// <returns>The status of the task.</returns>
public override TaskStatus OnUpdate()
{
// The coroutine has already been started if the status is not queued.
if (m_Status != TaskStatus.Queued) {
return m_Status;
}
if (m_ResolvedBehaviorTree == null || m_ResolvedBehaviorTree.IsActive()) {
return TaskStatus.Failure;
}
m_Status = TaskStatus.Running;
StartCoroutine(StartBehavior());
return m_Status;
}
/// <summary>
/// Starts the behavior tree using a coroutine to allow structural changes.
/// </summary>
private IEnumerator StartBehavior()
{
yield return new WaitForEndOfFrame();
m_Status = m_ResolvedBehaviorTree.StartBehavior() ? TaskStatus.Success : TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a308f84e10d3f9b4e89c16ea755e4120
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
[NodeIcon("e0a8f1df788b6274a9a24003859dfa7e")]
[Opsive.Shared.Utility.Description("Stops the specified behavior tree.")]
public class StopBehaviorTree : TargetBehaviorTreeAction
{
[SerializeField] protected SharedVariable<bool> m_PauseBehaviorTree;
/// <summary>
/// Executes the task logic.
/// </summary>
/// <returns>The status of the task.</returns>
public override TaskStatus OnUpdate()
{
if (m_ResolvedBehaviorTree == null || !m_ResolvedBehaviorTree.IsActive()) {
return TaskStatus.Failure;
}
return m_ResolvedBehaviorTree.StopBehavior(m_PauseBehaviorTree.Value) ? TaskStatus.Success : TaskStatus.Failure;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ff712b458703ec440a858c41edeca111
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
/// <summary>
/// Allows for subtrees to be loaded at runtime into the tree.
/// </summary>
[NodeIcon("e0a8f1df788b6274a9a24003859dfa7e")]
[Opsive.Shared.Utility.Description("Loads the specified subtrees in at runtime.")]
public class SubtreeReference : ActionNode, ISubtreeReference
{
[Tooltip("The subtrees that should be loaded.")]
[SubtreeListAttribute]
[SerializeField] protected Subtree[] m_Subtrees;
[Tooltip("The variables that should override the subtree variables.")]
[SharedVariableOverridesListAttribute]
[SerializeField] protected SharedVariableOverride[] m_Variables;
public virtual Subtree[] Subtrees { get { return m_Subtrees; } }
/// <summary>
/// A list of mapped SharedVariables. These variables can override the subtree.
/// </summary>
public virtual SharedVariableOverride[] SharedVariableOverrides { get => m_Variables; set => m_Variables = value; }
/// <summary>
/// Performs any runtime operations to evaluate the array of subtrees that should be returned.
/// </summary>
/// <param name="graphComponent">The component that the node is attached to.</param>
public virtual void EvaluateSubtrees(IGraphComponent graphComponent) { }
/// <summary>
/// If the task exists at runtime then the subtree didn't load. Return failure.
/// </summary>
/// <returns>The failure TaskStatus.</returns>
public override TaskStatus OnUpdate()
{
return TaskStatus.Failure;
}
}
}
#endif

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