public List <Trait> getPreviouslyBoundPrimitiveVariables(TraitDataType variableType, bool allTypes, Constraint currentConstraint) { PlotFragment parentFrag = StoryWorldDataProvider.getStoryData().findPlotFragmentById(_parentPlotFragmentId); List <Trait> varsToReturn = parentFrag.getPreviouslyBoundPrimitiveVariables(variableType, allTypes, this); foreach (Constraint cons in Constraints) { if (cons == currentConstraint) { //We have found where to stop looking, can now return variable list return(varsToReturn); } else if (cons.ContainsSavedVariable) { if (allTypes || (cons.SavedVariable.Type == variableType)) { //Add the variable names bound in this constraint to the running list varsToReturn.Add(cons.SavedVariable); } } } 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); }
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 Constraint newClone = (Constraint)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.ComparisonValue = (Parameter)_comparisonValue.Clone(); newClone.SavedVariable = (Trait)_savedVariable.Clone(); //Make a new unique variable name if (newClone.ContainsSavedVariable) { string newName = newClone.SavedVariable.Name; int cloneCount = 1; Action nullAction = null; List <string> prevVars = StoryWorldDataProvider.getStoryData().findPlotFragmentById(_parentPlotFragmentId).getAllPreviouslyBoundVariableNames(nullAction, true); while (prevVars.Contains(newName)) { newName = newClone.SavedVariable.Name + cloneCount.ToString(); cloneCount++; } newClone.SavedVariable.Name = newName; } return(newClone); }
virtual public Object Clone() { Action newClone = (Action)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); return(newClone); }
override 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 ActionCreateEnvironment newClone = (ActionCreateEnvironment)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.NewEnvironment = (Environment)_newEntity.Clone(); //Give the new var a unique name, making sure the new name is actually unique. //If name is not unique, keep increment suffix number until it is string newName = newClone.VariableName; 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.VariableName + cloneCount.ToString(); cloneCount++; } newClone.VariableName = newName; return(newClone); }
virtual public Object Clone() { Relationship newClone = (Relationship)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); return(newClone); }
override public Object Clone() { Parameter newClone = (Parameter)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); return(newClone); }
override public Object Clone() { ActionTextOutput newClone = (ActionTextOutput)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.TextOutput = _textOutput; return(newClone); }
override public Object Clone() { ActionEditObject newClone = (ActionEditObject)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.NewValue = (Parameter)_newValue.Clone(); newClone.NewTarget = (Parameter)_newTarget.Clone(); return(newClone); }
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 PlotFragment newClone = (PlotFragment)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.PrecStatements = new List <PreconditionStatement>(); newClone.Actions = new List <Action>(); foreach (PreconditionStatement prec in _precStatements) { //This clone operation will result in variable names with "1" appended, //because the clone operation checks the current parent plot fragment //and attempts to create unique variable names newClone.PrecStatements.Add((PreconditionStatement)prec.Clone()); } foreach (Action act in _actions) { //This clone operation will result in variable names with "1" appended, //because the clone operation checks the current parent plot fragment //and attempts to create unique variable names newClone.Actions.Add((Action)act.Clone()); } string newName = newClone.Name; int cloneCount = 1; List <string> prevVars = new List <string>(); foreach (PlotFragment frag in StoryWorldDataProvider.getStoryData().findAuthorGoalById(_parentAuthorGoalId).PlotFragments) { prevVars.Add(frag.Name); } while (prevVars.Contains(newName)) { newName = newClone.Name + cloneCount.ToString(); cloneCount++; } newClone.Name = newName; return(newClone); }
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); }
override public Object Clone() { ActionSubgoal newClone = (ActionSubgoal)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.ParametersToPass = new List <Parameter>(); foreach (Parameter param in _parametersToPass) { newClone.ParametersToPass.Add((Parameter)param.Clone()); } return(newClone); }
public override object Clone() { PlotPoint newClone = (PlotPoint)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.Traits = new List <Trait>(); newClone.Relationships = new List <Relationship>(); foreach (Trait traitItem in _traits) { newClone.Traits.Add((Trait)traitItem.Clone()); } //no relationships return(newClone); }
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 <string> getAllPreviouslyBoundVariableNames(Constraint currentConstraint) { PlotFragment parentFrag = StoryWorldDataProvider.getStoryData().findPlotFragmentById(_parentPlotFragmentId); List <string> varsToReturn = parentFrag.getAllPreviouslyBoundVariableNames(this, true); foreach (Constraint cons in Constraints) { if (cons == currentConstraint) { //We have found where to stop looking, can now return variable list return(varsToReturn); } else if (cons.ContainsSavedVariable) { //Add the variable names bound in this constraint to the running list varsToReturn.Add(cons.SavedVariable.Name); } } return(varsToReturn); }
virtual public Object Clone() { StoryEntity newClone = (StoryEntity)MemberwiseClone(); newClone.Id = StoryWorldDataProvider.getStoryData().getNewId(); newClone.Traits = new List <Trait>(); newClone.Relationships = new List <Relationship>(); foreach (Trait traitItem in _traits) { newClone.Traits.Add((Trait)traitItem.Clone()); } foreach (Relationship relItem in _relationships) { Relationship newRel = (Relationship)relItem.Clone(); //Hook up fromId properly newRel.FromId = newClone.Id; newClone.Relationships.Add(newRel); } //Give the clone a unique name, making sure the new name is actually unique. //If name is not unique, keep increment suffix number until it is // string newName = (string)newClone.Name; // int cloneCount = 1; // while (StoryWorldDataProvider.getStoryData().findCharacterByName(newName) != null) // { // newName = newClone.Name + "_clone" + cloneCount; // cloneCount++; // } // newClone.Name = newName; return(newClone); }