public static onPartGeometryUpdate ( Part part, bool createDefaultCube ) : void | ||
part | Part | |
createDefaultCube | bool | |
return | void |
private void buildFairing() { fairingBase.clearProfile(); UVMap uvs = UVMap.GetUVMapGlobal(uvMap); fairingBase.outsideUV = uvs.getArea("outside"); fairingBase.insideUV = uvs.getArea("inside"); fairingBase.edgesUV = uvs.getArea("edges"); float halfHeight = currentHeight * 0.5f; fairingBase.addRing(-halfHeight, currentBottomDiameter * 0.5f); if (currentTopDiameter != currentBottomDiameter) { fairingBase.addRing(-halfHeight + currentTaperHeight, currentBottomDiameter * 0.5f); } if (currentHeight != currentTaperHeight || currentTopDiameter == currentBottomDiameter) { fairingBase.addRing(halfHeight, currentTopDiameter * 0.5f); } fairingBase.generateColliders = this.generateColliders; fairingBase.generateFairing(); fairingBase.setMaterial(fairingMaterial); fairingBase.setOpacity(HighLogic.LoadedSceneIsEditor && editorTransparency ? 0.25f : 1.0f); updateEnginePositionAndScale(); SSTUModInterop.onPartGeometryUpdate(part, true); SSTUStockInterop.fireEditorUpdate(); }
private void updateModels() { currentMainTankModule.updateModel(); currentNoseModule.updateModel(); currentMountModule.updateModel(); SSTUModInterop.onPartGeometryUpdate(part, true); }
private void buildFairing() { //MonoBehaviour.print("Building Fairing "+guiTopDiameter+" : "+guiBottomDiameter); needsRebuilt = false; fairingCreated = true; int len = fairingParts.Length; if (HighLogic.LoadedSceneIsEditor)//only enforce editor sizing while in the editor; { for (int i = 0; i < len; i++) { //MonoBehaviour.print("pt t/b " + fairingParts[i].topRadius + " : " + fairingParts[i].bottomRadius); if (fairingParts[i].canAdjustTop && canAdjustTop) { fairingParts[i].topRadius = guiTopDiameter * 0.5f; } if (fairingParts[i].canAdjustBottom && canAdjustBottom) { fairingParts[i].bottomRadius = guiBottomDiameter * 0.5f; } //MonoBehaviour.print("pt t/b 2" + fairingParts[i].topRadius + " : " + fairingParts[i].bottomRadius); } } for (int i = 0; i < len; i++) { fairingParts[i].generateColliders = this.generateColliders; fairingParts[i].facesPerCollider = 1; fairingParts[i].numOfSections = (int)Math.Round(numOfSections); fairingParts[i].createFairing(fairingMaterial, editorTransparency ? 0.25f : 1f); } SSTUModInterop.onPartGeometryUpdate(part, true); }
protected virtual void setMainTankModuleFromEditor(String newMainTank, bool updateSymmetry) { TankModelData newModule = Array.Find(mainTankModules, m => m.name == newMainTank); currentMainTankModule.destroyCurrentModel(); currentMainTankModule = newModule; currentMainTankModule.setupModel(getTankRootTransform(false), ModelOrientation.CENTRAL); currentTankType = newModule.name; if (!currentMainTankModule.isValidTextureSet(currentTankTexture)) { currentTankTexture = currentMainTankModule.getDefaultTextureSet(); } currentMainTankModule.enableTextureSet(currentTankTexture); currentMainTankModule.updateTextureUIControl(this, "currentTankTexture", currentTankTexture); updateUIScaleControls(); updateEditorStats(true); lastSelectedVariant = currentMainTankModule.variantName; if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUModularFuelTank>().setMainTankModuleFromEditor(newMainTank, false); } } SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
private void buildFairing() { if (HighLogic.LoadedSceneIsEditor)//only enforce editor sizing while in the editor; { foreach (SSTUNodeFairingData fd in fairingParts) { if (fd.canAdjustTop) { fd.topRadius = guiTopDiameter * 0.5f; } if (fd.canAdjustBottom) { fd.bottomRadius = guiBottomDiameter * 0.5f; } } } foreach (FairingData fd in fairingParts) { fd.generateColliders = generateColliders; fd.facesPerCollider = 1; fd.numOfSections = (int)Math.Round(numOfSections); fd.createFairing(fairingMaterial, editorTransparency? 0.25f : 1f); } SSTUModInterop.onPartGeometryUpdate(part, true); }
protected virtual void setMountModuleFromEditor(String newMountType, bool updateSymmetry) { MountModelData newModule = Array.Find(mountModules, m => m.name == newMountType); currentMountModule.destroyCurrentModel(); currentMountModule = newModule; newModule.setupModel(part, getMountRootTransform(false), ModelOrientation.BOTTOM); currentMountType = newModule.name; if (!currentMountModule.isValidTextureSet(currentMountTexture)) { currentMountTexture = currentMountModule.getDefaultTextureSet(); } currentMountModule.enableTextureSet(currentMountTexture); currentMountModule.updateTextureUIControl(this, "currentMountTexture", currentMountTexture); updateEditorStats(true); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUModularFuelTank>().setMountModuleFromEditor(newMountType, false); } } SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
public void prepModel() { if (model != null) { return; } String transformName = "ProcDecouplerRoot"; Transform modelBase = part.transform.FindRecursive(transformName); if (modelBase != null) { GameObject.DestroyImmediate(modelBase.gameObject); } modelBase = new GameObject(transformName).transform; modelBase.NestToParent(part.transform.FindRecursive("model")); model = new ProceduralCylinderModel(); UVMap uvs = UVMap.GetUVMapGlobal(uvMap); model.outsideUV = uvs.getArea("outside"); model.insideUV = uvs.getArea("inside"); model.topUV = uvs.getArea("top"); model.bottomUV = uvs.getArea("bottom"); setModelParameters(); model.setMaterial(fairingMaterial); model.createModel(); model.setParent(modelBase); updatePhysicalAttributes(); updateDecouplerForce(); SSTUModInterop.onPartGeometryUpdate(part, true); }
/// <summary> /// Apply the scale and position changes to the actual models /// </summary> private void updateModels() { tankModule.model.updateModel(); noseModule.model.updateModel(); mountModule.model.updateModel(); SSTUModInterop.onPartGeometryUpdate(part, true); }
public override void OnStart(StartState state) { base.OnStart(state); initialize(); float max = techLimitMaxDiameter < maxTankDiameter ? techLimitMaxDiameter : maxTankDiameter; string[] names = SSTUUtils.getNames(mainTankModules, m => m.name); this.updateUIChooseOptionControl("currentTankType", names, names, true, currentTankType); this.updateUIFloatEditControl("currentTankDiameter", minTankDiameter, max, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter); updateAvailableVariants(); updateUIScaleControls(); Fields["currentTankDiameter"].uiControlEditor.onFieldChanged = tankDiameterUpdated; Fields["currentTankVerticalScale"].uiControlEditor.onFieldChanged = tankHeightScaleUpdated; Fields["currentTankType"].uiControlEditor.onFieldChanged = tankTypeUpdated; Fields["currentNoseType"].uiControlEditor.onFieldChanged = noseTypeUpdated; Fields["currentMountType"].uiControlEditor.onFieldChanged = mountTypeUpdated; Fields["currentNoseTexture"].uiControlEditor.onFieldChanged = onNoseTextureUpdated; Fields["currentTankTexture"].uiControlEditor.onFieldChanged = onTankTextureUpdated; Fields["currentMountTexture"].uiControlEditor.onFieldChanged = onMountTextureUpdated; Fields["currentTankType"].guiActiveEditor = mainTankModules.Length > 1; Fields["currentNoseType"].guiActiveEditor = noseModules.Length > 1; Fields["currentMountType"].guiActiveEditor = mountModules.Length > 1; SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); if (HighLogic.LoadedSceneIsEditor) { GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified)); } }
public void recreateModel() { setModelParameters(); model.recreateModel(); updatePhysicalAttributes(); updateDecouplerForce(); SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
public void Start() { if (!initializedResources && HighLogic.LoadedSceneIsEditor) { initializedResources = true; updateContainerVolume(); } updateGuiState(); SSTUModInterop.onPartGeometryUpdate(part, true); }
public override void OnStart(StartState state) { base.OnStart(state); initialize(); string[] groupNames = TankSet.getSetNames(tankSets); this.updateUIChooseOptionControl("currentTankSet", groupNames, groupNames, true, currentTankSet); string[] names = currentTankSetModule.getModelNames(); string[] descs = currentTankSetModule.getTankDescriptions(); this.updateUIChooseOptionControl("currentTankType", names, descs, true, currentTankType); if (maxTankDiameter == minTankDiameter) { Fields["currentTankDiameter"].guiActiveEditor = false; } else { this.updateUIFloatEditControl("currentTankDiameter", minTankDiameter, maxTankDiameter, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter); } updateAvailableVariants(); updateUIScaleControls(); currentNoseModule.updateTextureUIControl(this, "currentNoseTexture", currentNoseTexture); currentMainTankModule.updateTextureUIControl(this, "currentTankTexture", currentTankTexture); currentMountModule.updateTextureUIControl(this, "currentMountTexture", currentMountTexture); bool useModelSelectionGUI = HighLogic.CurrentGame.Parameters.CustomParams <SSTUGameSettings>().useModelSelectGui; Events["selectNoseEvent"].guiActiveEditor = useModelSelectionGUI; Events["selectMountEvent"].guiActiveEditor = useModelSelectionGUI; Fields["currentTankDiameter"].uiControlEditor.onFieldChanged = tankDiameterUpdated; Fields["currentTankVerticalScale"].uiControlEditor.onFieldChanged = tankHeightScaleUpdated; Fields["currentTankSet"].uiControlEditor.onFieldChanged = tankSetUpdated; Fields["currentTankType"].uiControlEditor.onFieldChanged = tankTypeUpdated; Fields["currentNoseType"].uiControlEditor.onFieldChanged = noseTypeUpdated; Fields["currentMountType"].uiControlEditor.onFieldChanged = mountTypeUpdated; Fields["currentNoseTexture"].uiControlEditor.onFieldChanged = onNoseTextureUpdated; Fields["currentTankTexture"].uiControlEditor.onFieldChanged = onTankTextureUpdated; Fields["currentMountTexture"].uiControlEditor.onFieldChanged = onMountTextureUpdated; Fields["currentTankSet"].guiActiveEditor = tankSets.Length > 1; Fields["currentTankType"].guiActiveEditor = currentTankSetModule.Length > 1; Fields["currentNoseType"].guiActiveEditor = !useModelSelectionGUI && noseModules.Length > 1; Fields["currentMountType"].guiActiveEditor = !useModelSelectionGUI && mountModules.Length > 1; SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); if (HighLogic.LoadedSceneIsEditor) { GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified)); } }
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.setScale(currentScale); m.models.updateModelMeshes(); m.models.updateSelections(); m.updateMassAndCost(); m.updateAttachNodes(true); SSTUModInterop.updateResourceVolume(m.part); 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.setScale(currentScale); m.models.updateModelMeshes(); m.updateMassAndCost(); m.updateAttachNodes(true); SSTUModInterop.updateResourceVolume(m.part); 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.definition.textureSets.Length > 1; SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
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); }
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; }
/// <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; }
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 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 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); }
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); }
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 }
//standard KSP lifecyle override public override void OnStart(StartState state) { base.OnStart(state); initialize(true); Action <SSTUModularServiceModule> modelChangedAction = delegate(SSTUModularServiceModule m) { m.updateModulePositions(); m.updateMassAndCost(); m.updateAttachNodes(true); m.updateDragCubes(); m.updateResourceVolume(); m.updateFairing(true); m.updateGUI(); SSTUModInterop.onPartGeometryUpdate(m.part, true); }; Fields[nameof(currentDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b) { this.actionWithSymmetry(m => { modelChangedAction(m); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentTop)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { topModule.modelSelected(a, b); this.actionWithSymmetry(modelChangedAction); this.actionWithSymmetry(m => { m.updateAnimationControl(noseAnimationID, topModule.model, noseAnimationLayer); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentCore)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { coreModule.modelSelected(a, b); this.actionWithSymmetry(modelChangedAction); if (!coreModule.model.isValidSolarOption(currentSolar, coreModule.model.currentDiameterScale)) { this.actionWithSymmetry(m => { m.currentSolar = m.coreModule.model.getAvailableSolarVariants(coreModule.model.currentDiameterScale)[0]; m.solarModule.modelSelected(m.currentSolar); modelChangedAction(m); m.updateSolarModules(); }); } this.actionWithSymmetry(m => { m.updateAnimationControl(coreAnimationID, coreModule.model, coreAnimationLayer); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentBottom)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { bottomModule.modelSelected(a, b); this.actionWithSymmetry(modelChangedAction); this.actionWithSymmetry(m => { m.updateAnimationControl(mountAnimationID, bottomModule.model, mountAnimationLayer); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentSolar)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { solarModule.modelSelected(a, b); this.actionWithSymmetry(m => { modelChangedAction(m); m.updateSolarModules(); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentRCS)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { rcsModule.modelSelected(a, b); this.actionWithSymmetry(m => { m.rcsModule.model.renameThrustTransforms(rcsThrustTransformName); modelChangedAction(m); m.updateRCSModule(); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentRCSOffset)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { modelChangedAction(m); }); SSTUStockInterop.fireEditorUpdate(); }; if (maxDiameter == minDiameter) { Fields[nameof(currentDiameter)].guiActiveEditor = false; } else { this.updateUIFloatEditControl(nameof(currentDiameter), minDiameter, maxDiameter, diameterIncrement * 2, diameterIncrement, diameterIncrement * 0.05f, true, currentDiameter); } Fields[nameof(currentTopTexture)].uiControlEditor.onFieldChanged = topModule.textureSetSelected; Fields[nameof(currentCoreTexture)].uiControlEditor.onFieldChanged = coreModule.textureSetSelected; Fields[nameof(currentBottomTexture)].uiControlEditor.onFieldChanged = bottomModule.textureSetSelected; if (HighLogic.LoadedSceneIsEditor) { GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified)); } updateDragCubes(); }
/// <summary> /// OnStart override, does basic startup/init stuff, including building models and registering for editor events /// </summary> /// <param name="state"></param> public override void OnStart(StartState state) { base.OnStart(state); initialize(); this.updateUIFloatEditControl(nameof(currentTankDiameter), minTankDiameter, maxTankDiameter, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter); float diff = maxVScale - minVScale; this.updateUIFloatEditControl(nameof(currentTankHeight), minVScale, maxVScale, diff * 0.2f, diff * 0.05f, diff * 0.001f, true, currentTankHeight); Action <SSTUModularUpperStage> modelChangeAction = m => { m.updateModules(true); m.updateModels(); m.updateTankStats(); m.updateRCSModule(); m.updateContainerVolume(); m.updateGuiState(); }; Fields[nameof(splitTank)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { m.splitTank = splitTank; if (m.splitTank) { m.intertankModule.setupModel(); m.lowerModule.setupModel(); } else { m.intertankModule.model.destroyCurrentModel(); m.lowerModule.model.destroyCurrentModel(); } m.Fields[nameof(currentIntertank)].guiActiveEditor = m.splitTank; m.Fields[nameof(currentLower)].guiActiveEditor = m.splitTank; m.Fields[nameof(currentIntertankTexture)].guiActiveEditor = m.splitTank; m.Fields[nameof(currentLowerTexture)].guiActiveEditor = m.splitTank; modelChangeAction(m); }); }; Fields[nameof(currentNose)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { noseModule.modelSelected(currentNose); this.actionWithSymmetry(modelChangeAction); }; Fields[nameof(currentUpper)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { upperModule.modelSelected(currentUpper); this.actionWithSymmetry(modelChangeAction); }; Fields[nameof(currentIntertank)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { intertankModule.modelSelected(currentIntertank); this.actionWithSymmetry(modelChangeAction); }; Fields[nameof(currentLower)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { lowerModule.modelSelected(currentLower); this.actionWithSymmetry(modelChangeAction); }; Fields[nameof(currentMount)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { mountModule.modelSelected(currentMount); this.actionWithSymmetry(modelChangeAction); }; Fields[nameof(currentRCS)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { rcsModule.modelSelected(currentRCS); this.actionWithSymmetry(m => { MonoBehaviour.print("RCS model updated!"); m.updateRCSModule(); modelChangeAction(m); }); }; Fields[nameof(currentNoseTexture)].uiControlEditor.onFieldChanged = noseModule.textureSetSelected; Fields[nameof(currentUpperTexture)].uiControlEditor.onFieldChanged = upperModule.textureSetSelected; Fields[nameof(currentMountTexture)].uiControlEditor.onFieldChanged = mountModule.textureSetSelected; Fields[nameof(currentIntertankTexture)].uiControlEditor.onFieldChanged = intertankModule.textureSetSelected; Fields[nameof(currentLowerTexture)].uiControlEditor.onFieldChanged = lowerModule.textureSetSelected; Fields[nameof(currentRCSTexture)].uiControlEditor.onFieldChanged = rcsModule.textureSetSelected; Callback <BaseField, System.Object> editorUpdateDelegate = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentTankDiameter = currentTankDiameter; } //else it conflicts with stock slider functionality if (m != this) { m.currentTankHeight = currentTankHeight; } modelChangeAction(m); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentTankDiameter)].uiControlEditor.onFieldChanged = editorUpdateDelegate; Fields[nameof(currentTankHeight)].uiControlEditor.onFieldChanged = editorUpdateDelegate; Fields[nameof(supportPercent)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.supportPercent = supportPercent; } //else it conflicts with stock slider functionality m.updateContainerVolume(); m.updateGuiState(); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentNose)].guiActiveEditor = noseModule.models.Count > 1; Fields[nameof(currentUpper)].guiActiveEditor = upperModule.models.Count > 1; Fields[nameof(currentIntertank)].guiActiveEditor = splitTank && intertankModule.models.Count > 1; Fields[nameof(currentLower)].guiActiveEditor = splitTank && lowerModule.models.Count > 1; Fields[nameof(currentMount)].guiActiveEditor = mountModule.models.Count > 1; Fields[nameof(currentRCS)].guiActiveEditor = rcsModule.models.Count > 1; Fields[nameof(currentIntertankTexture)].guiActiveEditor = splitTank; Fields[nameof(currentLowerTexture)].guiActiveEditor = splitTank; SSTUModInterop.onPartGeometryUpdate(part, true); SSTUStockInterop.fireEditorUpdate(); }
private void updateDragCube() { SSTUModInterop.onPartGeometryUpdate(part, true); SSTUStockInterop.fireEditorUpdate(); }
public override void OnStart(StartState state) { base.OnStart(state); initialize(); string[] groupNames = TankSet.getSetNames(tankSets); this.updateUIChooseOptionControl(nameof(currentTankSet), groupNames, groupNames, true, currentTankSet); string[] names = currentTankSetModule.getModelNames(); string[] descs = currentTankSetModule.getTankDescriptions(); this.updateUIChooseOptionControl(nameof(currentTankType), names, descs, true, currentTankType); if (maxTankDiameter == minTankDiameter) { Fields[nameof(currentTankDiameter)].guiActiveEditor = false; } else { this.updateUIFloatEditControl(nameof(currentTankDiameter), minTankDiameter, maxTankDiameter, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter); } updateAvailableVariants(false); updateUIScaleControls(); Fields[nameof(currentTankDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b) { this.actionWithSymmetry(m => { m.updateEditorStats(true); SSTUAttachNodeUtils.updateSurfaceAttachedChildren(m.part, m.prevTankDiameter, m.currentTankDiameter); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentTankVerticalScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b) { this.actionWithSymmetry(m => { m.updateEditorStats(true); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentTankSet)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b) { this.actionWithSymmetry(m => { TankSet newSet = Array.Find(m.tankSets, s => s.name == m.currentTankSet); m.currentTankSetModule = newSet; string variant = m.lastSelectedVariant; m.currentTankType = newSet.getDefaultModel(m.lastSelectedVariant); m.tankModule.updateSelections(); m.tankModule.modelSelected(m.currentTankType); m.Fields[nameof(m.currentTankType)].guiActiveEditor = newSet.Length > 1; //re-seat this if it was changed in the 'setMainTankModuleFromEditor' method //will allow for user-initiated main-tank changes to still change the 'last variant' but will //persist the variant if the newly selected set did not contain the selected variant //so that it will persist to the next set selection, OR be reseated on the next user-tank selection within the current set if (!m.currentTankSetModule.hasVariant(variant)) { m.lastSelectedVariant = variant; } if (m.variantData != null) { m.updateAvailableVariants(true); } m.updateEditorStats(true); m.updateUIScaleControls(); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentNoseType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b) { noseModule.modelSelected(a, b); this.actionWithSymmetry(m => { m.updateEditorStats(true); m.updateAnimationControl(m.noseAnimationID, m.noseModule.model, 1); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentTankType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b) { tankModule.modelSelected(a, b); this.actionWithSymmetry(m => { if (variantData != null) { m.updateAvailableVariants(true); } m.updateEditorStats(true); m.lastSelectedVariant = tankModule.model.variantName; m.updateAnimationControl(m.bodyAnimationID, m.tankModule.model, 3); m.updateUIScaleControls(); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentMountType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b) { mountModule.modelSelected(a, b); this.actionWithSymmetry(m => { m.updateEditorStats(true); m.updateAnimationControl(m.mountAnimationID, m.mountModule.model, 5); SSTUModInterop.onPartGeometryUpdate(m.part, true); }); SSTUStockInterop.fireEditorUpdate(); }; Fields[nameof(currentNoseTexture)].uiControlEditor.onFieldChanged = noseModule.textureSetSelected; Fields[nameof(currentTankTexture)].uiControlEditor.onFieldChanged = tankModule.textureSetSelected; Fields[nameof(currentMountTexture)].uiControlEditor.onFieldChanged = mountModule.textureSetSelected; Fields[nameof(currentTankSet)].guiActiveEditor = tankSets.Length > 1; Fields[nameof(currentTankType)].guiActiveEditor = currentTankSetModule.Length > 1; Fields[nameof(currentNoseType)].guiActiveEditor = noseModule.models.Count > 1; Fields[nameof(currentMountType)].guiActiveEditor = mountModule.models.Count > 1; SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); if (HighLogic.LoadedSceneIsEditor) { GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified)); } }
private void updateDragCubes() { SSTUModInterop.onPartGeometryUpdate(part, true); }
public override void OnStart(StartState state) { base.OnStart(state); initialize(); this.updateUIFloatEditControl(nameof(currentTopDiameter), minDiameter, maxDiameter, diameterIncrement * 2, diameterIncrement, diameterIncrement * 0.05f, true, currentTopDiameter); this.updateUIFloatEditControl(nameof(currentBottomDiameter), minDiameter, maxDiameter, diameterIncrement * 2, diameterIncrement, diameterIncrement * 0.05f, true, currentBottomDiameter); this.updateUIFloatEditControl(nameof(currentHeight), minHeight, maxHeight, heightIncrement * 2, heightIncrement, heightIncrement * 0.05f, true, currentHeight); this.updateUIFloatEditControl(nameof(currentTaperHeight), minHeight, maxHeight, heightIncrement * 2, heightIncrement, heightIncrement * 0.05f, true, currentTaperHeight); Action <SSTUInterstageDecoupler> rebuild = delegate(SSTUInterstageDecoupler m) { m.updateEditorFields(); m.buildFairing(); m.updateEnginePositionAndScale(); m.updateNodePositions(true); m.updatePartMass(); m.updateShielding(); m.updateDragCubes(); m.updateFairingTextureSet(false); }; Fields[nameof(currentTopDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentTopDiameter = this.currentTopDiameter; } rebuild(m); }); }; Fields[nameof(currentBottomDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentBottomDiameter = this.currentBottomDiameter; } rebuild(m); }); }; Fields[nameof(currentHeight)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentHeight = this.currentHeight; } rebuild(m); }); }; Fields[nameof(currentTaperHeight)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentTaperHeight = this.currentTaperHeight; } rebuild(m); }); }; Fields[nameof(editorTransparency)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.editorTransparency = this.editorTransparency; } m.fairingBase.setOpacity(m.editorTransparency ? 0.25f : 1); }); }; Fields[nameof(generateColliders)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.generateColliders = this.generateColliders; } if (m.fairingBase.generateColliders != m.generateColliders) { m.fairingBase.generateColliders = m.generateColliders; m.buildFairing(); m.updateFairingTextureSet(false); } }); }; Fields[nameof(currentTextureSet)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { m.currentTextureSet = currentTextureSet; m.updateFairingTextureSet(!SSTUGameSettings.persistRecolor()); }); }; Fields[nameof(currentEngineModel)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { engineModels.modelSelected(a, b); this.actionWithSymmetry(m => { //model selected action sets vars on symmetry parts rebuild(m); m.reInitEngineModule(); SSTUModInterop.updateResourceVolume(m.part); }); }; Fields[nameof(currentEngineScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { this.actionWithSymmetry(m => { if (m != this) { m.currentEngineScale = this.currentEngineScale; } rebuild(m); SSTUModInterop.updateResourceVolume(m.part); }); }; Fields[nameof(currentEngineLayout)].uiControlEditor.onFieldChanged = delegate(BaseField a, System.Object b) { engineModels.layoutSelected(a, b); this.actionWithSymmetry(m => { m.reInitEngineModule(); m.updatePartMass(); m.updateDragCubes(); SSTUModInterop.updateResourceVolume(m.part); }); }; Fields[nameof(currentEngineTextureSet)].uiControlEditor.onFieldChanged = engineModels.textureSetSelected; Fields[nameof(currentEngineTextureSet)].guiActiveEditor = engineModels.definition.textureSets.Length > 1; GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorShipModified)); SSTUModInterop.onPartGeometryUpdate(part, true); SSTUModInterop.updateResourceVolume(part); }