Exemple #1
0
        protected virtual void setMainTankModuleFromEditor(String newMainTank, bool updateSymmetry)
        {
            TankModelData newModule = Array.Find(mainTankModules, m => m.name == newMainTank);

            currentMainTankModule.destroyCurrentModel();
            currentMainTankModule = newModule;
            currentMainTankModule.setupModel(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);
            lastSelectedVariant = currentMainTankModule.variantName;
            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    p.GetComponent <SSTUModularFuelTank>().setMainTankModuleFromEditor(newMainTank, false);
                }
            }
            SSTUStockInterop.fireEditorUpdate();
            SSTUModInterop.onPartGeometryUpdate(part, true);
        }
Exemple #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 = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

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

            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);
            }
            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]);
            }

            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));
                }
            }
            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;
            }

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

            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();
            }
        }
 protected virtual void setMainTankModuleFromEditor(String newMainTank, bool updateSymmetry)
 {
     TankModelData newModule = Array.Find(mainTankModules, m => m.name == newMainTank);
     currentMainTankModule.destroyCurrentModel();
     currentMainTankModule = newModule;
     currentMainTankModule.setupModel(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);
     lastSelectedVariant = currentMainTankModule.variantName;
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             p.GetComponent<SSTUModularFuelTank>().setMainTankModuleFromEditor(newMainTank, false);
         }
     }
     SSTUStockInterop.fireEditorUpdate();
     SSTUModInterop.onPartGeometryUpdate(part, true);
 }