Esempio n. 1
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize();

            Fields[nameof(currentModel)].guiName = uiLabel;
            Fields[nameof(currentModel)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                models.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.models.setScale(currentScale);
                    m.models.updateModelMeshes();
                    m.models.updateSelections();
                    m.updateMassAndCost();
                    m.updateAttachNodes(true);
                    SSTUModInterop.updateResourceVolume(m.part);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentScale)].guiActiveEditor = canAdjustScale;
            UI_FloatEdit fe = (UI_FloatEdit)Fields[nameof(currentScale)].uiControlEditor;

            if (fe != null)
            {
                fe.minValue       = minScale;
                fe.maxValue       = maxScale;
                fe.incrementLarge = incScaleLarge;
                fe.incrementSmall = incScaleSmall;
                fe.incrementSlide = incScaleSlide;
            }
            Fields[nameof(currentScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    m.models.setScale(currentScale);
                    m.models.updateModelMeshes();
                    m.updateMassAndCost();
                    m.updateAttachNodes(true);
                    SSTUModInterop.updateResourceVolume(m.part);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };
            Fields[nameof(currentTexture)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                models.textureSetSelected(a, b);
            };
            Fields[nameof(currentTexture)].guiActiveEditor = models.definition.textureSets.Length > 1;
            SSTUStockInterop.fireEditorUpdate();
            SSTUModInterop.onPartGeometryUpdate(part, true);
        }
Esempio n. 2
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            init();

            Action <SSTUModularRCS> modelChangeAction = delegate(SSTUModularRCS m)
            {
                m.updateModelScale();
                m.updateAttachNodes(true);
                m.updateMassAndCost();
                SSTUModInterop.updateResourceVolume(m.part);
                SSTUModInterop.onPartGeometryUpdate(m.part, true);
            };

            Fields[nameof(currentModel)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                rcsBlockModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    modelChangeAction(m);
                    m.updateRCSThrust();
                });
            };

            Fields[nameof(currentStructure)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                standoffModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    modelChangeAction(m);
                });
            };

            Fields[nameof(currentScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentScale = currentScale;
                    }
                    modelChangeAction(m);
                    m.updateRCSThrust();
                });
            };

            Fields[nameof(currentTexture)].uiControlEditor.onFieldChanged          = rcsBlockModule.textureSetSelected;
            Fields[nameof(currentStructureTexture)].uiControlEditor.onFieldChanged = standoffModule.textureSetSelected;

            Fields[nameof(currentScale)].guiActiveEditor = allowRescale;

            SSTUModInterop.updateResourceVolume(part);
            SSTUModInterop.onPartGeometryUpdate(part, true);
        }
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize(true);

            Action <SSTUModularStationCore> modelChangedAction = delegate(SSTUModularStationCore m)
            {
                m.updateModulePositions();
                m.updateMassAndCost();
                m.updateAttachNodes(true);
                m.updateDragCubes();
                m.updateResourceVolume();
                m.updateGUI();
            };

            Fields[nameof(currentTop)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                topModule.modelSelected(currentTop);
                this.actionWithSymmetry(modelChangedAction);
            };

            Fields[nameof(currentCore)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                coreModule.modelSelected(currentCore);
                this.actionWithSymmetry(modelChangedAction);
            };

            Fields[nameof(currentBottom)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                bottomModule.modelSelected(currentBottom);
                this.actionWithSymmetry(modelChangedAction);
            };

            Fields[nameof(currentSolar)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                solarModule.modelSelected(currentSolar);
                this.actionWithSymmetry(m =>
                {
                    modelChangedAction(m);
                    m.updateSolarModules();
                });
            };

            Fields[nameof(currentTopTexture)].uiControlEditor.onFieldChanged    = topModule.textureSetSelected;
            Fields[nameof(currentCoreTexture)].uiControlEditor.onFieldChanged   = coreModule.textureSetSelected;
            Fields[nameof(currentBottomTexture)].uiControlEditor.onFieldChanged = bottomModule.textureSetSelected;

            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified));
            }
            updateDragCubes();
        }
Esempio n. 4
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            init();
            Fields[nameof(currentStructure)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                standoffModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.updateModelScale();
                    m.updateAttachNodes(true);
                    m.updateMassAndCost();
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
            };

            Fields[nameof(currentScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentScale = currentScale;
                    }
                    m.updateModelScale();
                    m.updateRCSThrust();
                    m.updateAttachNodes(true);
                    m.updateMassAndCost();
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
            };

            Fields[nameof(currentFuelType)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentFuelType = currentFuelType;
                    }
                    m.fuelType = Array.Find(m.fuelTypes, s => s.name == m.currentFuelType);
                    m.updateRCSFuelType();
                });
            };

            Fields[nameof(currentFuelType)].guiActiveEditor = updateFuel && fuelTypes.Length > 1;
            string[] names = SSTUUtils.getNames(fuelTypes, m => m.name);
            this.updateUIChooseOptionControl(nameof(currentFuelType), names, names, true, currentFuelType);

            Fields[nameof(currentScale)].guiActiveEditor = scaleGUIActive;
        }
Esempio n. 5
0
        /// <summary>
        /// OnStart override, does basic startup/init stuff, including building models and registering for editor events
        /// </summary>
        /// <param name="state"></param>
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize();
            this.updateUIFloatEditControl(nameof(currentTankDiameter), minTankDiameter, maxTankDiameter, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter);
            float diff = maxVScale - minVScale;

            this.updateUIFloatEditControl(nameof(currentTankHeight), minVScale, maxVScale, diff * 0.2f, diff * 0.05f, diff * 0.001f, true, currentTankHeight);

            Action <SSTUModularUpperStage> modelChangeAction = m =>
            {
                m.updateModules(true);
                m.updateModels();
                m.updateTankStats();
                m.updateRCSModule();
                m.updateContainerVolume();
                m.updateGuiState();
            };

            Fields[nameof(splitTank)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    m.splitTank = splitTank;
                    if (m.splitTank)
                    {
                        m.intertankModule.setupModel();
                        m.lowerModule.setupModel();
                    }
                    else
                    {
                        m.intertankModule.model.destroyCurrentModel();
                        m.lowerModule.model.destroyCurrentModel();
                    }
                    m.Fields[nameof(currentIntertank)].guiActiveEditor        = m.splitTank;
                    m.Fields[nameof(currentLower)].guiActiveEditor            = m.splitTank;
                    m.Fields[nameof(currentIntertankTexture)].guiActiveEditor = m.splitTank;
                    m.Fields[nameof(currentLowerTexture)].guiActiveEditor     = m.splitTank;
                    modelChangeAction(m);
                });
            };

            Fields[nameof(currentNose)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                noseModule.modelSelected(currentNose);
                this.actionWithSymmetry(modelChangeAction);
            };

            Fields[nameof(currentUpper)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                upperModule.modelSelected(currentUpper);
                this.actionWithSymmetry(modelChangeAction);
            };

            Fields[nameof(currentIntertank)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                intertankModule.modelSelected(currentIntertank);
                this.actionWithSymmetry(modelChangeAction);
            };

            Fields[nameof(currentLower)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                lowerModule.modelSelected(currentLower);
                this.actionWithSymmetry(modelChangeAction);
            };

            Fields[nameof(currentMount)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                mountModule.modelSelected(currentMount);
                this.actionWithSymmetry(modelChangeAction);
            };

            Fields[nameof(currentRCS)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                rcsModule.modelSelected(currentRCS);
                this.actionWithSymmetry(m =>
                {
                    MonoBehaviour.print("RCS model updated!");
                    m.updateRCSModule();
                    modelChangeAction(m);
                });
            };

            Fields[nameof(currentNoseTexture)].uiControlEditor.onFieldChanged      = noseModule.textureSetSelected;
            Fields[nameof(currentUpperTexture)].uiControlEditor.onFieldChanged     = upperModule.textureSetSelected;
            Fields[nameof(currentMountTexture)].uiControlEditor.onFieldChanged     = mountModule.textureSetSelected;
            Fields[nameof(currentIntertankTexture)].uiControlEditor.onFieldChanged = intertankModule.textureSetSelected;
            Fields[nameof(currentLowerTexture)].uiControlEditor.onFieldChanged     = lowerModule.textureSetSelected;
            Fields[nameof(currentRCSTexture)].uiControlEditor.onFieldChanged       = rcsModule.textureSetSelected;

            Callback <BaseField, System.Object> editorUpdateDelegate = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentTankDiameter = currentTankDiameter;
                    }                                                              //else it conflicts with stock slider functionality
                    if (m != this)
                    {
                        m.currentTankHeight = currentTankHeight;
                    }
                    modelChangeAction(m);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentTankDiameter)].uiControlEditor.onFieldChanged = editorUpdateDelegate;

            Fields[nameof(currentTankHeight)].uiControlEditor.onFieldChanged = editorUpdateDelegate;

            Fields[nameof(supportPercent)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.supportPercent = supportPercent;
                    }                                                    //else it conflicts with stock slider functionality
                    m.updateContainerVolume();
                    m.updateGuiState();
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentNose)].guiActiveEditor      = noseModule.models.Count > 1;
            Fields[nameof(currentUpper)].guiActiveEditor     = upperModule.models.Count > 1;
            Fields[nameof(currentIntertank)].guiActiveEditor = splitTank && intertankModule.models.Count > 1;
            Fields[nameof(currentLower)].guiActiveEditor     = splitTank && lowerModule.models.Count > 1;
            Fields[nameof(currentMount)].guiActiveEditor     = mountModule.models.Count > 1;
            Fields[nameof(currentRCS)].guiActiveEditor       = rcsModule.models.Count > 1;

            Fields[nameof(currentIntertankTexture)].guiActiveEditor = splitTank;
            Fields[nameof(currentLowerTexture)].guiActiveEditor     = splitTank;

            SSTUModInterop.onPartGeometryUpdate(part, true);
            SSTUStockInterop.fireEditorUpdate();
        }
Esempio n. 6
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize();
            string[] options = SSTUUtils.getNames(shieldTypeData, m => m.baseType.name);
            this.updateUIChooseOptionControl(nameof(currentShieldType), options, options, true, currentShieldType);
            this.updateUIFloatEditControl(nameof(currentDiameter), minDiameter, maxDiameter, diameterIncrement * 2f, diameterIncrement, diameterIncrement * 0.05f, true, currentDiameter);
            Fields[nameof(currentShieldType)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentShieldType = currentShieldType;
                    }
                    m.currentShieldTypeData = Array.Find(m.shieldTypeData, s => s.baseType.name == m.currentShieldType);
                    m.updateModuleStats();
                    m.updatePartCost();
                    SSTUModInterop.updateResourceVolume(part);
                });
            };

            //UI functions for stand-alone part
            Fields[nameof(currentDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentDiameter = currentDiameter;
                    }
                    m.model.setScaleForDiameter(currentDiameter);
                    m.model.setPosition(0);
                    m.model.updateModelMeshes();
                    m.updateFairing(true);
                    m.updateModuleStats();
                    m.updatePartCost();
                    m.updateAttachNodes(true);
                    m.updateDragCube();
                    SSTUModInterop.updateResourceVolume(part);
                });
            };
            Fields[nameof(currentShieldModel)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                model.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.model.setScaleForDiameter(currentDiameter);
                    m.model.setPosition(0);
                    m.model.updateModelMeshes();
                    m.updateFairing(true);
                    m.updateModuleStats();
                    m.updatePartCost();
                    m.updateAttachNodes(true);
                    m.updateDragCube();
                    SSTUModInterop.updateResourceVolume(part);
                });
            };
            Fields[nameof(currentShieldTexture)].uiControlEditor.onFieldChanged = model.textureSetSelected;
            Fields[nameof(currentDiameter)].guiActiveEditor = standAlonePart;
        }
Esempio n. 7
0
        //standard KSP lifecyle override
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize(true);

            Action <SSTUModularServiceModule> modelChangedAction = delegate(SSTUModularServiceModule m)
            {
                m.updateModulePositions();
                m.updateMassAndCost();
                m.updateAttachNodes(true);
                m.updateDragCubes();
                m.updateResourceVolume();
                m.updateFairing(true);
                m.updateGUI();
                SSTUModInterop.onPartGeometryUpdate(m.part, true);
            };

            Fields[nameof(currentDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                this.actionWithSymmetry(m =>
                {
                    modelChangedAction(m);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentTop)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                topModule.modelSelected(a, b);
                this.actionWithSymmetry(modelChangedAction);
                this.actionWithSymmetry(m => { m.updateAnimationControl(noseAnimationID, topModule.model, noseAnimationLayer); });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentCore)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                coreModule.modelSelected(a, b);
                this.actionWithSymmetry(modelChangedAction);
                if (!coreModule.model.isValidSolarOption(currentSolar, coreModule.model.currentDiameterScale))
                {
                    this.actionWithSymmetry(m =>
                    {
                        m.currentSolar = m.coreModule.model.getAvailableSolarVariants(coreModule.model.currentDiameterScale)[0];
                        m.solarModule.modelSelected(m.currentSolar);
                        modelChangedAction(m);
                        m.updateSolarModules();
                    });
                }
                this.actionWithSymmetry(m =>
                {
                    m.updateAnimationControl(coreAnimationID, coreModule.model, coreAnimationLayer);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentBottom)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                bottomModule.modelSelected(a, b);
                this.actionWithSymmetry(modelChangedAction);
                this.actionWithSymmetry(m => { m.updateAnimationControl(mountAnimationID, bottomModule.model, mountAnimationLayer); });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentSolar)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                solarModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    modelChangedAction(m);
                    m.updateSolarModules();
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentRCS)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                rcsModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.rcsModule.model.renameThrustTransforms(rcsThrustTransformName);
                    modelChangedAction(m);
                    m.updateRCSModule();
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentRCSOffset)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    modelChangedAction(m);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            if (maxDiameter == minDiameter)
            {
                Fields[nameof(currentDiameter)].guiActiveEditor = false;
            }
            else
            {
                this.updateUIFloatEditControl(nameof(currentDiameter), minDiameter, maxDiameter, diameterIncrement * 2, diameterIncrement, diameterIncrement * 0.05f, true, currentDiameter);
            }

            Fields[nameof(currentTopTexture)].uiControlEditor.onFieldChanged    = topModule.textureSetSelected;
            Fields[nameof(currentCoreTexture)].uiControlEditor.onFieldChanged   = coreModule.textureSetSelected;
            Fields[nameof(currentBottomTexture)].uiControlEditor.onFieldChanged = bottomModule.textureSetSelected;

            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified));
            }
            updateDragCubes();
        }
Esempio n. 8
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize();

            string[] groupNames = TankSet.getSetNames(tankSets);
            this.updateUIChooseOptionControl(nameof(currentTankSet), groupNames, groupNames, true, currentTankSet);

            string[] names = currentTankSetModule.getModelNames();
            string[] descs = currentTankSetModule.getTankDescriptions();
            this.updateUIChooseOptionControl(nameof(currentTankType), names, descs, true, currentTankType);

            if (maxTankDiameter == minTankDiameter)
            {
                Fields[nameof(currentTankDiameter)].guiActiveEditor = false;
            }
            else
            {
                this.updateUIFloatEditControl(nameof(currentTankDiameter), minTankDiameter, maxTankDiameter, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter);
            }
            updateAvailableVariants(false);
            updateUIScaleControls();

            Fields[nameof(currentTankDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                this.actionWithSymmetry(m =>
                {
                    m.updateEditorStats(true);
                    SSTUAttachNodeUtils.updateSurfaceAttachedChildren(m.part, m.prevTankDiameter, m.currentTankDiameter);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentTankVerticalScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                this.actionWithSymmetry(m =>
                {
                    m.updateEditorStats(true);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentTankSet)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                this.actionWithSymmetry(m =>
                {
                    TankSet newSet         = Array.Find(m.tankSets, s => s.name == m.currentTankSet);
                    m.currentTankSetModule = newSet;
                    string variant         = m.lastSelectedVariant;
                    m.currentTankType      = newSet.getDefaultModel(m.lastSelectedVariant);
                    m.tankModule.updateSelections();
                    m.tankModule.modelSelected(m.currentTankType);
                    m.Fields[nameof(m.currentTankType)].guiActiveEditor = newSet.Length > 1;
                    //re-seat this if it was changed in the 'setMainTankModuleFromEditor' method
                    //will allow for user-initiated main-tank changes to still change the 'last variant' but will
                    //persist the variant if the newly selected set did not contain the selected variant
                    //so that it will persist to the next set selection, OR be reseated on the next user-tank selection within the current set
                    if (!m.currentTankSetModule.hasVariant(variant))
                    {
                        m.lastSelectedVariant = variant;
                    }
                    if (m.variantData != null)
                    {
                        m.updateAvailableVariants(true);
                    }
                    m.updateEditorStats(true);
                    m.updateUIScaleControls();
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentNoseType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                noseModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.updateEditorStats(true);
                    m.updateAnimationControl(m.noseAnimationID, m.noseModule.model, 1);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentTankType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                tankModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    if (variantData != null)
                    {
                        m.updateAvailableVariants(true);
                    }
                    m.updateEditorStats(true);
                    m.lastSelectedVariant = tankModule.model.variantName;
                    m.updateAnimationControl(m.bodyAnimationID, m.tankModule.model, 3);
                    m.updateUIScaleControls();
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentMountType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                mountModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.updateEditorStats(true);
                    m.updateAnimationControl(m.mountAnimationID, m.mountModule.model, 5);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentNoseTexture)].uiControlEditor.onFieldChanged  = noseModule.textureSetSelected;
            Fields[nameof(currentTankTexture)].uiControlEditor.onFieldChanged  = tankModule.textureSetSelected;
            Fields[nameof(currentMountTexture)].uiControlEditor.onFieldChanged = mountModule.textureSetSelected;

            Fields[nameof(currentTankSet)].guiActiveEditor   = tankSets.Length > 1;
            Fields[nameof(currentTankType)].guiActiveEditor  = currentTankSetModule.Length > 1;
            Fields[nameof(currentNoseType)].guiActiveEditor  = noseModule.models.Count > 1;
            Fields[nameof(currentMountType)].guiActiveEditor = mountModule.models.Count > 1;

            SSTUStockInterop.fireEditorUpdate();
            SSTUModInterop.onPartGeometryUpdate(part, true);
            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified));
            }
        }
Esempio n. 9
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize();
            this.updateUIFloatEditControl(nameof(currentTopDiameter), minDiameter, maxDiameter, diameterIncrement * 2, diameterIncrement, diameterIncrement * 0.05f, true, currentTopDiameter);
            this.updateUIFloatEditControl(nameof(currentBottomDiameter), minDiameter, maxDiameter, diameterIncrement * 2, diameterIncrement, diameterIncrement * 0.05f, true, currentBottomDiameter);
            this.updateUIFloatEditControl(nameof(currentHeight), minHeight, maxHeight, heightIncrement * 2, heightIncrement, heightIncrement * 0.05f, true, currentHeight);
            this.updateUIFloatEditControl(nameof(currentTaperHeight), minHeight, maxHeight, heightIncrement * 2, heightIncrement, heightIncrement * 0.05f, true, currentTaperHeight);

            Action <SSTUInterstageDecoupler> rebuild = delegate(SSTUInterstageDecoupler m)
            {
                m.updateEditorFields();
                m.buildFairing();
                m.updateEnginePositionAndScale();
                m.updateNodePositions(true);
                m.updatePartMass();
                m.updateShielding();
                m.updateDragCubes();
                m.updateFairingTextureSet(false);
            };

            Fields[nameof(currentTopDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentTopDiameter = this.currentTopDiameter;
                    }
                    rebuild(m);
                });
            };
            Fields[nameof(currentBottomDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentBottomDiameter = this.currentBottomDiameter;
                    }
                    rebuild(m);
                });
            };
            Fields[nameof(currentHeight)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentHeight = this.currentHeight;
                    }
                    rebuild(m);
                });
            };
            Fields[nameof(currentTaperHeight)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentTaperHeight = this.currentTaperHeight;
                    }
                    rebuild(m);
                });
            };
            Fields[nameof(editorTransparency)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.editorTransparency = this.editorTransparency;
                    }
                    m.fairingBase.setOpacity(m.editorTransparency ? 0.25f : 1);
                });
            };
            Fields[nameof(generateColliders)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.generateColliders = this.generateColliders;
                    }
                    if (m.fairingBase.generateColliders != m.generateColliders)
                    {
                        m.fairingBase.generateColliders = m.generateColliders;
                        m.buildFairing();
                        m.updateFairingTextureSet(false);
                    }
                });
            };

            Fields[nameof(currentTextureSet)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    m.currentTextureSet = currentTextureSet;
                    m.updateFairingTextureSet(!SSTUGameSettings.persistRecolor());
                });
            };

            Fields[nameof(currentEngineModel)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                engineModels.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    //model selected action sets vars on symmetry parts
                    rebuild(m);
                    m.reInitEngineModule();
                    SSTUModInterop.updateResourceVolume(m.part);
                });
            };
            Fields[nameof(currentEngineScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                this.actionWithSymmetry(m =>
                {
                    if (m != this)
                    {
                        m.currentEngineScale = this.currentEngineScale;
                    }
                    rebuild(m);
                    SSTUModInterop.updateResourceVolume(m.part);
                });
            };
            Fields[nameof(currentEngineLayout)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
            {
                engineModels.layoutSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.reInitEngineModule();
                    m.updatePartMass();
                    m.updateDragCubes();
                    SSTUModInterop.updateResourceVolume(m.part);
                });
            };
            Fields[nameof(currentEngineTextureSet)].uiControlEditor.onFieldChanged = engineModels.textureSetSelected;
            Fields[nameof(currentEngineTextureSet)].guiActiveEditor = engineModels.definition.textureSets.Length > 1;

            GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorShipModified));
            SSTUModInterop.onPartGeometryUpdate(part, true);
            SSTUModInterop.updateResourceVolume(part);
        }