Exemplo n.º 1
0
        private void PopulateTunnelingVariables(string nameOfNamedObject, NamedObjectSave nos)
        {
            List <string> availableVariables = null;

            if (nos != null)
            {
                availableVariables = ExposedVariableManager.GetExposableMembersFor(nos).Select(item => item.Member).ToList();


                // We should remove any variables that are already tunneled into
                foreach (CustomVariable customVariable in EditorLogic.CurrentElement.CustomVariables)
                {
                    if (customVariable.SourceObject == nameOfNamedObject)
                    {
                        // Reverse loop since we're removing things
                        for (int i = availableVariables.Count - 1; i > -1; i--)
                        {
                            if (availableVariables[i] == customVariable.SourceObjectProperty)
                            {
                                availableVariables.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
            }

            if (availableVariables != null)
            {
                availableVariables.Sort();

                this.TunnelingVariableComboBox.Items.Clear();
                if (availableVariables != null)
                {
                    // We don't want to expose things like velocity an acceleration in Glue
                    List <string> velocityAndAccelerationVariables = ExposedVariableManager.GetPositionedObjectRateVariables();
                    // We also don't want to expose relative values - the user just simply sets the value and the state/variable handles
                    // whether it sets relative or absolute depending on whether the Entity is attached or not.
                    // This behavior used to not exist, but users never knew when to use relative or absolute, and
                    // that level of control is not really needed...if it is, custom code can probably handle it.
                    List <string> relativeVariables = ExposedVariableManager.GetPositionedObjectRelativeValues();


                    foreach (string availableVariable in availableVariables)
                    {
                        if (!velocityAndAccelerationVariables.Contains(availableVariable) && !relativeVariables.Contains(availableVariable))
                        {
                            this.TunnelingVariableComboBox.Items.Add(availableVariable);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void FillExposableVariables()
        {
            List <string> availableVariables = null;

            if (EditorLogic.CurrentEntitySave != null)
            {
                availableVariables = ExposedVariableManager.GetExposableMembersFor(EditorLogic.CurrentEntitySave, true).Select(item => item.Member).ToList();
            }
            else if (EditorLogic.CurrentScreenSave != null)
            {
                availableVariables = ExposedVariableManager.GetExposableMembersFor(EditorLogic.CurrentScreenSave, true).Select(item => item.Member).ToList();
            }

            if (availableVariables != null)
            {
                // We don't want to expose things like velocity an acceleration in Glue
                List <string> velocityAndAccelerationVariables = ExposedVariableManager.GetPositionedObjectRateVariables();
                // We also don't want to expose relative values - the user just simply sets the value and the state/variable handles
                // whether it sets relative or absolute depending on whether the Entity is attached or not.
                // This behavior used to not exist, but users never knew when to use relative or absolute, and
                // that level of control is not really needed...if it is, custom code can probably handle it.
                List <string> relativeVariables = ExposedVariableManager.GetPositionedObjectRelativeValues();

                foreach (string variableName in availableVariables)
                {
                    if (!velocityAndAccelerationVariables.Contains(variableName) && !relativeVariables.Contains(variableName))
                    {
                        AvailableVariablesComboBox.Items.Add(variableName);
                    }
                }

                if (AvailableVariablesComboBox.Items.Count > 0)
                {
                    AvailableVariablesComboBox.SelectedIndex = 0;
                }
            }
        }