private void initialize() { if (rendersToRemove != null && rendersToRemove.Length > 0) { SSTUUtils.removeTransforms(part, SSTUUtils.parseCSV(rendersToRemove)); } loadFairingData(SSTUStockInterop.getPartModuleConfig(part, this)); if (externalUpdateData != null) { updateFromExternalData(externalUpdateData); } updateEditorFields(false); //update cached editor gui field values for diameter, sections, etc. buildFairing(); //construct fairing from cached/persistent/default data needsStatusUpdate = true; if (textureSets != null) { if (textureSets.Length <= 1)//only a single, (or no) texture set selected/avaialable { Events["nextTextureEvent"].active = false; } if (textureSets.Length > 0 && String.IsNullOrEmpty(currentTextureSet)) { TextureSet s = textureSets[0]; currentTextureSet = textureSets[0].setName; } } }
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 LateUpdate() { //MonoBehaviour.print("Checking late update1: " + needsStatusUpdate + " :: " + needsRebuilt); if (externalUpdateData != null) { updateFromExternalData(externalUpdateData); } //MonoBehaviour.print("Checking late update2: " + needsStatusUpdate + " :: " + needsRebuilt); if (needsStatusUpdate) { updateFairingStatus(); } //MonoBehaviour.print("Checking late update3: " + needsStatusUpdate + " :: " + needsRebuilt); if (needsRebuilt) { rebuildFairing(); updatePersistentDataString(); SSTUStockInterop.fireEditorUpdate(); needsGuiUpdate = true; needsRebuilt = false; } if (needsGuiUpdate) { updateGuiState(); needsGuiUpdate = false; } if (HighLogic.LoadedSceneIsEditor && fairingParts != null) { updateOpacity(); } }
private void initialize() { meshes = part.transform.FindChildren(decalMeshName); ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this); ConfigNode[] decalNodes = node.GetNodes("DECAL"); int len = decalNodes.Length; possibleDecals = new SSTUDecal[len]; for (int i = 0; i < len; i++) { possibleDecals[i] = new SSTUDecal(decalNodes[i]); } SSTUDecal currentDecalObj = Array.Find(possibleDecals, m => m.name == currentDecal); if (currentDecalObj == null && len > 0) { currentDecalObj = possibleDecals[0]; currentDecal = currentDecalObj.name; } else if (currentDecalObj == null) { MonoBehaviour.print("ERROR: NO decals found to load for part: " + part.name); } foreach (Transform mesh in meshes) { currentDecalObj.enable(mesh); } }
public override void OnStart(StartState state) { base.OnStart(state); mpf = part.GetComponent <ModuleProceduralFairing>(); ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this); textureSets = TextureSet.loadTextureSets(node.GetNodes("TEXTURESET")); int len = textureSets.Length; string[] textureSetNames = new string[len]; for (int i = 0; i < len; i++) { textureSetNames[i] = textureSets[i].setName; } this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet); techLimitMaxDiameter = SSTUStockInterop.getTechLimit(techLimitSet); if (currentDiameter > techLimitMaxDiameter) { currentDiameter = techLimitMaxDiameter; } updateModelScale(); updateTexture(currentTextureSet); updateNodePositions(false); float max = techLimitMaxDiameter < maxDiameter ? techLimitMaxDiameter : maxDiameter; this.updateUIFloatEditControl("currentDiameter", minDiameter, max, diameterIncrement * 2f, diameterIncrement, diameterIncrement * 0.05f, true, currentDiameter); Fields["currentDiameter"].uiControlEditor.onFieldChanged = onDiameterUpdated; Fields["currentTextureSet"].uiControlEditor.onFieldChanged = onTextureUpdated; Fields["currentTextureSet"].guiActiveEditor = textureSets.Length > 1; updateEditorFields(); }
public void setContainerPercents(float[] percents, float totalVolume) { int len = containers.Length; if (len != percents.Length) { throw new IndexOutOfRangeException("Input container percents length does not match containers length: " + percents.Length + " : " + len); } float total = 0; for (int i = 0; i < len - 1; i++) { total += percents[i]; containers[i].setContainerPercent(percents[i]); } if (total > 1) { throw new InvalidOperationException("Input percents total > 1"); } containers[len - 1].setContainerPercent(1.0f - total); volume = totalVolume; updateContainerVolumes(); updateMassAndCost(); updateTankResources(); updateFuelSelections(); updatePersistentData(); SSTUStockInterop.fireEditorUpdate(); }
private void setDiameterFromEditor(float newDiameter, bool updateSymmetry) { if (newDiameter > maxDiameter) { newDiameter = maxDiameter; } if (newDiameter < minDiameter) { newDiameter = minDiameter; } currentDiameter = newDiameter; updateModelScale(); updateDragCubes(); updatePartCost(); updatePartMass(); if (updateSymmetry) { if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUWeldingDockingPort>().setDiameterFromEditor(newDiameter, false); } } SSTUStockInterop.fireEditorUpdate(); } }
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(); }
/// <summary> /// Updates part highlight renderer list, sends message to SSTUFlagDecal to update its renderer, /// sends message to FAR to update voxels, or if createDefaultCube==true will re-render the 'default' stock drag cube for the part<para/> /// Should be called anytime the model geometry in a part is changed -- either models added/deleted, procedural meshes updated. Other methods exist for pure drag-cube updating in SSTUStockInterop. /// </summary> /// <param name="part"></param> /// <param name="createDefaultCube"></param> public static void onPartGeometryUpdate(Part part, bool createDefaultCube) { if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } //noop on prefabs //MonoBehaviour.print(System.Environment.StackTrace); SSTUStockInterop.updatePartHighlighting(part); part.airlock = locateAirlock(part); partGeometryUpdate(part); if (isFARInstalled()) { SSTUStockInterop.addFarUpdatePart(part); //FARdebug(part); //part.SendMessage("GeometryPartModuleRebuildMeshData"); } else if (createDefaultCube && (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)) { SSTUStockInterop.addDragUpdatePart(part); } if (HighLogic.LoadedSceneIsEditor && part.parent == null && part != EditorLogic.RootPart) //likely the part under the cursor; this fixes problems with modular parts not wanting to attach to stuff { part.gameObject.SetLayerRecursive(1, 2097152); //1<<21 = Part Triggers get skipped by the relayering (hatches, ladders, ??) } }
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 loadConfigData() { ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this); ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); int len = textureNodes.Length; textureSetData = new TextureSet[len]; for (int i = 0; i < len; i++) { textureSetData[i] = new TextureSet(textureNodes[i]); } currentTextureSetData = Array.Find(textureSetData, m => m.setName == currentTextureSet); if (currentTextureSetData == null) { currentTextureSetData = textureSetData[0]; currentTextureSet = currentTextureSetData.setName; } string[] textureSetNames = new string[len]; for (int i = 0; i < len; i++) { textureSetNames[i] = textureSetData[i].setName; } this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, textureSetNames, true, currentTextureSet); techLimitMaxDiameter = SSTUStockInterop.getTechLimit(techLimitSet); if (diameter > techLimitMaxDiameter) { diameter = techLimitMaxDiameter; } }
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 override void OnStart(StartState state) { base.OnStart(state); loadConfigData(); //initialize the container instances, including initializing default values if needed updateMassAndCost(); //update cached part mass and cost values updatePersistentData(); //update persistent data in case tank was just initialized updateFuelSelections(); //update the selections for the 'FuelType' UI slider, this adds or removes the 'custom' option as needed updatePartStats(); //update part stats for crash tolerance and heat, as determined by the container modifiers //disable next fuel event button if main container does not have more than one preset type available BaseField fuelSelection = Fields["guiFuelType"]; fuelSelection.guiActiveEditor = enableFuelTypeChange && getBaseContainer().fuelPresets.Length > 1; fuelSelection.uiControlEditor.onFieldChanged = onFuelTypeUpdated; BaseEvent editContainerEvent = Events["openGUIEvent"]; editContainerEvent.active = enableContainerEdit; if (!initializedResources && (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)) { initializedResources = true; updateTankResources(); SSTUStockInterop.fireEditorUpdate();//update cost } }
public void LateUpdate() { if (externalUpdateData != null) { updateFromExternalData(externalUpdateData); } if (needsStatusUpdate) { needsStatusUpdate = false; updateFairingStatus(); } if (needsRebuilt) { updateFairingStatus(); rebuildFairing(); updatePersistentDataString(); updateEditorFields(false); SSTUStockInterop.fireEditorUpdate(); needsGuiUpdate = true; needsRebuilt = false; } if (needsGuiUpdate) { updateGuiState(); needsGuiUpdate = false; } }
public void Start() { INSTANCE = this; GameObject.DontDestroyOnLoad(this); MonoBehaviour.print("SSTUStockInterop Start"); GameEvents.OnGameSettingsApplied.Add(new EventVoid.OnEvent(gameSettingsApplied)); GameEvents.onGameStateLoad.Add(new EventData <ConfigNode> .OnEvent(gameStateLoaded)); }
public void Start() { INSTANCE = this; GameObject.DontDestroyOnLoad(this); MonoBehaviour.print("SSTUStockInterop Start"); GameEvents.onGameStateLoad.Add(new EventData <ConfigNode> .OnEvent(onGameLoad)); GameEvents.onLevelWasLoadedGUIReady.Add(new EventData <GameScenes> .OnEvent(onSceneLoaded)); }
public void Start() { INSTANCE = this; KSPShaderTools.TexturesUnlimitedLoader.addPostLoadCallback(KSPShaderToolsPostLoad); GameObject.DontDestroyOnLoad(this); MonoBehaviour.print("SSTUStockInterop Start"); GameEvents.OnGameSettingsApplied.Add(new EventVoid.OnEvent(gameSettingsApplied)); GameEvents.onGameStateLoad.Add(new EventData <ConfigNode> .OnEvent(gameStateLoaded)); }
public void recreateModel() { setModelParameters(); model.recreateModel(); updatePhysicalAttributes(); updateDecouplerForce(); SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
public void invertEnginesEvent() { invertEngines = !invertEngines; this.actionWithSymmetry(m => { m.invertEngines = invertEngines; m.updateEnginePositionAndScale(); }); SSTUStockInterop.fireEditorUpdate(); }
private void initialize() { if (initialized) { return; } initialized = true; loadConfigData(SSTUStockInterop.getPartModuleConfig(part, this)); setState(state); }
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 void invertEnginesEvent() { invertEngines = !invertEngines; updateEnginePositionAndScale(); this.forEachSymmetryCounterpart(module => { module.invertEngines = this.invertEngines; module.updateEnginePositionAndScale(); }); SSTUStockInterop.fireEditorUpdate(); }
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); }
/// <summary> /// Internal method to update the persistent data state(s) from the current animation state. /// </summary> /// <param name="newState"></param> protected void onAnimationStateChange(AnimState newState, bool updateExternal = false) { animationState = newState; persistentData = newState.ToString(); if (updateDragCube) { SSTUStockInterop.addDragUpdatePart(part); } if (updateExternal && onAnimStateChangeCallback != null) { onAnimStateChangeCallback(newState); } }
/// <summary> /// Recalculates volume for all containers by finding all IContainerVolumeContributor implementors, and summing the volume for each container from the returned values. /// Removes the need to manually calculate new % values for each container. /// </summary> public void recalcVolume() { if (!initializedResources || containers == null) { //not yet initialized -- recalc will be called during Start, so ignore for now return; } float[] volumes = new float[numberOfContainers]; IContainerVolumeContributor[] contributors = part.FindModulesImplementing <IContainerVolumeContributor>().ToArray(); ContainerContribution[] cts; int len = contributors.Length; for (int i = 0; i < len; i++) { if (contributors[i] == null) { SSTULog.error("NULL Container Contributor"); } cts = contributors[i].getContainerContributions(); if (cts == null) { SSTULog.error("NULL Container Contributor Contributions"); } int len2 = cts.Length; for (int k = 0; k < len2; k++) { int idx = cts[k].containerIndex; if (idx < volumes.Length && idx >= 0) { volumes[cts[k].containerIndex] += cts[k].containerVolume; } } } len = containers.Length; for (int i = 0; i < len; i++) { if (containers[i] == null) { SSTULog.error("NULL Container definition for index: " + i); } containers[i].setContainerVolume(volumes[i]); } updateMassAndCost(); //update cached part mass and cost values updatePersistentData(); //update persistent data in case tank was just initialized updateFuelSelections(); //update the selections for the 'FuelType' UI slider, this adds or removes the 'custom' option as needed updatePartStats(); //update part stats for crash tolerance and heat, as determined by the container modifiers updateGUIControls(); updateTankResources(); SSTUStockInterop.fireEditorUpdate(); }
public void onVolumeUpdated(float newVolume) { if (newVolume != volume) { volume = newVolume; updateContainerVolumes(); updateMassAndCost(); updateTankResources(); updateFuelSelections(); updatePersistentData(); SSTUStockInterop.fireEditorUpdate(); } Events["openGUIEvent"].guiActiveEditor = volume > 0; }
/// <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); }
public void onVolumeUpdated(float newVolume) { if (newVolume != volume) { volume = newVolume; updateContainerVolumes(); updateMassAndCost(); updateTankResources(); updateFuelSelections(); updatePersistentData(); SSTUStockInterop.fireEditorUpdate(); } updateGUIControls(); }
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. }
/// <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); }
public void Start() { INSTANCE = this; GameObject.DontDestroyOnLoad(this); MonoBehaviour.print("SSTUStockInterop Start"); GameEvents.OnGameSettingsApplied.Add(new EventVoid.OnEvent(gameSettingsApplied)); GameEvents.onGameStateLoad.Add(new EventData<ConfigNode>.OnEvent(gameStateLoaded)); }