public static void SelectChoice_PrologKBChanges(object sender, SelectChoiceEventArgs eventArgs) { Unit selectedChoice = eventArgs.SelectedChoice; var prologKBQuery = from unit in eventArgs.Blackboard.LookupUnits <Unit>() where unit.HasComponent <KC_PrologKB>() select unit; // Currently only support one global KB. Debug.Assert(prologKBQuery.Count() == 1); KC_PrologKB prologKB = prologKBQuery.First().GetComponent <KC_PrologKB>(); // If there are any facts to retract, retract them if (selectedChoice.HasComponent <KC_PrologFactDeleteList>()) { selectedChoice.GetComponent <KC_PrologFactDeleteList>().DeleteFacts(prologKB); } // If there are any facts to add, add them if (selectedChoice.HasComponent <KC_PrologFactAddList>()) { selectedChoice.GetComponent <KC_PrologFactAddList>().AddFacts(prologKB); } }
/* * Given an array of choices and a 0-indexed choice selection, adds the appropriate query to the blackboard. */ public void SelectChoice(ContentUnit[] choices, uint choiceMade) { if (choiceMade < choices.Length) { // Add a U_IDQuery to blackboard for the target content unit associated with the choice. ContentUnit selectedChoice = choices[choiceMade]; m_blackboard.AddUnit(new U_IDSelectRequest((string)selectedChoice.Metadata[TargetContentUnitID])); SelectChoiceEventArgs eventArgs = new SelectChoiceEventArgs(selectedChoice, m_blackboard); OnSelectChoice(eventArgs); } else { throw new ArgumentOutOfRangeException(nameof(choiceMade), choiceMade, $"choiceMade must be between 0 and the number of choices - 1 {choices.Length - 1}"); } }
/* * Given an array of choices and a 0-indexed choice selection, activates the KC_IDSelectionRequest on the selected choice and * call any actions registered on PresenterSelectChoice. */ public void SelectChoice(Unit[] choices, uint choiceMade) { if (choiceMade < choices.Length) { // Activate the KC_IDSelectionRequest associated with the choice. Unit selectedChoice = choices[choiceMade]; selectedChoice.SetActiveRequest(true); // Do any actions that have been registered on PresenterSelectChoice. SelectChoiceEventArgs eventArgs = new SelectChoiceEventArgs(selectedChoice, m_blackboard); OnSelectChoice(eventArgs); } else { throw new ArgumentOutOfRangeException(nameof(choiceMade), choiceMade, $"choiceMade must be between 0 and the number of choices - 1 {choices.Length - 1}"); } }
protected virtual void OnSelectChoice(SelectChoiceEventArgs eventArgs) { PresenterSelectChoice?.Invoke(this, eventArgs); }