private void updateResourceAmounts(float mult) { SSTUVolumeContainer vc = part.GetComponent <SSTUVolumeContainer>(); if (vc != null) { vc.inflationMultiplier = mult; } //std call that will update volume container and/or realfuels interop SSTUModInterop.updateResourceVolume(part); }
public override void OnStart(StartState state) { base.OnStart(state); init(); Action <SSTUModularRCS> modelChangeAction = delegate(SSTUModularRCS m) { m.updateModelScale(); m.updateAttachNodes(true); m.updateMassAndCost(); SSTUModInterop.updateResourceVolume(m.part); SSTUModInterop.onPartGeometryUpdate(m.part, true); }; Fields[nameof(currentModel)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { rcsBlockModule.modelSelected(a, b); this.actionWithSymmetry(m => { modelChangeAction(m); m.updateRCSThrust(); }); }; Fields[nameof(currentStructure)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { standoffModule.modelSelected(a, b); this.actionWithSymmetry(m => { modelChangeAction(m); }); }; Fields[nameof(currentScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentScale = currentScale; } modelChangeAction(m); m.updateRCSThrust(); }); }; Fields[nameof(currentTexture)].uiControlEditor.onFieldChanged = rcsBlockModule.textureSetSelected; Fields[nameof(currentStructureTexture)].uiControlEditor.onFieldChanged = standoffModule.textureSetSelected; Fields[nameof(currentScale)].guiActiveEditor = allowRescale; SSTUModInterop.updateResourceVolume(part); SSTUModInterop.onPartGeometryUpdate(part, true); }
private void updateResourceVolume() { float volume = coreModule.moduleVolume; if (useAdapterVolume) { volume += topModule.moduleVolume; volume += bottomModule.moduleVolume; } SSTUModInterop.onPartFuelVolumeUpdate(part, volume * 1000f); }
/// <summary> /// Actually set the resources from this list to the input part; if the current part resources match this list exactly they will be updated in-place, /// else all resources from the part will be cleared and the new list of resources added. /// </summary> /// <param name="part"></param> /// <param name="fill"></param> public void setResourcesToPart(Part part, float modifier, bool keepExisting) { removeUnusedResources(part); int len = resourceList.Count; foreach (ResourceListEntry rle in resourceList.Values) { rle.applyToPart(part, modifier, keepExisting); } SSTUModInterop.updatePartResourceDisplay(part); }
private void updateResources() { float scale = Mathf.Pow(getEngineScale(), thrustScalePower); float volume = resourceVolume * scale * engineModels.model.numberOfEngines; if (!SSTUModInterop.onPartFuelVolumeUpdate(part, volume * 1000)) { SSTUResourceList resources = new SSTUResourceList(); fuelType.addResources(resources, volume); resources.setResourcesToPart(part); } }
private void updateFairingTextureSet(bool useDefaults) { TextureSet s = TexturesUnlimitedLoader.getTextureSet(currentTextureSet); RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors("Decoupler"); fairingBase.enableTextureSet(currentTextureSet, colors); if (useDefaults) { recolorHandler.setColorData(colors); } SSTUModInterop.onPartTextureUpdated(part); }
public void setResourcesToPart(Part part, float modifier, bool keepExisting, string[] blacklist) { removeUnusedResources(part, blacklist); int len = resourceList.Count; foreach (ResourceListEntry rle in resourceList.Values) { rle.applyToPart(part, modifier, keepExisting); } SSTUModInterop.updatePartResourceDisplay(part); //GameEvents.onPartResourceListChange.Fire(part); }
private void updateTextureSet(bool useDefaults) { TextureSet s = KSPShaderLoader.getTextureSet(currentTextureSet); RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty); model.enableTextureSet(currentTextureSet, colors); if (useDefaults) { recolorHandler.setColorData(colors); } SSTUModInterop.onPartTextureUpdated(part); }
public void Start() { if (!initializedResources && HighLogic.LoadedSceneIsEditor) { initializedResources = true; updateContainerVolume(); } updateAnimationControl(noseAnimationID, noseModule.model, 1); updateAnimationControl(bodyAnimationID, tankModule.model, 3); updateAnimationControl(mountAnimationID, mountModule.model, 5); SSTUModInterop.onPartGeometryUpdate(part, true); }
public override void OnStart(StartState state) { base.OnStart(state); init(); Fields[nameof(currentStructure)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { standoffModule.modelSelected(a, b); this.actionWithSymmetry(m => { m.updateModelScale(); m.updateAttachNodes(true); m.updateMassAndCost(); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); }; Fields[nameof(currentScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentScale = currentScale; } m.updateModelScale(); m.updateRCSThrust(); m.updateAttachNodes(true); m.updateMassAndCost(); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); }; Fields[nameof(currentFuelType)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentFuelType = currentFuelType; } m.fuelType = Array.Find(m.fuelTypes, s => s.name == m.currentFuelType); m.updateRCSFuelType(); }); }; Fields[nameof(currentFuelType)].guiActiveEditor = updateFuel && fuelTypes.Length > 1; string[] names = SSTUUtils.getNames(fuelTypes, m => m.name); this.updateUIChooseOptionControl(nameof(currentFuelType), names, names, true, currentFuelType); Fields[nameof(currentScale)].guiActiveEditor = scaleGUIActive; }
public override void OnStart(StartState state) { base.OnStart(state); initialize(); Fields[nameof(currentModel)].guiName = uiLabel; Fields[nameof(currentModel)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { models.modelSelected(a, b); this.actionWithSymmetry(m => { m.models.model.updateScale(currentScale); m.models.updateModel(); m.updateMassAndCost(); m.updateAttachNodes(true); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentScale)].guiActiveEditor = canAdjustScale; UI_FloatEdit fe = (UI_FloatEdit)Fields[nameof(currentScale)].uiControlEditor; if (fe != null) { fe.minValue = minScale; fe.maxValue = maxScale; fe.incrementLarge = incScaleLarge; fe.incrementSmall = incScaleSmall; fe.incrementSlide = incScaleSlide; } Fields[nameof(currentScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { m.models.model.updateScale(currentScale); m.models.updateModel(); m.updateMassAndCost(); m.updateAttachNodes(true); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentTexture)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { models.textureSetSelected(a, b); }; Fields[nameof(currentTexture)].guiActiveEditor = models.model.modelDefinition.textureSets.Length > 1; SSTUStockInterop.fireEditorUpdate(); }
/// <summary> /// Update the resources for the part from the resources in the currently configured containers /// </summary> private void updateTankResources() { SSTUResourceList list = new SSTUResourceList(); int len = containers.Length; for (int i = 0; i < len; i++) { containers[i].getResources(list); } list.setResourcesToPart(part, inflationMultiplier, HighLogic.LoadedSceneIsFlight); updateMassAndCost(); SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onContainerUpdated(this); }
private void updateResourceAmounts(float mult) { SSTUVolumeContainer vc = part.GetComponent <SSTUVolumeContainer>(); if (vc != null) { vc.inflationMultiplier = mult; vc.recalcVolume(); } else { SSTUModInterop.updateResourceVolume(part);//call out to RF to update volume; it will obviously lack the inflation multiplier data } }
/// <summary> /// Update the resources for the part from the resources in the currently configured containers /// </summary> private void updateTankResources() { SSTUResourceList list = new SSTUResourceList(); int len = containers.Length; for (int i = 0; i < len; i++) { containers[i].getResources(list); } list.setResourcesToPart(part); updateMassAndCost(); SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onContainerUpdated(this); }
/// <summary> /// Updates models from module current parameters for scale and positioning /// </summary> private void updateModels() { noseModule.model.updateModel(); upperModule.model.updateModel(); if (splitTank) { intertankModule.model.updateModel(); lowerModule.model.updateModel(); } mountModule.model.updateModel(); rcsModule.model.updateModel(); rcsModule.model.renameThrustTransforms(rcsThrustTransformName); SSTUModInterop.onPartGeometryUpdate(part, true); }
private void initialize() { if (initialized) { return; } initialized = true; double hsp = 1; double dens = 1; PartResourceDefinition resource = PartResourceLibrary.Instance.GetDefinition(resourceName); hsp = resource.specificHeatCapacity; dens = resource.density; fluxPerResourceUnit = hsp * ablationEfficiency * dens; baseSkinIntMult = part.skinInternalConductionMult; baseCondMult = part.heatConductivity; ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); Transform mhsRoot = part.transform.FindRecursive("model").FindOrCreate("SSTU-MHS-Root"); ConfigNode[] modelNodes = node.GetNodes("MODELS"); ModelDefinitionLayoutOptions[] models = SSTUModelData.getModelDefinitions(modelNodes); model = new ModelModule <SSTUModularHeatShield>(part, this, mhsRoot, ModelOrientation.CENTRAL, nameof(currentShieldModel), null, nameof(currentShieldTexture), nameof(modelPersistentData), null, null, null, null); model.getSymmetryModule = (m) => m.model; model.setupModelList(models); model.setupModel(); model.setScaleForDiameter(currentDiameter); model.setPosition(0); model.updateModelMeshes(); model.updateSelections(); model.volumeScalar = resourceScalePower; model.massScalar = resourceScalePower; if (standAlonePart) { updateDragCube(); updateAttachNodes(false); } SSTUModInterop.updateResourceVolume(part); ConfigNode[] typeNodes = node.GetNodes("SHIELDTYPE"); shieldTypeData = HeatShieldTypeData.load(typeNodes); currentShieldTypeData = Array.Find(shieldTypeData, m => m.baseType.name == currentShieldType); updateModuleStats(); updatePartCost(); SSTUModInterop.onPartGeometryUpdate(part, false); SSTUModInterop.updateResourceVolume(part); SSTUStockInterop.fireEditorUpdate();//update for mass/cost/etc. }
public void destroyFairing() { //MonoBehaviour.print("Destroying Fairing"); int len = fairingParts.Length; for (int i = 0; i < len; i++) { fairingParts[i].destroyFairing(); } if (fairingCreated) { SSTUModInterop.onPartGeometryUpdate(part, true); } fairingCreated = false; }
/// <summary> /// Actually set the resources from this list to the input part; if the current part resources match this list exactly they will be updated in-place, /// else all resources from the part will be cleared and the new list of resources added. /// </summary> /// <param name="part"></param> /// <param name="fill"></param> public void setResourcesToPart(Part part) { int len = part.Resources.Count; if (len == resourceList.Count)//potentially the same resources exist as we are trying to setup { bool foundAll = true; foreach (String name in resourceList.Keys) { ResourceListEntry entry = resourceList[name]; if (part.Resources.Contains(name))//go ahead and set them as found; if not all are found we'll delete them anyway... { PartResource pr = part.Resources[name]; pr.maxAmount = entry.max; pr.amount = entry.fill; } else { foundAll = false; break; } } if (foundAll) { SSTUModInterop.updatePartResourceDisplay(part); return; } } part.Resources.list.Clear(); PartResource[] resources = part.GetComponents <PartResource>(); len = resources.Length; for (int i = 0; i < len; i++) { GameObject.Destroy(resources[i]); } ConfigNode resourceNode; foreach (String name in resourceList.Keys) { ResourceListEntry entry = resourceList[name]; resourceNode = new ConfigNode("RESOURCE"); resourceNode.AddValue("name", name); resourceNode.AddValue("maxAmount", entry.max); resourceNode.AddValue("amount", entry.fill); part.AddResource(resourceNode); } SSTUModInterop.updatePartResourceDisplay(part); }
private void setTankScaleFromEditor(float editorScaleValue, bool updateSymmetry) { currentTankVerticalScale = editorScaleValue; restoreEditorFields(); updateEditorStats(true); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUModularFuelTank>().setTankScaleFromEditor(editorScaleValue, false); } } SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
private void updateTextureSet(bool useDefaults) { TextureSet s = KSPShaderLoader.getTextureSet(currentTextureSet); RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty); int len = fairingParts.Length; for (int i = 0; i < len; i++) { fairingParts[i].fairingBase.enableTextureSet(currentTextureSet, colors); } if (useDefaults) { recolorHandler.setColorData(colors); } updateOpacity(); SSTUModInterop.onPartTextureUpdated(part); }
private void jettisonFairing() { renderingJettisonedFairing = true; if (numOfSections == 1 && prevAttachedPart != null) { reparentFairing(prevAttachedPart); } else { foreach (SSTUNodeFairingData data in fairingParts) { data.jettisonPanels(part); } } fairingJettisoned = true; currentlyEnabled = false; SSTUModInterop.onPartGeometryUpdate(part, true); }
public void Start() { if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) { if (!initializedFairing) { initializedFairing = true; updateFairing(); } } if (!initializedResources && HighLogic.LoadedSceneIsEditor) { initializedResources = true; updateContainerVolume(); } updateGuiState(); SSTUModInterop.onPartGeometryUpdate(part, true); }
private void rebuildFairing(bool userInput) { Transform model = part.transform.FindModel(modelName); if (model != null) { float scale = getCurrentScale(); model.transform.localScale = new Vector3(scale, scale, scale); } createPanels(); updateFairingMassAndCost(); updateNodePositions(userInput); updateShieldStatus(); enableEditorColliders(HighLogic.LoadedSceneIsEditor); setPanelRotations(HighLogic.LoadedSceneIsEditor && editorDeployed? deployedRotation : currentRotation); SSTUModInterop.onPartGeometryUpdate(part, false); recreateDragCubes(); }
private void setTankDiameterFromEditor(float newDiameter, bool updateSymmetry) { float oldDiameter = prevTankDiameter; currentTankDiameter = newDiameter; restoreEditorFields(); updateEditorStats(true); SSTUAttachNodeUtils.updateSurfaceAttachedChildren(part, oldDiameter, newDiameter); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUModularFuelTank>().setTankDiameterFromEditor(newDiameter, false); } } SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
/// <summary> /// Updates the min/max quantities of resource in the part based on the current 'totalFuelVolume' field and currently set fuel type /// </summary> private void updateContainerVolume() { SSTUVolumeContainer vc = part.GetComponent <SSTUVolumeContainer>(); if (vc != null) { float tankPercent = 100 - supportPercent; float monoPercent = supportPercent; float[] pcts = new float[2]; pcts[0] = tankPercent * 0.01f; pcts[1] = monoPercent * 0.01f; vc.setContainerPercents(pcts, totalTankVolume * 1000f); } else { //real-fuels handling.... SSTUModInterop.onPartFuelVolumeUpdate(part, totalTankVolume * 1000f); } }
/// <summary> /// Update the resources for the part from the resources in the currently configured containers /// </summary> private void updateTankResources() { SSTUResourceList list = new SSTUResourceList(); int len = containers.Length; for (int i = 0; i < len; i++) { containers[i].getResources(list); } list.setResourcesToPart(part, inflationMultiplier, HighLogic.LoadedSceneIsFlight, blacklistedResources); updateMassAndCost(); SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onContainerUpdated(this); SSTUResourceBoiloff rb = part.GetComponent <SSTUResourceBoiloff>(); if (rb != null) { rb.onPartResourcesChanged(); } }
private void updatePartResources() { if (heatSoak) { return; } //dont touch resources on heat-soak type setups float scale = Mathf.Pow(getScale(), resourceScalePower); float amount = baseResourceQuantity * scale * currentShieldTypeData.resourceMult; PartResource res = part.Resources[resourceName]; if (res == null) { MonoBehaviour.print("SEVERE ERROR: ModularHeatShield could not set resource, as no resource was found in part for name: " + resourceName); } else { res.amount = res.maxAmount = amount; } SSTUModInterop.updatePartResourceDisplay(part); }
private void jettisonFairing() { //MonoBehaviour.print("Jettisoning fairing - prev: "+prevAttachedPart); if (numOfSections == 1 && prevAttachedPart != null) { //MonoBehaviour.print("Reparenting fairing to: " + prevAttachedPart); reparentFairing(prevAttachedPart); SSTUModInterop.onPartGeometryUpdate(prevAttachedPart, true);//update other parts highlight renderers, to add the new fairing bits to it. } else { //MonoBehaviour.print("Jettisoning Panels: " + fairingParts.Length); foreach (SSTUNodeFairingData data in fairingParts) { data.jettisonPanels(part); } } prevAttachedPart = null; fairingJettisoned = true; fairingEnabled = false; destroyFairing();//cleanup any leftover bits in fairing containers }
/// <summary> /// Updates the associated VolumeContainer with any changes to part volume from this module /// </summary> private void updateContainerVolume() { float liters = calcTotalVolume(); SSTUVolumeContainer container = part.GetComponent <SSTUVolumeContainer>(); if (container == null) { SSTUModInterop.onPartFuelVolumeUpdate(part, liters); return; } int len = container.numberOfContainers; float[] percents = new float[len]; float total = liters; float val; for (int i = 0; i < len; i++) { val = calcVolume(i); percents[i] = val / total; } container.setContainerPercents(percents, total); }
private void updateContainerVolume() { SSTUModInterop.onPartFuelVolumeUpdate(part, currentTankVolume * 1000f); }