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); }
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 bool syncParametersWithSubgoal() { //Check to see if parameter variables to pass are synced with subgoal to pursue // Add new ones, delete non-existent ones, and warn about newly instantiated ones // that the user has never edited due to the update //NOTE: This synchronization process uses the parameter name as the identifying // data, instead of the TypeID variable. This allows for changes in the story goal // to not totally destroy any old settings the user has entered. This sync process // is therefore not the same as the typeid-based sync for character/environment // traits in the Utilities class List <Parameter> subgoalParams = StoryWorldDataProvider.findAuthorGoalById(_subGoalId).Parameters; List <Parameter> syncList = new List <Parameter>(); bool dataUpdated = false; foreach (Parameter param in subgoalParams) { Parameter oldParam = Utilities.findParameterByName(_parametersToPass, param.Name); if (oldParam == null) { //nonexistent parameter that needs to be in the param list syncList.Add(new Parameter(param, StoryWorldDataProvider.getStoryData())); dataUpdated = true; } else { //Synchronize type id's - this is not currently used, but could be in the future oldParam.TypeId = param.TypeId; if (oldParam.Type != param.Type) { dataUpdated = true; //sync types - this will switch the value of the parameter. oldParam.Type = param.Type; //Because types were switched, variable binding is cleared as well oldParam.ValueIsBoundToVariable = false; oldParam.resetValue(); } syncList.Add(oldParam); } } // Change list to corrected list _parametersToPass = syncList; return(dataUpdated); }