Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/BehaviorDesigner/Runtime/Tasks/HasExitedTrigger2D.cs
2026-02-21 16:45:37 +08:00

44 lines
1.0 KiB
C#

using UnityEngine;
namespace BehaviorDesigner.Runtime.Tasks
{
[HelpURLAttribute("http://www.opsive.com/assets/BehaviorDesigner/documentation.php?id=110")]
[TaskCategory("Physics")]
[TaskDescription("Returns success when an object exits the 2D trigger.")]
public class HasExitedTrigger2D : Conditional
{
[Tooltip("The tag of the GameObject to check for a trigger against")]
public SharedString tag = string.Empty;
[Tooltip("The object that exited the trigger")]
public SharedGameObject otherGameObject;
private bool exitedTrigger;
public override TaskStatus OnUpdate()
{
return (!exitedTrigger) ? TaskStatus.Failure : TaskStatus.Success;
}
public override void OnEnd()
{
exitedTrigger = false;
}
public override void OnTriggerExit2D(Collider2D other)
{
if (string.IsNullOrEmpty(tag.Value) || tag.Value.Equals(other.gameObject.tag))
{
otherGameObject.Value = other.gameObject;
exitedTrigger = true;
}
}
public override void OnReset()
{
tag = string.Empty;
otherGameObject = null;
}
}
}