本文整理汇总了C#中EBTStatus类的典型用法代码示例。如果您正苦于以下问题:C# EBTStatus类的具体用法?C# EBTStatus怎么用?C# EBTStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EBTStatus类属于命名空间,在下文中一共展示了EBTStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: update
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
{
EBTStatus s = childStatus;
Debug.Check(this.m_activeChildIndex < this.m_children.Count);
// Keep going until a child behavior says its running.
for (; ;)
{
if (s == EBTStatus.BT_RUNNING)
{
int childIndex = this.m_set[this.m_activeChildIndex];
BehaviorTask pBehavior = this.m_children[childIndex];
s = pBehavior.exec(pAgent);
}
// If the child succeeds, or keeps running, do the same.
if (s != EBTStatus.BT_FAILURE)
{
return s;
}
// Hit the end of the array, job done!
++this.m_activeChildIndex;
if (this.m_activeChildIndex >= this.m_children.Count)
{
return EBTStatus.BT_FAILURE;
}
s = EBTStatus.BT_RUNNING;
}
}
示例3: decorate
protected override EBTStatus decorate(EBTStatus status)
{
if (this.m_n > 0)
{
this.m_n--;
}
if (this.m_n == 0)
{
return EBTStatus.BT_SUCCESS;
}
Debug.Check(this.GetNode() is DecoratorLoopUntil);
DecoratorLoopUntil pDecoratorLoopUntil = (DecoratorLoopUntil)(this.GetNode());
if (pDecoratorLoopUntil.m_until)
{
if (status == EBTStatus.BT_SUCCESS)
{
return EBTStatus.BT_SUCCESS;
}
}
else
{
if (status == EBTStatus.BT_FAILURE)
{
return EBTStatus.BT_FAILURE;
}
}
return EBTStatus.BT_RUNNING;
}
示例4: decorate
protected override EBTStatus decorate(EBTStatus status)
{
Debug.Check(this.GetNode() is DecoratorLog);
DecoratorLog pDecoratorLogNode = (DecoratorLog)(this.GetNode());
behaviac.Debug.LogWarning(string.Format("DecoratorLogTask:{0}\n", pDecoratorLogNode.m_message));
return status;
}
示例5: getResultOptionStr
private string getResultOptionStr(EBTStatus status)
{
switch (status)
{
case EBTStatus.BT_SUCCESS: return "EBTStatus.BT_SUCCESS";
case EBTStatus.BT_FAILURE: return "EBTStatus.BT_FAILURE";
case EBTStatus.BT_RUNNING: return "EBTStatus.BT_RUNNING";
}
return "EBTStatus.BT_INVALID";
}
示例6: decorate
protected override EBTStatus decorate(EBTStatus status)
{
if (status == EBTStatus.BT_FAILURE)
{
return EBTStatus.BT_SUCCESS;
}
if (status == EBTStatus.BT_SUCCESS)
{
return EBTStatus.BT_FAILURE;
}
return status;
}
示例7: update
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
{
//Debug.Check(this.m_children.Count == 2);
for(int i = 0; i < this.m_children.Count; ++i)
{
BehaviorTask pBehavior = this.m_children[i];
EBTStatus s = pBehavior.exec(pAgent);
// If the child succeeds, succeeds
if (s == EBTStatus.BT_SUCCESS)
{
return s;
}
Debug.Check(s == EBTStatus.BT_FAILURE);
}
return EBTStatus.BT_FAILURE;
}
示例8: load
protected override void load(int version, string agentType, List<property_t> properties)
{
base.load(version, agentType, properties);
for (int i = 0; i < properties.Count; ++i)
{
property_t p = properties[i];
if (p.name == "Method")
{
if (!string.IsNullOrEmpty(p.value))
{
this.m_method = AgentMeta.ParseMethod(p.value);
}
}
else if (p.name == "ResultOption")
{
if (p.value == "BT_INVALID")
{
m_resultOption = EBTStatus.BT_INVALID;
}
else if (p.value == "BT_FAILURE")
{
m_resultOption = EBTStatus.BT_FAILURE;
}
else if (p.value == "BT_RUNNING")
{
m_resultOption = EBTStatus.BT_RUNNING;
}
else
{
m_resultOption = EBTStatus.BT_SUCCESS;
}
}
else if (p.name == "ResultFunctor")
{
if (p.value[0] != '\0')
{
this.m_resultFunctor = AgentMeta.ParseMethod(p.value); ;
}
}
}
}
示例9: update
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
{
bool bFirst = true;
Debug.Check(this.m_activeChildIndex < this.m_children.Count);
// Keep going until a child behavior says its running.
for (; ; )
{
EBTStatus s = childStatus;
if (!bFirst || s == EBTStatus.BT_RUNNING)
{
Debug.Check(this.m_status == EBTStatus.BT_INVALID ||
this.m_status == EBTStatus.BT_RUNNING);
BehaviorTask pBehavior = this.m_children[this.m_activeChildIndex];
s = pBehavior.exec(pAgent);
}
bFirst = false;
// If the child succeeds, or keeps running, do the same.
if (s != EBTStatus.BT_FAILURE)
{
return s;
}
// Hit the end of the array, job done!
++this.m_activeChildIndex;
if (this.m_activeChildIndex >= this.m_children.Count)
{
return EBTStatus.BT_FAILURE;
}
if (!this.CheckPredicates(pAgent))
{
return EBTStatus.BT_FAILURE;
}
}
}
示例10: decorate
protected override EBTStatus decorate(EBTStatus status)
{
if (this.m_n > 0)
{
this.m_n--;
if (this.m_n == 0)
{
return EBTStatus.BT_SUCCESS;
}
return EBTStatus.BT_FAILURE;
}
if (this.m_n == -1)
{
return EBTStatus.BT_FAILURE;
}
Debug.Check(this.m_n == 0);
return EBTStatus.BT_SUCCESS;
}
示例11: Execute
public EBTStatus Execute(Agent pAgent, EBTStatus childStatus)
{
EBTStatus result = EBTStatus.BT_SUCCESS;
if (this.m_method != null)
{
if (this.m_resultOption != EBTStatus.BT_INVALID)
{
this.m_method.Run(pAgent);
result = this.m_resultOption;
}
else
{
if (this.m_resultFunctor != null)
{
IValue returnValue = this.m_resultFunctor.GetIValue(pAgent, this.m_method);
result = ((TValue<EBTStatus>)returnValue).value;
}
else
{
IValue returnValue = this.m_method.GetIValue(pAgent);
Debug.Check(returnValue is TValue<EBTStatus>, "method's return type is not EBTStatus");
result = ((TValue<EBTStatus>)returnValue).value;
}
}
}
else
{
result = this.update_impl(pAgent, childStatus);
}
return result;
}
示例12: SelectorUpdate
public EBTStatus SelectorUpdate(Agent pAgent, EBTStatus childStatus, ref int activeChildIndex, List<BehaviorTask> children)
{
EBTStatus s = childStatus;
for (; ;)
{
Debug.Check(activeChildIndex < children.Count);
if (s == EBTStatus.BT_RUNNING)
{
BehaviorTask pBehavior = children[activeChildIndex];
if (this.CheckIfInterrupted(pAgent))
{
return EBTStatus.BT_FAILURE;
}
s = pBehavior.exec(pAgent);
}
// If the child fails, or keeps running, do the same.
if (s != EBTStatus.BT_FAILURE)
{
return s;
}
// Hit the end of the array, job done!
++activeChildIndex;
if (activeChildIndex >= children.Count)
{
return EBTStatus.BT_FAILURE;
}
s = EBTStatus.BT_RUNNING;
}
}
示例13: exec
public EBTStatus exec(Agent pAgent, EBTStatus childStatus)
{
#if !BEHAVIAC_RELEASE
Debug.Check(this.m_node == null || this.m_node.IsValid(pAgent, this),
string.Format("Agent In BT:{0} while the Agent used for: {1}", this.m_node.GetAgentType(), pAgent.GetClassTypeName()));
#endif//#if !BEHAVIAC_RELEASE
bool bEnterResult = false;
if (this.m_status == EBTStatus.BT_RUNNING)
{
bEnterResult = true;
}
else
{
//reset it to invalid when it was success/failure
this.m_status = EBTStatus.BT_INVALID;
bEnterResult = this.onenter_action(pAgent);
}
if (bEnterResult)
{
#if !BEHAVIAC_RELEASE
if (Config.IsLoggingOrSocketing)
{
string btStr = BehaviorTask.GetTickInfo(pAgent, this, "update");
//empty btStr is for internal BehaviorTreeTask
if (!string.IsNullOrEmpty(btStr))
{
LogManager.Instance.Log(pAgent, btStr, EActionResult.EAR_none, LogMode.ELM_tick);
}
}
#endif
bool bValid = this.CheckParentUpdatePreconditions(pAgent);
if (bValid)
{
this.m_status = this.update_current(pAgent, childStatus);
}
else
{
this.m_status = EBTStatus.BT_FAILURE;
if (this.GetCurrentTask() != null)
{
this.update_current(pAgent, EBTStatus.BT_FAILURE);
}
}
if (this.m_status != EBTStatus.BT_RUNNING)
{
//clear it
this.onexit_action(pAgent, this.m_status);
//this node is possibly ticked by its parent or by the topBranch who records it as currrent node
//so, we can't here reset the topBranch's current node
}
else
{
BranchTask tree = this.GetTopManageBranchTask();
if (tree != null)
{
tree.SetCurrentTask(this);
}
}
}
else
{
this.m_status = EBTStatus.BT_FAILURE;
}
return this.m_status;
}
示例14: update_current
protected override EBTStatus update_current(Agent pAgent, EBTStatus childStatus)
{
Debug.Check(this.m_node != null);
Debug.Check(this.m_node is BehaviorTree);
BehaviorTree tree = (BehaviorTree)this.m_node;
EBTStatus status = EBTStatus.BT_RUNNING;
if (tree.IsFSM)
{
status = this.update(pAgent, childStatus);
}
else
{
status = base.update_current(pAgent, childStatus);
}
return status;
}
示例15: update
protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
{
Debug.Check(this.m_node != null);
Debug.Check(this.m_root != null);
if (childStatus != EBTStatus.BT_RUNNING)
{
return childStatus;
}
EBTStatus status = EBTStatus.BT_INVALID;
status = base.update(pAgent, childStatus);
Debug.Check(status != EBTStatus.BT_INVALID);
return status;
}