public List <Trait> getPreviouslyBoundPrimitiveVariables(TraitDataType variableType, bool allTypes, Action currentAction) { //Get bound variable names in parameters and preconditions by passing //a non-existent PreconditionStatement reference (null) to the other variable //name collection function PreconditionStatement nullPrecStatement = null; List <Trait> varsToReturn = getPreviouslyBoundPrimitiveVariables(variableType, allTypes, nullPrecStatement); foreach (Action action in _actions) { if (action == currentAction) { //We have found where to stop looking, can now return variable list return(varsToReturn); } else { //Add the variable names bound in this statement to the running list varsToReturn.AddRange(action.getBoundPrimitiveVariables(variableType, allTypes)); } } return(varsToReturn); }
public List <string> getAllPreviouslyBoundVariableNames(Action currentAction, bool includeAuthorGoalParameters) { PreconditionStatement nullPrecStatement = null; List <string> varsToReturn = getAllPreviouslyBoundVariableNames(nullPrecStatement, includeAuthorGoalParameters); foreach (Action actItem in _actions) { //We have found where to stop looking, can now return variable list if (actItem == currentAction) { return(varsToReturn); } else if (actItem is ActionCreateObject) { varsToReturn.Add(((ActionCreateObject)actItem).VariableName); } else if (actItem is ActionCalculation) { varsToReturn.Add(((ActionCalculation)actItem).ResultVarName); } } return(varsToReturn); }
public WindowPreconditionEditor(PlotFragment frag, PreconditionStatement currEntity, StoryData currStoryData) { InitializeComponent(); _currentStoryData = currStoryData; _currentEntity = currEntity; _parentPlotFragment = frag; _currentlySelectedConstraint = null; _currentlyDataBinding = false; //Find editing type if (currEntity is PreconditionStatementCharacter) { _editingMode = 0; } else if (currEntity is PreconditionStatementEnvironment) { _editingMode = 1; } else { PlotPointType currType = currStoryData.findPlotPointTypeById(((PreconditionStatementPlotPoint)currEntity).MatchTypeId); _editingMode = 2; _ppType = currType; } txtBoxNumberInput.NullValue = 0.0; dataBind(); }
public List <string> getAllPreviouslyBoundVariableNames(PreconditionStatement currentPrecStatement, bool includeAuthorGoalParameters) { List <string> varsToReturn = new List <string>(); if (includeAuthorGoalParameters) { AuthorGoal parentGoal = StoryWorldDataProvider.findAuthorGoalById(_parentAuthorGoalId); // Add parameter variable names foreach (Parameter param in parentGoal.Parameters) { varsToReturn.Add(param.Name); } } foreach (PreconditionStatement precondStmt in _precStatements) { if (precondStmt == currentPrecStatement) { //We have found where to stop looking, can now return variable list return(varsToReturn); } else { //Add the variable names bound in this statement to the running list varsToReturn.AddRange(precondStmt.getAllBoundVariableNames()); } } return(varsToReturn); }
private void btDeletePrecond_Click(object sender, RoutedEventArgs e) { Object itemToEdit = precondDataGrid.SelectedItem; if ((itemToEdit == null) || !(itemToEdit is PreconditionStatement)) { return; } PreconditionStatement itemToDelete = (PreconditionStatement)itemToEdit; if (Utilities.MakeYesNoWarningDialog("Are you sure you want to delete this Precondition Statement?", "Confirm Deletion", this) == MessageBoxResult.No) { return; } _currentEntity.PrecStatements.Remove(itemToDelete); clearDataBindings(); dataBind(); }
virtual public Object Clone() { //TODO: make cloning work properly for duplication of entire plot fragments and author goals //- add a new clone method or something to //stop the creation of new unique names/variable names PreconditionStatement newClone = (PreconditionStatement)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.Constraints = new List <Constraint>(); foreach (Constraint cons in _constraints) { newClone.Constraints.Add((Constraint)cons.Clone()); } //If name is not unique, keep increment suffix number until it is string newName = newClone.SaveObjectVariableName; int cloneCount = 1; PlotFragment parentFrag = StoryWorldDataProvider.getStoryData().findPlotFragmentById(_parentPlotFragmentId); Action nullAction = null; List <string> prevVars = parentFrag.getAllPreviouslyBoundVariableNames(nullAction, true); while (prevVars.Contains(newName)) { newName = newClone.SaveObjectVariableName + cloneCount.ToString(); cloneCount++; } newClone.SaveObjectVariableName = newName; return(newClone); }
public List <Trait> getPreviouslyBoundPrimitiveVariables(TraitDataType variableType, bool allTypes, PreconditionStatement currentPrecStatement) { List <Trait> varsToReturn = new List <Trait>(); AuthorGoal parentGoal = StoryWorldDataProvider.findAuthorGoalById(_parentAuthorGoalId); // Add parameter variable names foreach (Parameter param in parentGoal.Parameters) { if (allTypes || (param.Type == variableType)) { varsToReturn.Add(param); } } foreach (PreconditionStatement precondStmt in _precStatements) { if (precondStmt == currentPrecStatement) { //We have found where to stop looking, can now return variable list return(varsToReturn); } else { //Add the variable names bound in this statement to the running list varsToReturn.AddRange(precondStmt.getBoundPrimitiveVariables(variableType, allTypes)); } } return(varsToReturn); }
public List<Trait> getPreviouslyBoundPrimitiveVariables(TraitDataType variableType, bool allTypes, PreconditionStatement currentPrecStatement) { List<Trait> varsToReturn = new List<Trait>(); AuthorGoal parentGoal = StoryWorldDataProvider.findAuthorGoalById(_parentAuthorGoalId); // Add parameter variable names foreach (Parameter param in parentGoal.Parameters) { if(allTypes || (param.Type == variableType)) { varsToReturn.Add(param); } } foreach (PreconditionStatement precondStmt in _precStatements) { if(precondStmt == currentPrecStatement) { //We have found where to stop looking, can now return variable list return varsToReturn; } else { //Add the variable names bound in this statement to the running list varsToReturn.AddRange(precondStmt.getBoundPrimitiveVariables(variableType, allTypes)); } } return varsToReturn; }
public List<string> getAllPreviouslyBoundVariableNames(PreconditionStatement currentPrecStatement, bool includeAuthorGoalParameters) { List<string> varsToReturn = new List<string>(); if (includeAuthorGoalParameters) { AuthorGoal parentGoal = StoryWorldDataProvider.findAuthorGoalById(_parentAuthorGoalId); // Add parameter variable names foreach (Parameter param in parentGoal.Parameters) { varsToReturn.Add(param.Name); } } foreach (PreconditionStatement precondStmt in _precStatements) { if (precondStmt == currentPrecStatement) { //We have found where to stop looking, can now return variable list return varsToReturn; } else { //Add the variable names bound in this statement to the running list varsToReturn.AddRange(precondStmt.getAllBoundVariableNames()); } } return varsToReturn; }