示例#1
0
 private void updateAvailableVariants(bool useDefaultIfInvalid)
 {
     noseModule.updateSelections(useDefaultIfInvalid);
     mountModule.updateSelections(useDefaultIfInvalid);
     Fields[nameof(currentNoseType)].guiActiveEditor  = noseModule.models.Count > 1;
     Fields[nameof(currentMountType)].guiActiveEditor = mountModule.models.Count > 1;
 }
示例#2
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();
        }
示例#3
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.
        }
示例#4
0
        private void init()
        {
            if (initialized)
            {
                return;
            }
            initialized         = true;
            standoffRotatedRoot = part.transform.FindRecursive("SSTUModularRCSStructureRoot");
            if (standoffRotatedRoot == null)
            {
                standoffRotatedRoot = new GameObject("SSTUModularRCSStructureRoot").transform;
                standoffRotatedRoot.NestToParent(part.transform.FindRecursive("model"));
                standoffRotatedRoot.Rotate(90, -90, 0);
            }
            modelRotatedRoot = part.transform.FindRecursive("SSTUModularRCSBlockRoot");
            if (modelRotatedRoot == null)
            {
                modelRotatedRoot = new GameObject("SSTUModularRCSBlockRoot").transform;
                modelRotatedRoot.NestToParent(part.transform.FindRecursive("model"));
                modelRotatedRoot.Rotate(0, 0, 0);
            }
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ModelDefinitionLayoutOptions[] blocks  = SSTUModelData.getModelDefinitions(node.GetNodes("MODEL"));
            ModelDefinitionLayoutOptions[] structs = SSTUModelData.getModelDefinitions(node.GetNodes("STRUCTURE"));

            modelTransform      = modelRotatedRoot.FindOrCreate("ModularRCSModel");
            rcsBlockModule      = new ModelModule <SSTUModularRCS>(part, this, modelTransform, ModelOrientation.CENTRAL, nameof(currentModel), nameof(currentLayout), nameof(currentTexture), nameof(modelPersistentData), null, null, null, null);
            rcsBlockModule.name = "RCSBlock";
            rcsBlockModule.getSymmetryModule = m => m.rcsBlockModule;
            rcsBlockModule.setupModelList(blocks);
            rcsBlockModule.getValidOptions = () => blocks;
            rcsBlockModule.setupModel();
            rcsBlockModule.updateSelections();

            standoffTransform   = standoffRotatedRoot.FindOrCreate("ModularRCSStandoff");
            standoffModule      = new ModelModule <SSTUModularRCS>(part, this, standoffTransform, ModelOrientation.TOP, nameof(currentStructure), nameof(currentLayout), nameof(currentStructureTexture), nameof(structurePersistentData), null, null, null, null);
            standoffModule.name = "Standoff";
            standoffModule.getSymmetryModule = m => m.standoffModule;
            standoffModule.setupModelList(structs);
            standoffModule.getValidOptions = () => structs;
            standoffModule.setupModel();
            standoffModule.updateSelections();

            updateModelScale();
            updateMassAndCost();
            rcsBlockModule.renameRCSThrustTransforms(rcsThrustTransformName);

            updateAttachNodes(false);
        }
示例#5
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ModelDefinitionLayoutOptions[] defs = SSTUModelData.getModelDefinitions(node.GetNodes("MODEL"));
            Transform root = part.transform.FindRecursive("model").FindOrCreate(rootTransformName);

            models      = new ModelModule <SSTUModelSwitch>(part, this, root, ModelOrientation.TOP, nameof(currentModel), null, nameof(currentTexture), nameof(modelPersistentData), nameof(animationPersistentData), nameof(animationMaxDeploy), nameof(enableAnimationEvent), nameof(disableAnimationEvent));
            models.name = "ModelSwitch";
            models.getSymmetryModule = m => m.models;
            models.getValidOptions   = () => defs;
            models.setupModelList(defs);
            models.setupModel();
            models.setScale(currentScale);
            models.updateModelMeshes();
            models.updateSelections();
            updateMassAndCost();
            updateAttachNodes(false);
        }
示例#6
0
 private void updateGUI()
 {
     topModule.updateSelections();
     bottomModule.updateSelections();
     solarModule.updateSelections();
 }
示例#7
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();
        }