Files
Cielonos/Packages/com.opsive.behaviordesigner/Runtime/Tasks/Actions/StopBehaviorTree.cs

34 lines
1.3 KiB
C#
Raw Normal View History

2025-11-25 08:19:33 -05:00
#if GRAPH_DESIGNER
/// ---------------------------------------------
/// Behavior Designer
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
2026-05-10 11:47:55 -04:00
namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.BehaviorTree
2025-11-25 08:19:33 -05:00
{
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
using UnityEngine;
2026-05-10 11:47:55 -04:00
using UnityEngine.Scripting.APIUpdating;
2025-11-25 08:19:33 -05:00
[NodeIcon("e0a8f1df788b6274a9a24003859dfa7e")]
[Opsive.Shared.Utility.Description("Stops the specified behavior tree.")]
2026-05-10 11:47:55 -04:00
[MovedFrom(false, "Opsive.BehaviorDesigner.Runtime.Tasks.Actions", "Opsive.BehaviorDesigner.Runtime", "StopBehaviorTree")]
2025-11-25 08:19:33 -05:00
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