protected override bool onenter(Agent pAgent) { Debug.Check(this.m_children.Count > 0); Debug.Check(this.m_activeChildIndex == CompositeTask.InvalidChildIndex); //SelectorProbability pSelectorProbabilityNode = this.GetNode() is SelectorProbability; this.m_weightingMap.Clear(); this.m_totalSum = 0; for (int i = 0; i < this.m_children.Count; ++i) { BehaviorTask task = this.m_children[i]; Debug.Check(task is DecoratorWeight.DecoratorWeightTask); DecoratorWeight.DecoratorWeightTask pWT = (DecoratorWeight.DecoratorWeightTask)task; int weight = pWT.GetWeight(pAgent); this.m_weightingMap.Add(weight); this.m_totalSum += weight; } Debug.Check(this.m_weightingMap.Count == this.m_children.Count); return(true); }
protected override bool onenter(Agent pAgent) { Debug.Check(this.m_children.Count > 0); //if the following assert failed, just comment it out //Debug.Check(this.m_activeChildIndex == CompositeTask.InvalidChildIndex); //to reset it anyway in case onexit is not called for some reason this.m_activeChildIndex = CompositeTask.InvalidChildIndex; //SelectorProbability pSelectorProbabilityNode = this.GetNode() is SelectorProbability; this.m_weightingMap.Clear(); this.m_totalSum = 0; for (int i = 0; i < this.m_children.Count; ++i) { BehaviorTask task = this.m_children[i]; Debug.Check(task is DecoratorWeight.DecoratorWeightTask); DecoratorWeight.DecoratorWeightTask pWT = (DecoratorWeight.DecoratorWeightTask)task; int weight = pWT.GetWeight(pAgent); this.m_weightingMap.Add(weight); this.m_totalSum += weight; } Debug.Check(this.m_weightingMap.Count == this.m_children.Count); return(true); }
protected override bool onenter(Agent pAgent) { this.m_weightingMap.Clear(); this.m_totalSum = 0; for (int i = 0; i < this.m_children.Count; i++) { BehaviorTask behaviorTask = this.m_children[i]; DecoratorWeight.DecoratorWeightTask decoratorWeightTask = (DecoratorWeight.DecoratorWeightTask)behaviorTask; int weight = decoratorWeightTask.GetWeight(pAgent); this.m_weightingMap.Add(weight); this.m_totalSum += weight; } return(true); }