예제 #1
0
 //called from the ModuleManagerPostLoad() callback for KSPShaderTools
 public void KSPShaderToolsPostLoad()
 {
     MonoBehaviour.print("Reloading config databases (fuel types, model data, etc...)");
     //FuelTypes.INSTANCE.loadConfigData();
     //VolumeContainerLoader.loadConfigData();//needs to be loaded after fuel types
     ROTModelLayout.load();
     ROTModelData.loadConfigData();
 }
예제 #2
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            prevDiameter = currentDiameter;

            coreNodeNames = ROTUtils.parseCSV(coreManagedNodes);

            //model-module setup/initialization
            ConfigNode node = ROTConfigNodeUtils.parseConfigNode(configNodeData);

            //list of CORE model nodes from config
            //each one may contain multiple 'model=modelDefinitionName' entries
            //but must contain no more than a single 'variant' entry.
            //if no variant is specified, they are added to the 'Default' variant.
            ConfigNode[] coreDefNodes = node.GetNodes("CORE");
            ModelDefinitionLayoutOptions[]      coreDefs;
            List <ModelDefinitionLayoutOptions> coreDefList = new List <ModelDefinitionLayoutOptions>();
            int coreDefLen = coreDefNodes.Length;

            for (int i = 0; i < coreDefLen; i++)
            {
                string variantName = coreDefNodes[i].GetStringValue("variant", "Default");
                coreDefs = ROTModelData.getModelDefinitionLayouts(coreDefNodes[i].GetStringValues("model"));
                coreDefList.AddUniqueRange(coreDefs);
                ModelDefinitionVariantSet mdvs = getVariantSet(variantName);
                mdvs.addModels(coreDefs);
            }
            coreDefs = coreDefList.ToArray();

            coreModule      = new ROTModelModule <ModuleROTProbe>(part, this, getRootTransform("ModularProbe-CORE"), ModelOrientation.CENTRAL, nameof(currentCore), null, nameof(currentCoreTexture), nameof(coreModulePersistentData));
            coreModule.name = "ModularProbe-Core";
            coreModule.getSymmetryModule = m => m.coreModule;
            coreModule.getValidOptions   = () => getVariantSet(currentVariant).definitions;

            coreModule.massScalar   = massScalingPower;
            coreModule.volumeScalar = volumeScalingPower;

            //set up the model lists and load the currently selected model
            coreModule.setupModelList(coreDefs);
            coreModule.setupModel();

            updateModulePositions();
            updateMassAndDimensions();
            updateAttachNodes(false);
            updateAvailableVariants();
            ROTStockInterop.updatePartHighlighting(part);
        }
예제 #3
0
        /// <summary>
        /// Create a group of model definition layout sets.  Loads the model definitions + their supported layout configurations.
        /// </summary>
        /// <param name="nodes"></param>
        /// <returns></returns>
        public static ModelDefinitionLayoutOptions[] getModelDefinitions(ConfigNode[] nodes)
        {
            int len = nodes.Length;

            List <ModelDefinitionLayoutOptions> options = new List <ModelDefinitionLayoutOptions>();
            List <ModelLayoutData> layoutDataList       = new List <ModelLayoutData>();
            ROTModelDefinition     def;

            string[] groupedNames;
            string[] groupedLayouts;
            int      len2;

            for (int i = 0; i < len; i++)
            {
                //because configNode.ToString() reverses the order of values, and model def layouts are always loaded from string-cached config nodes
                //we need to reverse the order of the model and layout names during parsing
                groupedNames   = nodes[i].GetStringValues("model");
                groupedLayouts = nodes[i].GetStringValues("layout", new string[] { "default" });
                len2           = groupedNames.Length;
                for (int k = 0; k < len2; k++)
                {
                    def = ROTModelData.getModelDefinition(groupedNames[k]);
                    layoutDataList.AddRange(ROTModelLayout.findLayouts(groupedLayouts));
                    if (nodes[i].HasValue("position") || nodes[i].HasValue("rotation") || nodes[i].HasValue("scale"))
                    {
                        Vector3           pos    = nodes[i].GetVector3("position", Vector3.zero);
                        Vector3           scale  = nodes[i].GetVector3("scale", Vector3.one);
                        Vector3           rot    = nodes[i].GetVector3("rotation", Vector3.zero);
                        ModelPositionData mpd    = new ModelPositionData(pos, scale, rot);
                        ModelLayoutData   custom = new ModelLayoutData("default", new ModelPositionData[] { mpd });
                        if (layoutDataList.Exists(m => m.name == "default"))
                        {
                            ModelLayoutData del = layoutDataList.Find(m => m.name == "default");
                            layoutDataList.Remove(del);
                        }
                        layoutDataList.Add(custom);
                    }
                    if (def == null)
                    {
                        error("Model definition was null for name: " + groupedNames[k] + ". Skipping definition during loading of part");
                    }
                    else
                    {
                        options.Add(new ModelDefinitionLayoutOptions(def, layoutDataList.ToArray()));
                    }
                    layoutDataList.Clear();
                }
            }
            return(options.ToArray());
        }