public override BehaviorResult Exec(IBehaviorTree tree) { if (TargetNode == null) { //Debug.LogError("missing target node"); return(BehaviorResult.failed); } if (!Running) { if (OnPrecondition != null) { if (!OnPrecondition()) { return(BehaviorResult.failed); } } SetStarting(); } if (N == 0.0f) { N = tree.GameTime; } BehaviorResult result = TargetNode.Exec(tree); if (result == BehaviorResult.success) { SetCompleted(); N = 0.0f; return(BehaviorResult.success); } else if (result == BehaviorResult.failed) { SetFailed(); return(BehaviorResult.failed); } else if (result == BehaviorResult.running) { if (tree.GameTime - N < Interval) { return(BehaviorResult.running); } else { TargetNode.Abort(); N = 0.0f; return(BehaviorResult.failed); } } else { return(BehaviorResult.abort); } }