bool CheckConditionFor(Blackboard blackboard, object item) { object old_val = null; if (blackboard.Contains(VariableName)) { old_val = blackboard.Get <object>(VariableName); } blackboard.Set(VariableName, item); bool can_run = Child.CheckCondition(blackboard); // Restore old blackboard value if (old_val != null) { blackboard.Set(VariableName, old_val); } return(can_run); }
protected override Status Update(Blackboard blackboard) { if (blackboard.Contains(Destination)) { return(Status.Success); } if (Func != null) { blackboard.Set(Destination, Func()); } else if (Value != null) { blackboard.Set(Destination, Value.GetValue(blackboard)); } else { blackboard.Set(Destination, FuncBlackboard(blackboard)); } return(Status.Success); }
public override bool CheckCondition(Blackboard blackboard) { int test_index = 0; while (true) { if (test_index >= currentList.Count) { return(false); } object old_val = null; if (blackboard.Contains("current")) { old_val = blackboard.Get <object>("current"); } blackboard.Set("current", currentList[test_index]); bool can_run = Child.CheckCondition(blackboard); if (!can_run) { test_index++; } // Restore old blackboard value if (old_val != null) { blackboard.Set("current", old_val); } if (can_run) { return(true); } } }
public bool IsSet(Blackboard bb) { return(bb.Contains(Name) && Get(bb) != null); }