示例#1
0
        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);
        }