mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
30 lines
709 B
C#
30 lines
709 B
C#
using System;
|
|
|
|
namespace BehaviorTreeSlayer
|
|
{
|
|
public class EventCaller : ConditionalNode
|
|
{
|
|
[OutField]
|
|
public string Event;
|
|
public override void Enter(object args)
|
|
{
|
|
BehaviorTree tree = (BehaviorTree)args;
|
|
if (!string.IsNullOrEmpty(Event))
|
|
tree.Regist(Event, OnEvent);
|
|
|
|
}
|
|
public override void Exit(object args)
|
|
{
|
|
|
|
}
|
|
private void OnEvent(object obj)
|
|
{
|
|
IsConditionOK = true;
|
|
}
|
|
public override TaskResult Tick(double dt, object args = null)
|
|
{
|
|
return IsConditionOK ? TaskResult.Running : TaskResult.None;
|
|
}
|
|
}
|
|
}
|