private void init() { if (initialized) { return; } initialized = true; ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); ConfigNode[] fuelTypeNodes = node.GetNodes("FUELTYPE"); int len = fuelTypeNodes.Length; fuelTypes = new ContainerFuelPreset[len]; for (int i = 0; i < len; i++) { fuelTypes[i] = VolumeContainerLoader.getPreset(fuelTypeNodes[i].GetValue("name")); } fuelType = Array.Find(fuelTypes, m => m.name == currentFuelType); if (fuelType == null && (fuelTypes != null && fuelTypes.Length > 0)) { MonoBehaviour.print("ERROR: SSTUModularRCS - currentFuelType was null for value: " + currentFuelType); fuelType = fuelTypes[0]; currentFuelType = fuelType.name; MonoBehaviour.print("Assigned default fuel type of: " + currentFuelType + ". This is likely a config error that needs to be corrected."); } else if (fuelTypes == null || fuelTypes.Length < 1) { //TODO -- handle cases of disabled fuel switching MonoBehaviour.print("ERROR: SSTUModularRCS - No fuel type definitions found."); } }
private void initialize() { if (initialized) { return; } initialized = true; recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]); ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); string[] names = node.GetStringValues("textureSet"); string[] titles = SSTUUtils.getNames(TexturesUnlimitedLoader.getTextureSets(names), m => m.title); TextureSet currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet); if (currentTextureSetData == null) { currentTextureSet = names[0]; currentTextureSetData = TexturesUnlimitedLoader.getTextureSet(currentTextureSet); initializedColors = false; } if (!initializedColors) { initializedColors = true; recolorHandler.setColorData(currentTextureSetData.maskColors); } this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet); Fields[nameof(currentTextureSet)].guiActiveEditor = names.Length > 1; fuelType = VolumeContainerLoader.getPreset(fuelPreset); Transform modelBase = part.transform.FindRecursive("model"); //Set up the engine models container ConfigNode[] modelNodes = node.GetNodes("MODEL"); engineModelRoot = modelBase.FindOrCreate(engineModelRootName); ModelDefinitionLayoutOptions[] models = SSTUModelData.getModelDefinitions(modelNodes); engineModels = new ModelModule <SSTUInterstageDecoupler>(part, this, engineModelRoot, ModelOrientation.CENTRAL, nameof(currentEngineModel), nameof(currentEngineLayout), nameof(currentEngineTextureSet), nameof(customEngineColorData), null, null, null, null); engineModels.getSymmetryModule = m => m.engineModels; engineModels.getValidOptions = () => models; engineModels.getLayoutPositionScalar = () => currentBottomDiameter * 0.5f; //engineModels.getLayoutScaleScalar = () => currentEngineScale; engineModels.setupModelList(models); engineModels.setupModel(); engineModels.updateSelections(); updateEnginePositionAndScale(); //set up the fairing container minHeight = engineModels.moduleHeight; Transform fairingContainerRoot = modelBase.FindOrCreate(baseTransformName); fairingBase = new FairingContainer(fairingContainerRoot.gameObject, cylinderSides, numberOfPanels, wallThickness); updateEditorFields(); buildFairing(); updateEnginePositionAndScale(); updateFairingTextureSet(false); updateNodePositions(false); updatePartMass(); }
public static void updateRCSFuelType(string fuelType, Part part) { ContainerFuelPreset fuelTypeData = VolumeContainerLoader.getPreset(fuelType); if (fuelTypeData != null) { updateRCSFuelType(fuelTypeData, part); } }
private void initialize() { if (initialized) { return; } initialized = true; recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]); ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); string[] names = TextureSet.getTextureSetNames(textureNodes); string[] titles = TextureSet.getTextureSetTitles(textureNodes); TextureSet currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet); if (currentTextureSetData == null) { currentTextureSet = names[0]; currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet); initializedColors = false; } if (!initializedColors) { initializedColors = true; recolorHandler.setColorData(currentTextureSetData.maskColors); } this.updateUIChooseOptionControl("currentTextureSet", names, titles, true, currentTextureSet); Fields[nameof(currentTextureSet)].guiActiveEditor = textureNodes.Length > 1; fairingMaterial = currentTextureSetData.textureData[0].createMaterial("SSTUFairingMaterial"); fuelType = VolumeContainerLoader.getPreset(fuelPreset); Transform modelBase = part.transform.FindRecursive("model"); setupEngineModels(modelBase, node); minHeight = engineModels.model.modelDefinition.height * getEngineScale(); Transform root = modelBase.FindOrCreate(baseTransformName); Transform collider = modelBase.FindOrCreate("InterstageFairingBaseCollider"); fairingBase = new InterstageDecouplerModel(root.gameObject, collider.gameObject, 0.25f, cylinderSides, numberOfPanels, wallThickness); updateEditorFields(); buildFairing(); updateTextureSet(false); updateNodePositions(false); if (!initializedResources && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)) { initializedResources = true; updateResources(); } updatePartMass(); updateEngineThrust(); }
private void init() { if (initialized) { return; } initialized = true; ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); standoffTransform = part.transform.FindRecursive("model").FindOrCreate("ModularRCSStandoff"); standoffTransform.localRotation = Quaternion.Euler(0, 0, 90);//rotate 90' on z-axis, to face along x+/-; this should put the 'top' of the model at 0,0,0 standoffModule = new ModelModule <SingleModelData, SSTUModularRCS>(part, this, standoffTransform, ModelOrientation.TOP, nameof(structurePersistentData), nameof(currentStructure), nameof(currentStructureTexture)); standoffModule.getSymmetryModule = m => m.standoffModule; standoffModule.setupModelList(ModelData.parseModels <SingleModelData>(node.GetNodes("STRUCTURE"), m => new SingleModelData(m))); standoffModule.setupModel(); if (string.IsNullOrEmpty(modelName)) { MonoBehaviour.print("ERROR: SSTUModularRCS - null/empty modelName in module config."); } modelTransform = part.transform.FindModel(modelName); updateModelScale(); updateMassAndCost(); updateAttachNodes(false); ConfigNode[] fuelTypeNodes = node.GetNodes("FUELTYPE"); int len = fuelTypeNodes.Length; fuelTypes = new ContainerFuelPreset[len]; for (int i = 0; i < len; i++) { fuelTypes[i] = VolumeContainerLoader.getPreset(fuelTypeNodes[i].GetValue("name")); } fuelType = Array.Find(fuelTypes, m => m.name == currentFuelType); if (fuelType == null && (fuelTypes != null && fuelTypes.Length > 0)) { MonoBehaviour.print("ERROR: SSTUModularRCS - currentFuelType was null for value: " + currentFuelType); fuelType = fuelTypes[0]; currentFuelType = fuelType.name; MonoBehaviour.print("Assigned default fuel type of: " + currentFuelType + ". This is likely a config error that needs to be corrected."); } else if (fuelTypes == null || fuelTypes.Length < 1) { //TODO -- handle cases of disabled fuel switching MonoBehaviour.print("ERROR: SSTUModularRCS - No fuel type definitions found."); } }
public FuelTypeISP(ConfigNode node) { fuelPreset = VolumeContainerLoader.getPreset(node.GetStringValue("name")); if (fuelPreset == null) { SSTULog.error("Could not locate fuel preset for name: " + node.GetStringValue("name")); } if (node.HasNode("atmosphereCurve")) { atmosphereCurve = node.GetFloatCurve("atmosphereCurve"); } else { atmosphereCurve = null; } }