Пример #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);
        }
Пример #2
0
        private void updateResourceAmounts(float mult)
        {
            SSTUVolumeContainer vc = part.GetComponent <SSTUVolumeContainer>();

            if (vc != null)
            {
                vc.inflationMultiplier = mult;
            }
            //std call that will update volume container and/or realfuels interop
            SSTUModInterop.updateResourceVolume(part);
        }
Пример #3
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);
        }
Пример #4
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            double hsp  = 1;
            double dens = 1;

            PartResourceDefinition resource = PartResourceLibrary.Instance.GetDefinition(resourceName);

            hsp  = resource.specificHeatCapacity;
            dens = resource.density;

            fluxPerResourceUnit = hsp * ablationEfficiency * dens;
            baseSkinIntMult     = part.skinInternalConductionMult;
            baseCondMult        = part.heatConductivity;

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            Transform mhsRoot = part.transform.FindRecursive("model").FindOrCreate("SSTU-MHS-Root");

            ConfigNode[] modelNodes = node.GetNodes("MODELS");
            ModelDefinitionLayoutOptions[] models = SSTUModelData.getModelDefinitions(modelNodes);
            model = new ModelModule <SSTUModularHeatShield>(part, this, mhsRoot, ModelOrientation.CENTRAL, nameof(currentShieldModel), null, nameof(currentShieldTexture), nameof(modelPersistentData), null, null, null, null);
            model.getSymmetryModule = (m) => m.model;
            model.setupModelList(models);
            model.setupModel();
            model.setScaleForDiameter(currentDiameter);
            model.setPosition(0);
            model.updateModelMeshes();
            model.updateSelections();
            model.volumeScalar = resourceScalePower;
            model.massScalar   = resourceScalePower;
            if (standAlonePart)
            {
                updateDragCube();
                updateAttachNodes(false);
            }
            SSTUModInterop.updateResourceVolume(part);
            ConfigNode[] typeNodes = node.GetNodes("SHIELDTYPE");
            shieldTypeData        = HeatShieldTypeData.load(typeNodes);
            currentShieldTypeData = Array.Find(shieldTypeData, m => m.baseType.name == currentShieldType);
            updateModuleStats();
            updatePartCost();
            SSTUModInterop.onPartGeometryUpdate(part, false);
            SSTUModInterop.updateResourceVolume(part);
            SSTUStockInterop.fireEditorUpdate();//update for mass/cost/etc.
        }
Пример #5
0
        private void updateResourceAmounts(float mult)
        {
            SSTUVolumeContainer vc = part.GetComponent <SSTUVolumeContainer>();

            if (vc != null)
            {
                vc.inflationMultiplier = mult;
                vc.recalcVolume();
            }
            else
            {
                SSTUModInterop.updateResourceVolume(part);//call out to RF to update volume; it will obviously lack the inflation multiplier data
            }
        }
Пример #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;
        }
Пример #7
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);
        }