本文整理匯總了C#中behaviac.BehaviorNode.CheckPreconditions方法的典型用法代碼示例。如果您正苦於以下問題:C# BehaviorNode.CheckPreconditions方法的具體用法?C# BehaviorNode.CheckPreconditions怎麽用?C# BehaviorNode.CheckPreconditions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類behaviac.BehaviorNode
的用法示例。
在下文中一共展示了BehaviorNode.CheckPreconditions方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: decomposeNode
public PlannerTask decomposeNode(BehaviorNode node, int depth)
{
try
{
// Ensure that the planner does not get stuck in an infinite loop
if (depth >= 256)
{
Debug.LogError("Exceeded task nesting depth. Does the graph contain an invalid cycle?");
return null;
}
LogPlanNodeBegin(this.agent, node);
int depth1 = this.agent.Variables.Depth;
PlannerTask taskAdded = null;
bool isPreconditionOk = node.CheckPreconditions(this.agent, false);
if (isPreconditionOk)
{
bool bOk = true;
taskAdded = PlannerTask.Create(node, this.agent);
if (node is Action)
{
//nothing to do for action
Debug.Check(true);
}
else
{
Debug.Check(taskAdded is PlannerTaskComplex);
PlannerTaskComplex seqTask = taskAdded as PlannerTaskComplex;
bOk = this.decomposeComplex(node, seqTask, depth);
}
if (bOk)
{
node.ApplyEffects(this.agent, Effector.EPhase.E_SUCCESS);
}
else
{
BehaviorTask.DestroyTask(taskAdded);
taskAdded = null;
}
}
else
{
//precondition failed
LogPlanNodePreconditionFailed(this.agent, node);
}
LogPlanNodeEnd(this.agent, node, taskAdded != null ? "success" : "failure");
Debug.Check(this.agent.Variables.Depth == depth1);
return taskAdded;
}
catch (Exception ex)
{
Debug.Check(false, ex.Message);
}
return null;
}