Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Update the current fairing modules (top, centra, and bottom) for the current model-module configuration (diameters, positions).
 /// </summary>
 /// <param name="userInput"></param>
 private void updateFairing(bool userInput)
 {
     ModuleROTNodeFairing[] modules = part.GetComponents <ModuleROTNodeFairing>();
     if (centralFairingIndex >= 0 && centralFairingIndex < modules.Length)
     {
         bool enabled = coreModule.fairingEnabled;
         ModuleROTNodeFairing coreFairing = modules[centralFairingIndex];
         float top = coreModule.fairingTop;
         float bot = coreModule.fairingBottom;
         ROTFairingUpdateData data = new ROTFairingUpdateData();
         data.setTopY(top);
         data.setTopRadius(currentDiameter * 0.5f);
         data.setBottomY(bot);
         data.setBottomRadius(currentDiameter * 0.5f);
         data.setEnable(enabled);
         coreFairing.updateExternal(data);
     }
     if (topFairingIndex >= 0 && topFairingIndex < modules.Length)
     {
         ROTModelModule <ModuleROTank> moduleForUpperFiaring = getUpperFairingModelModule();
         bool enabled = moduleForUpperFiaring.fairingEnabled;
         ModuleROTNodeFairing topFairing = modules[topFairingIndex];
         float topFairingBottomY         = moduleForUpperFiaring.fairingBottom;
         ROTFairingUpdateData data       = new ROTFairingUpdateData();
         data.setTopY(getPartTopY());
         data.setBottomY(topFairingBottomY);
         data.setBottomRadius(currentDiameter * 0.5f);
         data.setEnable(enabled);
         if (userInput)
         {
             data.setTopRadius(currentDiameter * 0.5f);
         }
         topFairing.updateExternal(data);
     }
     if (bottomFairingIndex >= 0 && bottomFairingIndex < modules.Length)
     {
         ROTModelModule <ModuleROTank> moduleForLowerFairing = getLowerFairingModelModule();
         bool enabled = moduleForLowerFairing.fairingEnabled;
         ModuleROTNodeFairing bottomFairing = modules[bottomFairingIndex];
         float bottomFairingTopY            = moduleForLowerFairing.fairingTop;
         ROTFairingUpdateData data          = new ROTFairingUpdateData();
         data.setTopRadius(currentDiameter * 0.5f);
         data.setTopY(bottomFairingTopY);
         data.setEnable(enabled);
         if (userInput)
         {
             data.setBottomRadius(currentDiameter * 0.5f);
         }
         bottomFairing.updateExternal(data);
     }
 }