/// <summary> /// Depending on the group policy of its parent, the floating point return value indicates whether the decider will be activated. /// </summary> /// <param name="agentData"> Agent data. </param> /// <param name="decisionData"> Decision data to use in activate method. </param> /// <returns> Floating point value used to decide if the decider will be activated. </returns> public override float Decide(IAgentData agentData, ref IDecisionData decisionData) { // Create blackboard. Blackboard blackboard = new Blackboard(); // Add parent blackboards. if (this.Blackboard != null) { blackboard.Parents.Add(this.Blackboard); } blackboard.Parents.Add(agentData.Blackboard); // Setup blackboard. Blackboard previousBlackboard = agentData.Blackboard; agentData.Blackboard = blackboard; // Deactivate child. IDecisionData childDecisionData = null; float decisionValue = this.DecideChild(agentData, ref childDecisionData); // Tear down. agentData.Blackboard = previousBlackboard; // Create decision data. if (decisionValue > 0.0f) { decisionData = new DecisionData { Blackboard = blackboard, ChildDecisionData = childDecisionData }; } return decisionValue; }
/// <summary> /// The equals. /// </summary> /// <param name="other"> The other. </param> /// <returns> The System.Boolean. </returns> public bool Equals(Blackboard other) { if (ReferenceEquals(null, other)) { return false; } if (ReferenceEquals(this, other)) { return true; } return base.Equals(other) && CollectionUtils.SequenceEqual(other.Parents, this.Parents); }
/// <summary> /// Initializes a new instance of the <see cref="Blackboard" /> class. Constructor. /// </summary> /// <param name="original"> Blackboard to copy attributes from. </param> public Blackboard(Blackboard original) : base(original) { this.Parents = new List<Blackboard>(original.Parents); }