示例#1
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);

            mpf = part.GetComponent <ModuleProceduralFairing>();
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet t      = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (t == null)
            {
                currentTextureSet = names[0];
                t = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(t.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            Fields[nameof(currentTextureSet)].guiActiveEditor = names.Length > 1;
        }
示例#2
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize();
            float max = techLimitMaxDiameter < maxTankDiameter ? techLimitMaxDiameter : maxTankDiameter;

            string[] names = SSTUUtils.getNames(mainTankModules, m => m.name);
            this.updateUIChooseOptionControl("currentTankType", names, names, true, currentTankType);
            this.updateUIFloatEditControl("currentTankDiameter", minTankDiameter, max, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter);
            updateAvailableVariants();
            updateUIScaleControls();
            Fields["currentTankDiameter"].uiControlEditor.onFieldChanged      = tankDiameterUpdated;
            Fields["currentTankVerticalScale"].uiControlEditor.onFieldChanged = tankHeightScaleUpdated;
            Fields["currentTankType"].uiControlEditor.onFieldChanged          = tankTypeUpdated;
            Fields["currentNoseType"].uiControlEditor.onFieldChanged          = noseTypeUpdated;
            Fields["currentMountType"].uiControlEditor.onFieldChanged         = mountTypeUpdated;

            Fields["currentNoseTexture"].uiControlEditor.onFieldChanged  = onNoseTextureUpdated;
            Fields["currentTankTexture"].uiControlEditor.onFieldChanged  = onTankTextureUpdated;
            Fields["currentMountTexture"].uiControlEditor.onFieldChanged = onMountTextureUpdated;

            Fields["currentTankType"].guiActiveEditor  = mainTankModules.Length > 1;
            Fields["currentNoseType"].guiActiveEditor  = noseModules.Length > 1;
            Fields["currentMountType"].guiActiveEditor = mountModules.Length > 1;

            SSTUStockInterop.fireEditorUpdate();
            SSTUModInterop.onPartGeometryUpdate(part, true);
            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified));
            }
        }
示例#3
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized    = true;
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (currentTextureSetData == null)
            {
                currentTextureSet     = names[0];
                currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors     = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(currentTextureSetData.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
            Fields[nameof(currentTextureSet)].guiActiveEditor = names.Length > 1;

            fuelType = VolumeContainerLoader.getPreset(fuelPreset);

            Transform modelBase = part.transform.FindRecursive("model");

            //Set up the engine models container
            ConfigNode[] modelNodes = node.GetNodes("MODEL");
            engineModelRoot = modelBase.FindOrCreate(engineModelRootName);
            ModelDefinitionLayoutOptions[] models = SSTUModelData.getModelDefinitions(modelNodes);
            engineModels = new ModelModule <SSTUInterstageDecoupler>(part, this, engineModelRoot, ModelOrientation.CENTRAL, nameof(currentEngineModel), nameof(currentEngineLayout), nameof(currentEngineTextureSet), nameof(customEngineColorData), null, null, null, null);
            engineModels.getSymmetryModule       = m => m.engineModels;
            engineModels.getValidOptions         = () => models;
            engineModels.getLayoutPositionScalar = () => currentBottomDiameter * 0.5f;
            //engineModels.getLayoutScaleScalar = () => currentEngineScale;
            engineModels.setupModelList(models);
            engineModels.setupModel();
            engineModels.updateSelections();
            updateEnginePositionAndScale();

            //set up the fairing container
            minHeight = engineModels.moduleHeight;
            Transform fairingContainerRoot = modelBase.FindOrCreate(baseTransformName);

            fairingBase = new FairingContainer(fairingContainerRoot.gameObject, cylinderSides, numberOfPanels, wallThickness);
            updateEditorFields();
            buildFairing();
            updateEnginePositionAndScale();
            updateFairingTextureSet(false);
            updateNodePositions(false);
            updatePartMass();
        }
示例#4
0
        /// <summary>
        /// NON-Symmetry enabled method
        /// </summary>
        public void updateSelections(bool updateIfInvalid = false)
        {
            IEnumerable <T> validSelections = getValidSelections(models);

            string[] names    = SSTUUtils.getNames(validSelections, s => s.name);
            string[] displays = getDisplayNames(validSelections);
            if (updateIfInvalid && !Array.Exists(names, m => m == modelName))
            {
                modelSelected(names[0]);
            }
            partModule.updateUIChooseOptionControl(modelField.name, names, displays, true, modelName);
            modelField.guiActiveEditor = names.Length > 1;
        }
示例#5
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;
        }
 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);
     this.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.updatePartResources();
             m.updatePartCost();
         });
     };
     this.Fields[nameof(currentDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
     {
         this.actionWithSymmetry(m =>
         {
             if (m != this)
             {
                 m.currentDiameter = currentDiameter;
             }
             m.model.model.updateScaleForDiameter(currentDiameter);
             m.model.model.setPosition(0, ModelOrientation.CENTRAL);
             m.model.updateModel();
             m.updateFairing(true);
             m.updateModuleStats();
             m.updatePartResources();
             m.updatePartCost();
             m.updateAttachNodes(true);
             m.updateDragCube();
         });
     };
     this.Fields[nameof(currentDiameter)].guiActiveEditor                = standAlonePart;
     this.Fields[nameof(currentShieldModel)].guiActiveEditor             = false;
     Fields[nameof(currentShieldTexture)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b)
     {
         model.textureSetSelected(a, b);
     };
     this.Fields[nameof(currentShieldTexture)].guiActiveEditor = standAlonePart && model.model.modelDefinition.textureSets.Length > 1;
 }
示例#7
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet t      = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (t == null)
            {
                currentTextureSet = names[0];
                t = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(t.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);

            Transform tr = part.transform.FindRecursive("model").FindOrCreate("PetalAdapterRoot");

            fairingBase = new InterstageFairingContainer(tr.gameObject, cylinderSides, numberOfPanels, wallThickness);
            UVMap uvs = UVMap.GetUVMapGlobal(uvMap);

            fairingBase.outsideUV = uvs.getArea("outside");
            fairingBase.insideUV  = uvs.getArea("inside");
            fairingBase.edgesUV   = uvs.getArea("edges");

            validateStraightHeight();
            rebuildFairing(false);//will create fairing using default / previously saved fairing configuration
            setPanelRotations(currentRotation);
            if (state == InterstageFairingState.JETTISONED)
            {
                fairingBase.destroyFairing();
            }
            updateGuiState();
        }
示例#8
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            init();

            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 = fuelTypes.Length > 1;
            string[] names = SSTUUtils.getNames(fuelTypes, m => m.name);
            this.updateUIChooseOptionControl(nameof(currentFuelType), names, names, true, currentFuelType);
        }
        private void loadConfigData()
        {
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (currentTextureSetData == null)
            {
                currentTextureSet     = names[0];
                currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors     = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(currentTextureSetData.maskColors);
            }
            Fields["currentTextureSet"].guiActiveEditor = names.Length > 1;
            this.updateUIChooseOptionControl("currentTextureSet", names, titles, true, currentTextureSet);
        }
示例#10
0
        /// <summary>
        /// Restores ModelData instances from config node data, and populates the 'currentModule' instances with the currently enabled modules.
        /// </summary>
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] tankSetsNodes = node.GetNodes("TANKSET");
            ConfigNode[] tankNodes     = node.GetNodes("TANK");
            ConfigNode[] mountNodes    = node.GetNodes("CAP");

            variantData = TankVariant.parseVariants(node.GetNodes("VARIANT"));

            tankSets = TankSet.parseSets(tankSetsNodes);
            //if no sets exist, initialize a default set to add all models to
            if (tankSets.Length == 0)
            {
                tankSets = new TankSet[1];
                ConfigNode defaultSetNode = new ConfigNode("TANKSET");
                defaultSetNode.AddValue("name", "default");
                tankSets[0] = new TankSet(defaultSetNode);
            }
            TankModelData[] mainTankModules = ModelData.parseModels <TankModelData>(tankNodes, m => new TankModelData(m));

            int     len = mainTankModules.Length;
            TankSet set;

            for (int i = 0; i < len; i++)
            {
                set = Array.Find(tankSets, m => m.name == mainTankModules[i].setName);
                //if set is not found by name, add it to the first set which is guaranteed to exist due to the default-set-adding code above.
                if (set == null)
                {
                    set = tankSets[0];
                }
                set.addModel(mainTankModules[i]);
            }

            topNodeNames    = SSTUUtils.parseCSV(topManagedNodeNames);
            bottomNodeNames = SSTUUtils.parseCSV(bottomManagedNodeNames);

            tankModule = new ModelModule <TankModelData, SSTUModularFuelTank>(part, this, getRootTransform(rootTransformName, true), ModelOrientation.CENTRAL, nameof(bodyModuleData), nameof(currentTankType), nameof(currentTankTexture));
            tankModule.getSymmetryModule = m => m.tankModule;
            tankModule.getDisplayNames   = m => SSTUUtils.getNames(m, s => s.variantName);
            tankModule.setupModelList(mainTankModules);

            currentTankSetModule = Array.Find(tankSets, m => m.name == tankModule.model.setName);
            currentTankSet       = currentTankSetModule.name;
            lastSelectedVariant  = tankModule.model.variantName;

            tankModule.getValidSelections = delegate(IEnumerable <TankModelData> data) { return(System.Linq.Enumerable.Where(data, s => s.setName == currentTankSet)); };
            tankModule.updateSelections();
            tankModule.setupModel();

            len = mountNodes.Length;
            ConfigNode             mountNode;
            List <SingleModelData> noses  = new List <SingleModelData>();
            List <SingleModelData> mounts = new List <SingleModelData>();

            for (int i = 0; i < len; i++)
            {
                mountNode = mountNodes[i];
                if (mountNode.GetBoolValue("useForNose", true))
                {
                    mountNode.SetValue("nose", "true");
                    noses.Add(new SingleModelData(mountNode));
                }
                if (mountNode.GetBoolValue("useForMount", true))
                {
                    mountNode.SetValue("nose", "false");
                    mounts.Add(new SingleModelData(mountNode));
                }
            }

            noseModule = new ModelModule <SingleModelData, SSTUModularFuelTank>(part, this, getRootTransform(rootNoseTransformName, true), ModelOrientation.TOP, nameof(noseModuleData), nameof(currentNoseType), nameof(currentNoseTexture));
            noseModule.getSymmetryModule  = m => m.noseModule;
            noseModule.getValidSelections = delegate(IEnumerable <SingleModelData> data)
            {
                return(System.Linq.Enumerable.Where(data, m => m.canSwitchTo(part, topNodeNames) && TankVariant.isValidNose(m.name, tankModule.model.variantName, variantData)));
            };
            noseModule.setupModelList(noses);
            noseModule.setupModel();

            mountModule = new ModelModule <SingleModelData, SSTUModularFuelTank>(part, this, getRootTransform(rootMountTransformName, true), ModelOrientation.BOTTOM, nameof(mountModuleData), nameof(currentMountType), nameof(currentMountTexture));
            mountModule.getSymmetryModule  = m => m.mountModule;
            mountModule.getValidSelections = delegate(IEnumerable <SingleModelData> data)
            {
                return(System.Linq.Enumerable.Where(data, m => m.canSwitchTo(part, bottomNodeNames) && TankVariant.isValidMount(m.name, tankModule.model.variantName, variantData)));
            };
            mountModule.setupModelList(mounts);
            mountModule.setupModel();
        }
示例#11
0
        //creates/recreates FairingData instances from data from config node and any persistent node (if applicable)
        private void loadFairingData(ConfigNode node)
        {
            recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]);

            ConfigNode[] fairingNodes = node.GetNodes("FAIRING");
            fairingParts = new SSTUNodeFairingData[fairingNodes.Length];

            Transform modelBase = part.transform.FindRecursive("model");
            Transform parent;

            SSTUNodeFairing[] cs = part.GetComponents <SSTUNodeFairing>();
            int l           = Array.IndexOf(cs, this);
            int moduleIndex = l;

            for (int i = 0; i < fairingNodes.Length; i++)
            {
                parent          = modelBase.FindOrCreate(fairingName + "-" + moduleIndex + "-" + i);
                fairingParts[i] = new SSTUNodeFairingData();
                fairingParts[i].load(fairingNodes[i], parent.gameObject);
                if (fairingParts[i].canAdjustTop)
                {
                    enableTopDiameterControls = true;
                    if (guiTopDiameter < 0)
                    {
                        guiTopDiameter = fairingParts[i].topRadius * 2f;
                    }
                    else
                    {
                        fairingParts[i].topRadius = guiTopDiameter * 0.5f;
                    }
                }
                if (fairingParts[i].canAdjustBottom)
                {
                    enableBottomDiameterControls = true;
                    if (guiBottomDiameter < 0)
                    {
                        guiBottomDiameter = fairingParts[i].bottomRadius * 2f;
                    }
                    else
                    {
                        fairingParts[i].bottomRadius = guiBottomDiameter * 0.5f;
                    }
                }
            }
            //reload fairing data from persistence;
            //it -should- already match the guiTopDiameter/guiBottomDiameter (or else was already corrupted/invalid when saved out).
            if (!String.IsNullOrEmpty(persistentDataString))
            {
                String[] datas  = SSTUUtils.parseCSV(persistentDataString, ":");
                int      length = datas.Length;
                for (int i = 0; i < length; i++)
                {
                    fairingParts[i].loadPersistence(datas[i]);
                }
            }
            string[]   names  = node.GetStringValues("textureSet");
            string[]   titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title);
            TextureSet t      = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);

            if (t == null)
            {
                currentTextureSet = names[0];
                t = TexturesUnlimitedLoader.getTextureSet(currentTextureSet);
                initializedColors = false;
            }
            if (!initializedColors)
            {
                initializedColors = true;
                recolorHandler.setColorData(t.maskColors);
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet);
        }
示例#12
0
 public string[] getLayoutTitles()
 {
     return(SSTUUtils.getNames(layouts, m => m.title));
 }
示例#13
0
 public string[] getTextureSetTitles()
 {
     return(SSTUUtils.getNames(textureSets, m => m.title));
 }