/// <summary> /// Updates part highlight renderer list, sends message to ModuleROTFlagDecal to update its renderer, /// sends message to FAR to update voxels, or if createDefaultCube==true will re-render the 'default' stock drag cube for the part<para/> /// Should be called anytime the model geometry in a part is changed -- either models added/deleted, procedural meshes updated. Other methods exist for pure drag-cube updating in ROTStockInterop. /// </summary> /// <param name="part"></param> /// <param name="createDefaultCube"></param> public static void onPartGeometryUpdate(Part part, bool createDefaultCube) { if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } //noop on prefabs //MonoBehaviour.print(System.Environment.StackTrace); ROTStockInterop.updatePartHighlighting(part); part.airlock = locateAirlock(part); partGeometryUpdate(part); if (isFARInstalled()) { ROTStockInterop.addFarUpdatePart(part); //FARdebug(part); //part.SendMessage("GeometryPartModuleRebuildMeshData"); } else if (createDefaultCube && (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)) { ROTStockInterop.addDragUpdatePart(part); } if (HighLogic.LoadedSceneIsEditor && part.parent == null && part != EditorLogic.RootPart) //likely the part under the cursor; this fixes problems with modular parts not wanting to attach to stuff { part.gameObject.SetLayerRecursive(1, 2097152); //1<<21 = Part Triggers get skipped by the relayering (hatches, ladders, ??) } }
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); }