Example #1
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);
        }