Beispiel #1
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.
        }
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            double hsp  = 1;
            double dens = 1;

            if (heatSoak)
            {
                PartResourceDefinition resource = PartResourceLibrary.Instance.GetDefinition(resourceName);
                hsp  = resource.specificHeatCapacity;
                dens = resource.density;
            }
            else
            {
                resource = part.Resources[resourceName];
                if (resource != null)
                {
                    hsp  = resource.info.specificHeatCapacity;
                    dens = resource.info.density;
                }
                else
                {
                    hsp  = PhysicsGlobals.StandardSpecificHeatCapacity;
                    dens = 0.005f;
                }
            }
            fluxPerResourceUnit = hsp * ablationEfficiency * dens;
            baseSkinIntMult     = part.skinInternalConductionMult;
            baseCondMult        = part.heatConductivity;

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            //stand-alone modular heat-shield setup
            if (standAlonePart)
            {
                ConfigNode[] modelNodes = node.GetNodes("MODEL");
                model = new ModelModule <SingleModelData, SSTUModularHeatShield>(part, this, part.transform.FindRecursive("model"), ModelOrientation.CENTRAL, nameof(modelPersistentData), nameof(currentShieldModel), nameof(currentShieldTexture));
                model.setupModelList(SingleModelData.parseModels(modelNodes));
                model.setupModel();
                model.model.updateScaleForDiameter(currentDiameter);
                model.setPosition(0, ModelOrientation.CENTRAL);
                model.model.updateModel();
                updateAttachNodes(false);
                updateDragCube();
            }

            ConfigNode[] typeNodes = node.GetNodes("SHIELDTYPE");
            shieldTypeData        = HeatShieldTypeData.load(typeNodes);
            currentShieldTypeData = Array.Find(shieldTypeData, m => m.baseType.name == currentShieldType);
            updateModuleStats();

            updatePartCost();
            if (!initializedResources && (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight))
            {
                updatePartResources();
                initializedResources = true;
            }
        }