private void initialize() { //MonoBehaviour.print("NodeFairingInit: "+fairingCreated+ " :: " +fairingForceDisabled+ " :: "+fairingJettisoned + " :: " +fairingEnabled); if (rendersToRemove != null && rendersToRemove.Length > 0) { ROTUtils.removeTransforms(part, ROTUtils.parseCSV(rendersToRemove)); } loadFairingData(ROTConfigNodeUtils.parseConfigNode(configNodeData)); if (externalUpdateData != null) { updateFromExternalData(externalUpdateData); } if (fairingCreated || (fairingEnabled && !fairingJettisoned && !fairingForceDisabled && string.IsNullOrEmpty(nodeName)))//previously existed, recreate it, or should exist by default values in the config { buildFairing(); if (!string.IsNullOrEmpty(nodeName)) { AttachNode n = part.FindAttachNode(nodeName); if (n != null && n.attachedPart != null) { prevAttachedPart = n.attachedPart; //MonoBehaviour.print("Setting initial attached part to: " + prevAttachedPart); } } } else if (!fairingJettisoned && !fairingForceDisabled && !string.IsNullOrEmpty(nodeName))//else could potentially be activated by a node...check for activation { needsStatusUpdate = true; } updateTextureSet(false); needsGuiUpdate = true; //MonoBehaviour.print("NodeFairingInit End: " + fairingCreated + " :: " + fairingForceDisabled + " :: " + fairingJettisoned + " :: " + fairingEnabled); }
public void loadPersistence(String data) { String[] csv = ROTUtils.parseCSV(data); topY = ROTUtils.safeParseFloat(csv[0]); bottomY = ROTUtils.safeParseFloat(csv[1]); topRadius = ROTUtils.safeParseFloat(csv[2]); bottomRadius = ROTUtils.safeParseFloat(csv[3]); }
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); }
//creates/recreates FairingData instances from data from config node and any persistent node (if applicable) private void loadFairingData(ConfigNode node) { recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]); ConfigNode[] fairingNodes = node.GetNodes("FAIRING"); fairingParts = new ROTNodeFairingData[fairingNodes.Length]; Transform modelBase = part.transform.FindRecursive("model"); Transform parent; ModuleROTNodeFairing[] cs = part.GetComponents <ModuleROTNodeFairing>(); int l = Array.IndexOf(cs, this); int moduleIndex = l; for (int i = 0; i < fairingNodes.Length; i++) { parent = modelBase.FindOrCreate(fairingName + "-" + moduleIndex + "-" + i); fairingParts[i] = new ROTNodeFairingData(); fairingParts[i].load(fairingNodes[i], parent.gameObject); if (fairingParts[i].canAdjustTop) { enableTopDiameterControls = true; if (guiTopDiameter < 0) { guiTopDiameter = fairingParts[i].topRadius * 2f; } else { fairingParts[i].topRadius = guiTopDiameter * 0.5f; } } if (fairingParts[i].canAdjustBottom) { enableBottomDiameterControls = true; if (guiBottomDiameter < 0) { guiBottomDiameter = fairingParts[i].bottomRadius * 2f; } else { fairingParts[i].bottomRadius = guiBottomDiameter * 0.5f; } } } //reload fairing data from persistence; //it -should- already match the guiTopDiameter/guiBottomDiameter (or else was already corrupted/invalid when saved out). if (!String.IsNullOrEmpty(persistentDataString)) { String[] datas = ROTUtils.parseCSV(persistentDataString, ":"); int length = datas.Length; for (int i = 0; i < length; i++) { fairingParts[i].loadPersistence(datas[i]); } } string[] names = node.GetStringValues("textureSet"); string[] titles = ROTUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title); TextureSet t = TexturesUnlimitedLoader.getTextureSet(currentTextureSet); if (t == null) { currentTextureSet = names[0]; t = TexturesUnlimitedLoader.getTextureSet(currentTextureSet); initializedColors = false; } if (!initializedColors) { initializedColors = true; recolorHandler.setColorData(t.maskColors); } this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet); }