Ejemplo n.º 1
0
        /// <summary>
        /// Loads all of the part definitions and values from the stashed config node data
        /// </summary>
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            noseModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSNose"), ModelOrientation.TOP, nameof(nosePersistentData), nameof(currentNose), nameof(currentNoseTexture));
            noseModule.getSymmetryModule = m => m.noseModule;
            noseModule.setupModelList(SingleModelData.parseModels(node.GetNodes("NOSE")));
            noseModule.setupModel();

            upperModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSUpper"), ModelOrientation.TOP, nameof(upperPersistentData), nameof(currentUpper), nameof(currentUpperTexture));
            upperModule.getSymmetryModule = m => m.upperModule;
            upperModule.setupModelList(SingleModelData.parseModels(node.GetNodes("UPPER")));
            upperModule.setupModel();

            intertankModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSIntertank"), ModelOrientation.TOP, nameof(intertankPersistentData), nameof(currentIntertank), nameof(currentIntertankTexture));
            intertankModule.getSymmetryModule = m => m.intertankModule;
            intertankModule.setupModelList(SingleModelData.parseModels(node.GetNodes("INTERTANK")));
            intertankModule.setupModel();

            lowerModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSLower"), ModelOrientation.TOP, nameof(lowerPersistentData), nameof(currentLower), nameof(currentLowerTexture));
            lowerModule.getSymmetryModule = m => m.lowerModule;
            lowerModule.setupModelList(SingleModelData.parseModels(node.GetNodes("LOWER")));
            lowerModule.setupModel();

            mountModule = new ModelModule <SingleModelData, SSTUModularUpperStage>(part, this, getRootTransform("MUSMount"), ModelOrientation.BOTTOM, nameof(mountPersistentData), nameof(currentMount), nameof(currentMountTexture));
            mountModule.getSymmetryModule = m => m.mountModule;
            mountModule.setupModelList(SingleModelData.parseModels(node.GetNodes("MOUNT")));
            mountModule.setupModel();

            rcsModule = new ModelModule <SSTUModularUpperStageRCS, SSTUModularUpperStage>(part, this, getRootTransform("MUSRCS"), ModelOrientation.CENTRAL, nameof(rcsPersistentData), nameof(currentRCS), nameof(currentRCSTexture));
            rcsModule.getSymmetryModule = m => m.rcsModule;
            rcsModule.setupModelList(SingleModelData.parseModels(node.GetNodes("RCS"), m => new SSTUModularUpperStageRCS(m)));
            rcsModule.setupModel();
            updateRCSModule();

            if (!splitTank)
            {
                intertankModule.model.destroyCurrentModel();
                lowerModule.model.destroyCurrentModel();
            }
        }
Ejemplo n.º 2
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 = SSTUStockInterop.getPartModuleConfig(part, this);

            ConfigNode[] tankNodes  = node.GetNodes("TANK");
            ConfigNode[] mountNodes = node.GetNodes("CAP");
            ConfigNode[] fuelNodes  = node.GetNodes("FUELTYPE");
            ConfigNode[] limitNodes = node.GetNodes("TECHLIMIT");

            mainTankModules = SingleModelData.parseModels(tankNodes);

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

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

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

            currentMainTankModule = Array.Find(mainTankModules, m => m.name == currentTankType);
            if (currentMainTankModule == null)
            {
                MonoBehaviour.print("ERROR: Could not locate tank type for: " + currentTankType + ". reverting to first available tank type.");
                currentMainTankModule = mainTankModules[0];
                currentTankType       = currentMainTankModule.name;
            }

            currentNoseModule = Array.Find(noseModules, m => m.name == currentNoseType);
            if (currentNoseModule == null)
            {
                MonoBehaviour.print("ERROR: Could not locate nose type for: " + currentNoseType + ". reverting to first available nose type.");
                currentNoseModule = noseModules[0];
                currentNoseType   = currentNoseModule.name;
            }

            currentMountModule = Array.Find(mountModules, m => m.name == currentMountType);
            if (currentMountModule == null)
            {
                MonoBehaviour.print("ERROR: Could not locate mount type for: " + currentMountType + ". reverting to first available mount type.");
                currentMountModule = mountModules[0];
                currentMountType   = currentMountModule.name;
            }
            if (!currentMainTankModule.isValidTextureSet(currentTankTexture))
            {
                currentTankTexture = currentMainTankModule.getDefaultTextureSet();
            }
            if (!currentNoseModule.isValidTextureSet(currentNoseTexture))
            {
                currentNoseTexture = currentNoseModule.getDefaultTextureSet();
            }
            if (!currentMountModule.isValidTextureSet(currentMountTexture))
            {
                currentMountTexture = currentMountModule.getDefaultTextureSet();
            }
            currentNoseModule.updateTextureUIControl(this, "currentNoseTexture", currentNoseTexture);
            currentMainTankModule.updateTextureUIControl(this, "currentTankTexture", currentTankTexture);
            currentMountModule.updateTextureUIControl(this, "currentMountTexture", currentMountTexture);
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        private void init(bool start)
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            topNodeNames    = SSTUUtils.parseCSV(topManagedNodes);
            bottomNodeNames = SSTUUtils.parseCSV(bottomManagedNodes);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            coreModules = SingleModelData.parseModels(node.GetNodes("CORE"));

            List <ConfigNode> tops    = new List <ConfigNode>();
            List <ConfigNode> bottoms = new List <ConfigNode>();

            ConfigNode[] mNodes = node.GetNodes("CAP");
            ConfigNode   mNode;
            int          len = mNodes.Length;

            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                if (mNode.GetBoolValue("useForTop", true))
                {
                    tops.Add(mNode);
                }
                if (mNode.GetBoolValue("useForBottom", true))
                {
                    bottoms.Add(mNode);
                }
            }
            topModules    = SingleModelData.parseModels(tops.ToArray());
            bottomModules = SingleModelData.parseModels(bottoms.ToArray());
            tops.Clear();
            bottoms.Clear();

            mNodes = node.GetNodes("DOCK");
            len    = mNodes.Length;
            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                if (mNode.GetBoolValue("useForTop", true))
                {
                    tops.Add(mNode);
                }
                if (mNode.GetBoolValue("useForBottom", true))
                {
                    bottoms.Add(mNode);
                }
            }
            topDockModules    = SingleModelData.parseModels(tops.ToArray());
            bottomDockModules = SingleModelData.parseModels(bottoms.ToArray());
            tops.Clear();
            bottoms.Clear();

            mNodes       = node.GetNodes("SOLAR");
            len          = mNodes.Length;
            solarModules = new SolarData[len];
            for (int i = 0; i < len; i++)
            {
                mNode           = mNodes[i];
                solarModules[i] = new SolarData(mNode);
            }

            topDockModule    = SingleModelData.findModel(topDockModules, currentTopDock);
            topModule        = SingleModelData.findModel(topModules, currentTop);
            coreModule       = SingleModelData.findModel(coreModules, currentCore);
            bottomModule     = SingleModelData.findModel(bottomModules, currentBottom);
            bottomDockModule = SingleModelData.findModel(bottomDockModules, currentBottomDock);
            solarModule      = Array.Find(solarModules, m => m.name == currentSolar);//TODO cleanup

            //validate selections for sub-modules that may require unlocks
            if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
            {
                if (!topDockModule.isAvailable(upgradesApplied))
                {
                    topDockModule = Array.Find(topDockModules, m => m.isAvailable(upgradesApplied));
                }
                if (!bottomDockModule.isAvailable(upgradesApplied))
                {
                    bottomDockModule = Array.Find(bottomDockModules, m => m.isAvailable(upgradesApplied));
                }
                if (!solarModule.isAvailable(this))
                {
                    solarModule = Array.Find(solarModules, m => m.isAvailable(this));
                }
                currentTopDock    = topDockModule.name;
                currentBottomDock = bottomDockModule.name;
                currentSolar      = solarModule.name;
            }

            if (!topModule.isValidTextureSet(currentTopTexture))
            {
                currentTopTexture = topModule.getDefaultTextureSet();
            }
            if (!coreModule.isValidTextureSet(currentCoreTexture))
            {
                currentCoreTexture = coreModule.getDefaultTextureSet();
            }
            if (!bottomModule.isValidTextureSet(currentBottomTexture))
            {
                currentBottomTexture = bottomModule.getDefaultTextureSet();
            }

            restoreModels();
            updateModulePositions();
            updateMass();
            updateCost();
            updateAttachNodes(false);
            if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
            {
                ModuleDockingNode[] mdns = part.GetComponents <ModuleDockingNode>();
                if (mdns.Length > 0)
                {
                    if (topDockModule.model != null)
                    {
                        topDockPartModule = mdns[0];
                    }
                    if (bottomDockModule.model != null)
                    {
                        bottomDockPartModule = mdns.Length > 1 ? mdns[1] : mdns[0];
                    }
                }
                updateDockingModules(start);
            }
            //resources are updated in Start(), to ensure that the dependent modules have loaded
        }
Ejemplo n.º 5
0
        private void initialize(bool start)
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            topNodeNames    = SSTUUtils.parseCSV(topManagedNodes);
            bottomNodeNames = SSTUUtils.parseCSV(bottomManagedNodes);

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            coreModule = new ModelModule <ServiceModuleCoreModel, SSTUModularServiceModule>(part, this, getRootTransform("MSC-CORE", true), ModelOrientation.TOP, nameof(coreModulePersistentData), nameof(currentCore), nameof(currentCoreTexture));
            coreModule.getSymmetryModule = m => m.coreModule;
            coreModule.setupModelList(ModelData.parseModels(node.GetNodes("CORE"), m => new ServiceModuleCoreModel(m)));

            topModule = new ModelModule <SingleModelData, SSTUModularServiceModule>(part, this, getRootTransform("MSC-TOP", true), ModelOrientation.TOP, nameof(topModulePersistentData), nameof(currentTop), nameof(currentTopTexture));
            topModule.getSymmetryModule  = m => m.topModule;
            topModule.getValidSelections = m => topModule.models.FindAll(s => s.canSwitchTo(part, topNodeNames));

            bottomModule = new ModelModule <SingleModelData, SSTUModularServiceModule>(part, this, getRootTransform("MSC-BOTTOM", true), ModelOrientation.BOTTOM, nameof(bottomModulePersistentData), nameof(currentBottom), nameof(currentBottomTexture));
            bottomModule.getSymmetryModule  = m => m.bottomModule;
            bottomModule.getValidSelections = m => bottomModule.models.FindAll(s => s.canSwitchTo(part, bottomNodeNames));

            solarModule = new ModelModule <SolarData, SSTUModularServiceModule>(part, this, getRootTransform("MSC-Solar", true), ModelOrientation.CENTRAL, null, nameof(currentSolar), null);
            solarModule.getSymmetryModule = m => m.solarModule;
            solarModule.setupModelList(ModelData.parseModels(node.GetNodes("SOLAR"), m => new SolarData(m)));
            solarModule.getValidSelections = delegate(IEnumerable <SolarData> all)
            {
                //System.Linq.Enumerable.Where(all, s => s.isAvailable(upgradesApplied));
                float scale = coreModule.model.currentDiameterScale;
                //find all solar panels that are unlocked via upgrades/tech-tree
                List <SolarData> unlocked = solarModule.models.FindAll(s => s.isAvailable(upgradesApplied));
                //filter those to find only the ones available for the current
                List <SolarData> availableByScale = unlocked.FindAll(s => coreModule.model.isValidSolarOption(s.name, scale));
                return(availableByScale);
            };
            solarModule.preModelSetup = delegate(SolarData d)
            {
                d.positions = coreModule.model.getPanelConfiguration(d.name).getScaledPositions(coreModule.model.currentDiameterScale);
            };

            rcsModule = new ModelModule <ServiceModuleRCSModelData, SSTUModularServiceModule>(part, this, getRootTransform("MSC-Rcs", true), ModelOrientation.CENTRAL, null, nameof(currentRCS), null);
            rcsModule.getSymmetryModule = m => m.rcsModule;
            rcsModule.setupModelList(ModelData.parseModels(node.GetNodes("RCS"), m => new ServiceModuleRCSModelData(m)));
            rcsModule.getValidSelections = m => rcsModule.models.FindAll(s => s.isAvailable(upgradesApplied));

            List <ConfigNode> tops    = new List <ConfigNode>();
            List <ConfigNode> bottoms = new List <ConfigNode>();

            ConfigNode[] mNodes = node.GetNodes("CAP");
            ConfigNode   mNode;
            int          len = mNodes.Length;

            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                if (mNode.GetBoolValue("useForTop", true))
                {
                    tops.Add(mNode);
                }
                if (mNode.GetBoolValue("useForBottom", true))
                {
                    bottoms.Add(mNode);
                }
            }
            topModule.setupModelList(SingleModelData.parseModels(tops.ToArray()));
            bottomModule.setupModelList(SingleModelData.parseModels(bottoms.ToArray()));

            tops.Clear();
            bottoms.Clear();
            topModule.setupModel();
            coreModule.setupModel();
            coreModule.model.updateScaleForDiameter(currentDiameter);
            bottomModule.setupModel();
            solarModule.setupModel();
            rcsModule.setupModel();
            rcsModule.model.renameThrustTransforms(rcsThrustTransformName);

            updateModulePositions();
            updateMassAndCost();
            updateAttachNodes(false);
            SSTUStockInterop.updatePartHighlighting(part);
        }
Ejemplo n.º 6
0
        private void initialize(bool start)
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            topNodeNames    = SSTUUtils.parseCSV(topManagedNodes);
            bottomNodeNames = SSTUUtils.parseCSV(bottomManagedNodes);

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            coreModule = new ModelModule <SingleModelData, SSTUModularStationCore>(part, this, getRootTransform("MSC-CORE", true), ModelOrientation.TOP, nameof(coreModulePersistentData), nameof(currentCore), nameof(currentCoreTexture));
            coreModule.getSymmetryModule = m => m.coreModule;
            coreModule.setupModelList(SingleModelData.parseModels(node.GetNodes("CORE")));

            topModule = new ModelModule <SingleModelData, SSTUModularStationCore>(part, this, getRootTransform("MSC-TOP", true), ModelOrientation.TOP, nameof(topModulePersistentData), nameof(currentTop), nameof(currentTopTexture));
            topModule.getSymmetryModule  = m => m.topModule;
            topModule.getValidSelections = m => topModule.models.FindAll(s => s.canSwitchTo(part, topNodeNames));

            bottomModule = new ModelModule <SingleModelData, SSTUModularStationCore>(part, this, getRootTransform("MSC-BOTTOM", true), ModelOrientation.BOTTOM, nameof(bottomModulePersistentData), nameof(currentBottom), nameof(currentBottomTexture));
            bottomModule.getSymmetryModule  = m => m.bottomModule;
            bottomModule.getValidSelections = m => bottomModule.models.FindAll(s => s.canSwitchTo(part, bottomNodeNames));

            solarModule = new ModelModule <SolarData, SSTUModularStationCore>(part, this, getRootTransform("MSC-Solar", true), ModelOrientation.CENTRAL, null, nameof(currentSolar), null);
            solarModule.getSymmetryModule = m => m.solarModule;
            solarModule.setupModelList(SingleModelData.parseModels(node.GetNodes("SOLAR"), m => new SolarData(m)));
            solarModule.getValidSelections = m => solarModule.models.FindAll(s => s.isAvailable(upgradesApplied));

            List <ConfigNode> tops    = new List <ConfigNode>();
            List <ConfigNode> bottoms = new List <ConfigNode>();

            ConfigNode[] mNodes = node.GetNodes("CAP");
            ConfigNode   mNode;
            int          len = mNodes.Length;

            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                if (mNode.GetBoolValue("useForTop", true))
                {
                    tops.Add(mNode);
                }
                if (mNode.GetBoolValue("useForBottom", true))
                {
                    bottoms.Add(mNode);
                }
            }
            topModule.setupModelList(SingleModelData.parseModels(tops.ToArray()));
            bottomModule.setupModelList(SingleModelData.parseModels(bottoms.ToArray()));

            tops.Clear();
            bottoms.Clear();
            topModule.setupModel();
            coreModule.setupModel();//TODO -- only setup core module if not the prefab part -- else need to add transform updating/fx-updating for RCS and engine modules, as they lack proper handling for transform swapping at runtime
            bottomModule.setupModel();
            solarModule.setupModel();

            updateModulePositions();
            updateMassAndCost();
            updateAttachNodes(false);
            SSTUStockInterop.updatePartHighlighting(part);
        }