private void loadConfigNodeData(ConfigNode node) { ConfigNode[] layoutNodes = node.GetNodes("LAYOUT"); loadEngineLayouts(layoutNodes); if (String.IsNullOrEmpty(currentEngineLayoutName)) { currentEngineLayoutName = engineLayouts[0].layoutName; } currentEngineLayout = Array.Find(engineLayouts, m => m.layoutName == currentEngineLayoutName); if (currentEngineLayout == null) { currentEngineLayout = engineLayouts[0]; currentEngineLayoutName = currentEngineLayout.layoutName; } if (!currentEngineLayout.isValidMount(currentMountName))//catches the case of an uninitilized part and those where mount data has been removed from the config. { currentMountName = currentEngineLayout.defaultMount; currentMountDiameter = currentEngineLayout.getMountData(currentMountName).initialDiameter; currentEngineSpacing = currentEngineLayout.getEngineSpacing(engineScale, currentEngineLayout.getMountData(currentMountName)); editorEngineSpacingAdjust = prevEngineSpacingAdjust = 0f; } currentMountData = currentEngineLayout.getMountData(currentMountName); if (currentMountDiameter > currentMountData.maxDiameter) { currentMountDiameter = currentMountData.maxDiameter; } if (currentMountDiameter < currentMountData.minDiameter) { currentMountDiameter = currentMountData.minDiameter; } }
public float getEngineSpacing(float engineScale, EngineClusterLayoutMountData mount) { if (mount.engineSpacing != -1) { return mount.engineSpacing * engineScale; } return engineSpacing; }
private void updateLayoutFromEditor(String newLayout, bool updateSymmetry) { currentEngineLayoutName = newLayout; currentEngineLayout = Array.Find(engineLayouts, m => m.layoutName == newLayout); if (currentMountName == "Mount-None" && currentEngineLayout.isValidMount(currentMountName)) { //NOOP } else { currentMountName = currentEngineLayout.defaultMount; } bool useModelSelectionGUI = HighLogic.CurrentGame.Parameters.CustomParams<SSTUGameSettings>().useModelSelectGui; Fields["guiMountOption"].guiActiveEditor = !useModelSelectionGUI && currentEngineLayout.mountData.Length > 1; Events["selectMountEvent"].guiActiveEditor = useModelSelectionGUI && currentEngineLayout.mountData.Length > 1; currentMountData = currentEngineLayout.getMountData(currentMountName); currentMountDiameter = currentMountData.initialDiameter; currentEngineSpacing = currentEngineLayout.getEngineSpacing(engineScale, currentMountData) + editorEngineSpacingAdjust; setupMountModel(); updateMountTexture(); positionMountModel(); setupEngineModels(); positionEngineModels(); reInitEngineModule(); updateNodePositions(true); updateDragCubes(); updateEditorFields(); updateMountSizeGuiControl(true, currentMountData.initialDiameter); updateMountOptionsGuiControl(); updateMountTextureOptionsGuiControl(); updatePartCostAndMass(); updateGuiState(); updateFairing(true); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent<SSTUModularEngineCluster>().updateLayoutFromEditor(newLayout, false); } } }
private void updateMountFromEditor(String newMount, bool updateSymmetry) { currentMountName = newMount; currentMountData = currentEngineLayout.getMountData(currentMountName); currentMountDiameter = currentMountData.initialDiameter; setupMountModel(); updateMountTexture(); positionMountModel(); positionEngineModels(); updateNodePositions(true); updateDragCubes(); updateEditorFields(); updateMountOptionsGuiControl(); updateMountSizeGuiControl(true); updateMountTextureOptionsGuiControl(); updatePartCostAndMass(); updateGuiState(); updateFairing(true); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent<SSTUModularEngineCluster>().updateMountFromEditor(newMount, false); } } SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
public float getEngineRotation(EngineClusterLayoutMountData mount, int positionIndex) { float[] vals = mount.rotateEngines.Length > 0 ? mount.rotateEngines : engineRotationOverride; float val = 0; if (vals.Length > 0) { if (vals.Length == 1) { val = vals[0]; } else { val = vals[positionIndex]; } } return val; }