Exemplo n.º 1
0
        protected virtual void setMainTankModuleFromEditor(String newMainTank, bool updateSymmetry)
        {
            SingleModelData newModule = Array.Find(mainTankModules, m => m.name == newMainTank);

            currentMainTankModule.destroyCurrentModel();
            currentMainTankModule = newModule;
            currentMainTankModule.setupModel(part, getTankRootTransform(false), ModelOrientation.CENTRAL);
            currentTankType = newModule.name;
            if (!currentMainTankModule.isValidTextureSet(currentTankTexture))
            {
                currentTankTexture = currentMainTankModule.getDefaultTextureSet();
            }
            currentMainTankModule.enableTextureSet(currentTankTexture);
            currentMainTankModule.updateTextureUIControl(this, "currentTankTexture", currentTankTexture);
            updateUIScaleControls();
            updateEditorStats(true);

            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    p.GetComponent <SSTUModularFuelTank>().setMainTankModuleFromEditor(newMainTank, false);
                }
            }
            SSTUStockInterop.fireEditorUpdate();
            SSTUModInterop.onPartGeometryUpdate(part, true);
        }
Exemplo n.º 2
0
 private void setupModel()
 {
     if (!String.IsNullOrEmpty(modelDefinition.modelName))
     {
         Transform       baseTransform = getBaseTransform();
         SingleModelData smd           = new SingleModelData(modelDefinition.name);
         smd.setupModel(baseTransform, ModelOrientation.CENTRAL);
         GameObject model = smd.model;
         model.transform.localScale = new Vector3(scale, scale, scale);
     }
 }
Exemplo n.º 3
0
        private void setBottomDockEditor(string newBottomDock, bool updateSymmetry)
        {
            currentBottomDock = newBottomDock;
            SingleModelData prev = bottomDockModule;

            bottomDockModule.destroyCurrentModel();
            bottomDockModule = SingleModelData.findModel(bottomDockModules, currentBottomDock);
            bottomDockModule.setupModel(getBottomDockRoot(false), ModelOrientation.BOTTOM);
            onModelChanged(prev, bottomDockModule);
            updateDockingModules(true);
            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    p.GetComponent <SSTUModularStationCore>().setBottomDockEditor(newBottomDock, false);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Restore the currently selected modules' models, and restore their current texture-set selection
        /// Removes any existing models from special-named root transforms with no attempt at re-use
        /// </summary>
        private void restoreModels()
        {
            topDockModule.setupModel(getTopDockRoot(true), ModelOrientation.TOP);
            topModule.setupModel(getTopRoot(true), ModelOrientation.TOP);
            coreModule.setupModel(getCoreRoot(false), ModelOrientation.CENTRAL, true);//setup model on prefab part and don't touch it after that
            bottomModule.setupModel(getBottomRoot(true), ModelOrientation.BOTTOM);
            bottomDockModule.setupModel(getBottomDockRoot(true), ModelOrientation.BOTTOM);
            solarModule.enable(getSolarRoot(true), 0);

            topModule.enableTextureSet(currentTopTexture);
            coreModule.enableTextureSet(currentCoreTexture);
            bottomModule.enableTextureSet(currentBottomTexture);

            //control transforms need to exist during part initialization
            //else things will explode if one of those transforms is the reference transform when a vessel is reloaded
            //so create them on prefab and restore on other instances
            if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
            {
                Transform modelRoot = part.transform.FindRecursive("model");

                topDockTransform = new GameObject(topDockName).transform;
                topDockTransform.NestToParent(modelRoot);
                topDockTransform.Rotate(-90, 0, 0, Space.Self);
                topControlTransform = new GameObject(topDockName + "Control").transform;
                topControlTransform.NestToParent(modelRoot);

                bottomDockTransform = new GameObject(bottomDockName).transform;
                bottomDockTransform.NestToParent(modelRoot);
                bottomDockTransform.Rotate(90, 0, 0, Space.Self);
                bottomControlTransform = new GameObject(bottomDockName + "Control").transform;
                bottomControlTransform.NestToParent(modelRoot);
                bottomControlTransform.Rotate(180, 0, 0, Space.Self);
            }
            else
            {
                topDockTransform       = part.transform.FindRecursive(topDockName);
                topControlTransform    = part.transform.FindRecursive(topDockName + "Control");
                bottomDockTransform    = part.transform.FindRecursive(bottomDockName);
                bottomControlTransform = part.transform.FindRecursive(bottomDockName + "Control");
            }
            SSTUStockInterop.updatePartHighlighting(part);
        }
Exemplo n.º 5
0
        private void setBottomEditor(string newBottom, bool updateSymmetry)
        {
            currentBottom = newBottom;
            SingleModelData prev = bottomModule;

            bottomModule.destroyCurrentModel();
            bottomModule = SingleModelData.findModel(bottomModules, currentBottom);
            bottomModule.setupModel(getBottomRoot(false), ModelOrientation.BOTTOM);
            onModelChanged(prev, bottomModule);
            if (!bottomModule.isValidTextureSet(currentBottomTexture))
            {
                currentBottomTexture = bottomModule.getDefaultTextureSet();
            }
            bottomModule.enableTextureSet(currentBottomTexture);
            bottomModule.updateTextureUIControl(this, "currentBottomTexture", currentBottomTexture);
            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    p.GetComponent <SSTUModularStationCore>().setBottomEditor(newBottom, false);
                }
            }
        }
Exemplo n.º 6
0
        private void setCoreEditor(string newCore, bool updateSymmetry)
        {
            currentCore = newCore;
            SingleModelData prev = coreModule;

            coreModule.destroyCurrentModel();
            coreModule = SingleModelData.findModel(coreModules, currentCore);
            coreModule.setupModel(getCoreRoot(false), ModelOrientation.CENTRAL);
            onModelChanged(prev, coreModule);
            if (!coreModule.isValidTextureSet(currentCoreTexture))
            {
                currentCoreTexture = coreModule.getDefaultTextureSet();
            }
            coreModule.enableTextureSet(currentCoreTexture);
            coreModule.updateTextureUIControl(this, "currentCoreTexture", currentCoreTexture);
            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    p.GetComponent <SSTUModularStationCore>().setCoreEditor(newCore, false);
                }
            }
        }
Exemplo n.º 7
0
        private void setTopEditor(string newTop, bool updateSymmetry)
        {
            currentTop = newTop;
            SingleModelData prev = topModule;

            topModule.destroyCurrentModel();
            topModule = SingleModelData.findModel(topModules, currentTop);
            topModule.setupModel(getTopRoot(false), ModelOrientation.TOP);
            onModelChanged(prev, topModule);
            if (!topModule.isValidTextureSet(currentTopTexture))
            {
                currentTopTexture = topModule.getDefaultTextureSet();
            }
            topModule.enableTextureSet(currentTopTexture);
            topModule.updateTextureUIControl(this, "currentTopTexture", currentTopTexture);
            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    p.GetComponent <SSTUModularStationCore>().setTopEditor(newTop, false);
                }
            }
        }
Exemplo n.º 8
0
        private void setMainTankModuleFromEditor(SingleModelData newModule, bool updateSymmetry)
        {
            currentMainTankModule.destroyCurrentModel();
            currentMainTankModule = newModule;
            currentMainTankModule.setupModel(part, part.transform.FindRecursive("model"));
            currentTankType = newModule.name;

            updateEditorStats(true);

            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    SSTUModularFuelTank mft = p.GetComponent<SSTUModularFuelTank>();
                    SingleModelData mt = Array.Find(mft.mainTankModules, t => t.name == newModule.name);
                    mft.setMainTankModuleFromEditor(mt, false);
                }
            }
        }
 private void setTopEditor(string newTop, bool updateSymmetry)
 {
     currentTop = newTop;
     SingleModelData prev = topModule;
     topModule.destroyCurrentModel();
     topModule = SingleModelData.findModel(topModules, currentTop);
     topModule.setupModel(getTopRoot(false), ModelOrientation.TOP);
     onModelChanged(prev, topModule);
     if (!topModule.isValidTextureSet(currentTopTexture))
     {
         currentTopTexture = topModule.getDefaultTextureSet();
     }
     topModule.enableTextureSet(currentTopTexture);
     topModule.updateTextureUIControl(this, "currentTopTexture", currentTopTexture);
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             p.GetComponent<SSTUModularStationCore>().setTopEditor(newTop, false);
         }
     }
 }
Exemplo n.º 10
0
 private void setTopDockEditor(string newDock, bool updateSymmetry)
 {
     currentTopDock = newDock;
     SingleModelData prev = topDockModule;
     topDockModule.destroyCurrentModel();
     topDockModule = SingleModelData.findModel(topDockModules, currentTopDock);
     topDockModule.setupModel(getTopDockRoot(false), ModelOrientation.TOP);
     onModelChanged(prev, topDockModule);
     updateDockingModules(true);
     if (updateSymmetry)
     {
         foreach(Part p in part.symmetryCounterparts)
         {
             p.GetComponent<SSTUModularStationCore>().setTopDockEditor(currentTopDock, false);
         }
     }
 }
Exemplo n.º 11
0
 private void setCoreEditor(string newCore, bool updateSymmetry)
 {
     currentCore = newCore;
     SingleModelData prev = coreModule;
     coreModule.destroyCurrentModel();
     coreModule = SingleModelData.findModel(coreModules, currentCore);
     coreModule.setupModel(getCoreRoot(false), ModelOrientation.CENTRAL);
     onModelChanged(prev, coreModule);
     if (!coreModule.isValidTextureSet(currentCoreTexture))
     {
         currentCoreTexture = coreModule.getDefaultTextureSet();
     }
     coreModule.enableTextureSet(currentCoreTexture);
     coreModule.updateTextureUIControl(this, "currentCoreTexture", currentCoreTexture);
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             p.GetComponent<SSTUModularStationCore>().setCoreEditor(newCore, false);
         }
     }
 }
Exemplo n.º 12
0
 private void setBottomEditor(string newBottom, bool updateSymmetry)
 {
     currentBottom = newBottom;
     SingleModelData prev = bottomModule;
     bottomModule.destroyCurrentModel();
     bottomModule = SingleModelData.findModel(bottomModules, currentBottom);
     bottomModule.setupModel(getBottomRoot(false), ModelOrientation.BOTTOM);
     onModelChanged(prev, bottomModule);
     if (!bottomModule.isValidTextureSet(currentBottomTexture))
     {
         currentBottomTexture = bottomModule.getDefaultTextureSet();
     }
     bottomModule.enableTextureSet(currentBottomTexture);
     bottomModule.updateTextureUIControl(this, "currentBottomTexture", currentBottomTexture);
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             p.GetComponent<SSTUModularStationCore>().setBottomEditor(newBottom, false);
         }
     }
 }
Exemplo n.º 13
0
        private void initialize()
        {
            if (heatCurve == null)
            {
                heatCurve = new FloatCurve();
                heatCurve.Add(0, 0.00002f);  //very minimal initial ablation factor
                heatCurve.Add(50, 0.00005f); //ramp it up fairly quickly though
                heatCurve.Add(150, 0.00015f);
                heatCurve.Add(500, 0.00050f);
                heatCurve.Add(750, 0.00075f);
                heatCurve.Add(1000, 0.00100f);
                heatCurve.Add(2000, 0.00400f);
                heatCurve.Add(3000, 0.00800f);  //generally, things will explode before this point
                heatCurve.Add(10000, 0.05000f); //but just in case, continue the curve up to insane levels
            }
            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;
                }
            }
            useToFluxMultiplier = hsp * ablationEfficiency * dens * ablationMult;
            baseSkinIntMult     = part.skinInternalConductionMult;

            //stand-alone modular heat-shield setup
            if (standAlonePart)
            {
                if (string.IsNullOrEmpty(modelName))
                {
                    MonoBehaviour.print("SEVERE ERROR: SSTUModularHeatShield could has no model specified for part: " + part.name);
                }

                if (!String.IsNullOrEmpty(transformsToRemove))
                {
                    SSTUUtils.removeTransforms(part, SSTUUtils.parseCSV(transformsToRemove));
                }

                shieldTypeNames = SSTUDatabase.getHeatShieldNames();

                ConfigNode modelNode = new ConfigNode("MODEL");
                modelNode.AddValue("name", modelName);
                mainModelData = new SingleModelData(modelNode);
                mainModelData.setupModel(part.transform.FindRecursive("model"), ModelOrientation.CENTRAL, true);
                setModelDiameter(currentDiameter);
                updateAttachNodes(false);
                updateDragCube();
                updateEditorFields();
            }

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] typeNodes = node.GetNodes("SHIELDTYPE");
            int          len       = typeNodes.Length;

            shieldTypeNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                shieldTypeNames[i] = typeNodes[i].GetStringValue("name");
            }
            if (shieldTypeNames.Length == 0)
            {
                shieldTypeNames = new string[] { "Medium" };
            }
            currentShieldTypeData = SSTUDatabase.getHeatShieldType(currentShieldType);
            heatCurve             = currentShieldTypeData.heatCurve;

            updatePartCost();
            if (!initializedResources && (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight))
            {
                updatePartResources();
                initializedResources = true;
            }
        }
Exemplo n.º 14
0
        private void setMainTankModuleFromEditor(SingleModelData newModule, bool updateSymmetry)
        {
            currentMainTankModule.destroyCurrentModel();
            currentMainTankModule = newModule;
            currentMainTankModule.setupModel(part, part.transform.FindRecursive("model"), ModelOrientation.CENTRAL);
            currentTankType = newModule.name;
            if (!currentMainTankModule.isValidTextureSet(currentTankTexture)) { currentTankTexture = currentMainTankModule.modelDefinition.defaultTextureSet; }
            currentMainTankModule.enableTextureSet(currentTankTexture);

            updateEditorStats(true);

            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    SSTUModularFuelTank mft = p.GetComponent<SSTUModularFuelTank>();
                    SingleModelData mt = Array.Find(mft.mainTankModules, t => t.name == newModule.name);
                    mft.setMainTankModuleFromEditor(mt, false);
                }
            }
        }
Exemplo n.º 15
0
        private void initialize()
        {
            if (heatCurve == null)
            {
                heatCurve = new FloatCurve();
                heatCurve.Add(0, 0.00002f);//very minimal initial ablation factor
                heatCurve.Add(50, 0.00005f);//ramp it up fairly quickly though
                heatCurve.Add(150, 0.00015f);
                heatCurve.Add(500, 0.00050f);
                heatCurve.Add(750, 0.00075f);
                heatCurve.Add(1000, 0.00100f);
                heatCurve.Add(2000, 0.00400f);
                heatCurve.Add(3000, 0.00800f);//generally, things will explode before this point
                heatCurve.Add(10000, 0.05000f);//but just in case, continue the curve up to insane levels
            }
            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;
                }
            }
            useToFluxMultiplier = hsp * ablationEfficiency * dens * ablationMult;
            baseSkinIntMult = part.skinInternalConductionMult;

            //stand-alone modular heat-shield setup
            if (standAlonePart)
            {
                if (string.IsNullOrEmpty(modelName))
                {
                    MonoBehaviour.print("SEVERE ERROR: SSTUModularHeatShield could has no model specified for part: " + part.name);
                }

                if (!String.IsNullOrEmpty(transformsToRemove))
                {
                    SSTUUtils.removeTransforms(part, SSTUUtils.parseCSV(transformsToRemove));
                }

                shieldTypeNames = SSTUDatabase.getHeatShieldNames();

                ConfigNode modelNode = new ConfigNode("MODEL");
                modelNode.AddValue("name", modelName);
                mainModelData = new SingleModelData(modelNode);
                mainModelData.setupModel(part.transform.FindRecursive("model"), ModelOrientation.CENTRAL, true);
                setModelDiameter(currentDiameter);
                updateAttachNodes(false);
                updateDragCube();
                updateEditorFields();
            }

            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);
            ConfigNode[] typeNodes = node.GetNodes("SHIELDTYPE");
            int len = typeNodes.Length;
            shieldTypeNames = new string[len];
            for (int i = 0; i < len; i++)
            {
                shieldTypeNames[i] = typeNodes[i].GetStringValue("name");
            }
            if (shieldTypeNames.Length == 0) { shieldTypeNames = new string[] { "Medium" }; }
            currentShieldTypeData = SSTUDatabase.getHeatShieldType(currentShieldType);
            heatCurve = currentShieldTypeData.heatCurve;

            updatePartCost();
            if (!initializedResources && (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight))
            {
                updatePartResources();
                initializedResources = true;
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Loads or builds the models for the currently selected modules.
 /// </summary>
 private void restoreModels()
 {
     currentMainTankModule.setupModel(part, getTankRootTransform(true), ModelOrientation.CENTRAL);
     currentNoseModule.setupModel(part, getNoseRootTransform(true), ModelOrientation.TOP);
     currentMountModule.setupModel(part, getMountRootTransform(true), ModelOrientation.BOTTOM);
 }
Exemplo n.º 17
0
 private void setupModel()
 {
     if (!String.IsNullOrEmpty(modelDefinition.modelName))
     {
         Transform baseTransform = getBaseTransform();
         SingleModelData smd = new SingleModelData(modelDefinition.name);
         smd.setupModel(baseTransform, ModelOrientation.CENTRAL);
         GameObject model = smd.model;
         model.transform.localScale = new Vector3(scale, scale, scale);
     }
 }