本文整理汇总了C#中behaviac.BehaviorNode类的典型用法代码示例。如果您正苦于以下问题:C# BehaviorNode类的具体用法?C# BehaviorNode怎么用?C# BehaviorNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BehaviorNode类属于behaviac命名空间,在下文中一共展示了BehaviorNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: decompose
public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
{
Sequence sequence = (Sequence)node;
bool bOk = false;
int childCount = sequence.GetChildrenCount();
int i = 0;
for (; i < childCount; ++i)
{
BehaviorNode childNode = sequence.GetChild(i);
PlannerTask childTask = planner.decomposeNode(childNode, depth);
if (childTask == null)
{
break;
}
//clear the log cache so that the next node can log all properites
LogManager.Instance.PLanningClearCache();
seqTask.AddChild(childTask);
}
if (i == childCount)
{
bOk = true;
}
return bOk;
}
示例2: decompose
public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
{
Parallel parallel = (Parallel)node;
bool bOk = false;
//parallel currently is the same with sequence
int childCount = parallel.GetChildrenCount();
int i = 0;
for (; i < childCount; ++i)
{
BehaviorNode childNode = parallel.GetChild(i);
PlannerTask childTask = planner.decomposeNode(childNode, depth);
if (childTask == null)
{
break;
}
seqTask.AddChild(childTask);
}
if (i == childCount)
{
bOk = true;
}
return bOk;
}
示例3: decompose
public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
{
ReferencedBehavior taskSubTree = (ReferencedBehavior)node;
bool bOk = false;
Debug.Check(taskSubTree != null);
int depth2 = planner.GetAgent().Variables.Depth;
using(AgentState currentState = planner.GetAgent().Variables.Push(false))
{
//planner.agent.Variables.Log(planner.agent, true);
taskSubTree.SetTaskParams(planner.GetAgent());
Task task = taskSubTree.RootTaskNode;
if (task != null)
{
planner.LogPlanReferenceTreeEnter(planner.GetAgent(), taskSubTree);
task.Parent.InstantiatePars(planner.GetAgent());
PlannerTask childTask = planner.decomposeNode(task, depth);
if (childTask != null)
{
seqTask.AddChild(childTask);
bOk = true;
}
task.Parent.UnInstantiatePars(planner.GetAgent());
planner.LogPlanReferenceTreeExit(planner.GetAgent(), taskSubTree);
Debug.Check(true);
}
}
Debug.Check(planner.GetAgent().Variables.Depth == depth2);
return bOk;
}
示例4: UpdateTransitions
public static bool UpdateTransitions(Agent pAgent, BehaviorNode node, List<Transition> transitions, ref int nextStateId, EBTStatus result)
{
bool bTransitioned = false;
if (transitions != null)
{
for (int i = 0; i < transitions.Count; ++i)
{
Transition transition = transitions[i];
if (transition.Evaluate(pAgent))
{
nextStateId = transition.TargetStateId;
Debug.Check(nextStateId != -1);
//transition actions
transition.ApplyEffects(pAgent, Effector.EPhase.E_BOTH);
#if !BEHAVIAC_RELEASE
if (Config.IsLoggingOrSocketing)
{
BehaviorTask.CHECK_BREAKPOINT(pAgent, node, "transition", EActionResult.EAR_none);
}
#endif
bTransitioned = true;
break;
}
}
}
return bTransitioned;
}
示例5: Init
public virtual void Init(BehaviorNode node)
{
Debug.Check(node != null);
this.m_node = node;
this.m_id = this.m_node.GetId();
}
示例6: AddChild
public override void AddChild(BehaviorNode pBehavior)
{
Debug.Check(pBehavior is DecoratorWeight);
DecoratorWeight pDW = (DecoratorWeight)(pBehavior);
if (pDW != null)
{
base.AddChild(pBehavior);
}
else
{
Debug.Check(false, "only DecoratorWeightTask can be children");
}
}
示例7: decompose
/// <summary>
/// implement the decompose
/// </summary>
/// <param name="task"></param>
/// <param name="seqTask"></param>
/// <param name="depth"></param>
/// <param name="planner"></param>
/// <returns></returns>
public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
{
bool bOk = false;
Task task = (Task)node;
PlannerTask childTask = planner.decomposeTask((Task)task, depth);
if (childTask != null)
{
seqTask.AddChild(childTask);
bOk = true;
}
return bOk;
}
示例8: decompose
public override bool decompose(BehaviorNode branch, PlannerTaskComplex seqTask, int depth, Planner planner)
{
bool bOk = false;
int childCount = branch.GetChildrenCount();
Debug.Check(childCount == 1);
BehaviorNode childNode = branch.GetChild(0);
PlannerTask childTask = planner.decomposeNode(childNode, depth);
if (childTask != null)
{
seqTask.AddChild(childTask);
bOk = true;
}
return bOk;
}
示例9: decompose
public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
{
ReferencedBehavior taskSubTree = (ReferencedBehavior)node;
bool bOk = false;
Debug.Check(taskSubTree != null);
int depth2 = planner.GetAgent().Variables.Depth;
using(AgentState currentState = planner.GetAgent().Variables.Push(false))
{
Agent pAgent = planner.GetAgent();
string szTreePath = taskSubTree.GetReferencedTree(pAgent);
BehaviorTreeTask subTreeTask = Workspace.Instance.CreateBehaviorTreeTask(szTreePath);
taskSubTree.SetTaskParams(pAgent, subTreeTask);
Task task = taskSubTree.RootTaskNode(planner.GetAgent());
if (task != null)
{
planner.LogPlanReferenceTreeEnter(planner.GetAgent(), taskSubTree);
//task.Parent.InstantiatePars(this.LocalVars);
BehaviorTreeTask oldCurrentTreeTask = pAgent.ExcutingTreeTask;
pAgent.ExcutingTreeTask = subTreeTask;
PlannerTask childTask = planner.decomposeNode(task, depth);
pAgent.ExcutingTreeTask = oldCurrentTreeTask;
if (childTask != null)
{
//taskSubTree.SetTaskParams(planner.GetAgent(), childTask);
PlannerTaskReference subTreeRef = (PlannerTaskReference)seqTask;
subTreeRef.SubTreeTask = subTreeTask;
seqTask.AddChild(childTask);
bOk = true;
}
//task.Parent.UnInstantiatePars(this.LocalVars);
planner.LogPlanReferenceTreeExit(planner.GetAgent(), taskSubTree);
Debug.Check(true);
}
}
Debug.Check(planner.GetAgent().Variables.Depth == depth2);
return bOk;
}
示例10: decompose
public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
{
DecoratorIterator pForEach = (DecoratorIterator)node;
bool bOk = false;
int childCount = pForEach.GetChildrenCount();
Debug.Check(childCount == 1);
BehaviorNode childNode = pForEach.GetChild(0);
bool bGoOn = true;
int count = 0;
int index = 0;
while (bGoOn)
{
int depth2 = planner.GetAgent().Variables.Depth;
using(AgentState currentState = planner.GetAgent().Variables.Push(false))
{
bGoOn = pForEach.IterateIt(planner.GetAgent(), index, ref count);
if (bGoOn)
{
planner.LogPlanForEachBegin(planner.GetAgent(), pForEach, index, count);
PlannerTask childTask = planner.decomposeNode(childNode, depth);
planner.LogPlanForEachEnd(planner.GetAgent(), pForEach, index, count, childTask != null ? "success" : "failure");
if (childTask != null)
{
Debug.Check(seqTask is PlannerTaskIterator);
PlannerTaskIterator pForEachTask = seqTask as PlannerTaskIterator;
pForEachTask.Index = index;
seqTask.AddChild(childTask);
bOk = true;
break;
}
index++;
}
}
Debug.Check(planner.GetAgent().Variables.Depth == depth2);
}
return bOk;
}
示例11: Attach
public override void Attach(BehaviorNode pAttachment, bool bIsPrecondition, bool bIsEffector, bool bIsTransition)
{
if (bIsTransition)
{
Debug.Check(!bIsEffector && !bIsPrecondition);
if (this.m_transitions == null)
{
this.m_transitions = new List<Transition>();
}
Transition pTransition = pAttachment as Transition;
Debug.Check(pTransition != null);
this.m_transitions.Add(pTransition);
return;
}
Debug.Check(bIsTransition == false);
base.Attach(pAttachment, bIsPrecondition, bIsEffector, bIsTransition);
}
示例12: decompose
public override bool decompose(BehaviorNode node, PlannerTaskComplex seqTask, int depth, Planner planner)
{
Selector sel = (Selector)node;
bool bOk = false;
int childCount = sel.GetChildrenCount();
int i = 0;
for (; i < childCount; ++i)
{
BehaviorNode childNode = sel.GetChild(i);
PlannerTask childTask = planner.decomposeNode(childNode, depth);
if (childTask != null)
{
seqTask.AddChild(childTask);
bOk = true;
break;
}
}
return bOk;
}
示例13: GetParentTreeName
private static string GetParentTreeName(BehaviorNode n)
{
string btName = null;
if (n is ReferencedBehavior)
{
n = n.Parent;
}
bool bIsTree = false;
bool bIsRefTree = false;
while (n != null)
{
bIsTree = (n is BehaviorTree);
bIsRefTree = (n is ReferencedBehavior);
if (bIsTree || bIsRefTree)
{
break;
}
n = n.Parent;
}
if (bIsTree)
{
BehaviorTree bt = n as BehaviorTree;
btName = bt.GetName();
}
else if (bIsRefTree)
{
ReferencedBehavior refTree = n as ReferencedBehavior;
btName = refTree.ReferencedTree;
}
else
{
Debug.Check(false);
}
return btName;
}
示例14: GetTickInfo
public static string GetTickInfo(Agent pAgent, BehaviorNode n, string action)
{
#if !BEHAVIAC_RELEASE
if (Config.IsLoggingOrSocketing)
{
if (pAgent != null && pAgent.IsMasked())
{
//BEHAVIAC_PROFILE("GetTickInfo", true);
string bClassName = n.GetClassNameString();
//filter out intermediate bt, whose class name is empty
if (!string.IsNullOrEmpty(bClassName))
{
string btName = GetParentTreeName(n);
string bpstr = "";
if (!string.IsNullOrEmpty(btName))
{
bpstr = string.Format("{0}.xml->", btName);
}
int nodeId = n.GetId();
bpstr += string.Format("{0}[{1}]", bClassName, nodeId);
if (!string.IsNullOrEmpty(action))
{
bpstr += string.Format(":{0}", action);
}
return bpstr;
}
}
}
#endif
return string.Empty;
}
示例15: Init
//~DecoratorTask()
//{
//}
public override void Init(BehaviorNode node)
{
base.Init(node);
//DecoratorNode pDN = node as DecoratorNode;
}