Skip to content

Commit

Permalink
Merge pull request #124 from post-kerbin-mining-corporation/dev
Browse files Browse the repository at this point in the history
0.8.0
  • Loading branch information
ChrisAdderley authored Nov 21, 2024
2 parents f953957 + afa662e commit 480a688
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 29 deletions.
2 changes: 2 additions & 0 deletions GameData/SystemHeat/Localization/en-us.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ Localization
/// =================================
#LOC_SystemHeat_ModuleSystemHeatRadiator_DisplayName = Heat Radiator
#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo = Cools systems on vessels by pumping coolant through radiating surfaces.\n\n<color=#ff730d>Thermal Parameters:</color>\n - Radiates <b><<1>>W</b> at <b><<2>> K</b>\n - Radiates <b><<3>>W</b> at <b><<4>> K</b>\n \n\n<b>Legacy Core Heat Parameters</b>
#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo_Atmosphere = \n<b>Affected by atmosphere density</b> \n- <b><<1>>%</b> at <b><<2>> atm</b>\n - <b><<3>>%</b> at <b><<4>> atm</b>
#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo_Acceleration = \n<b>Affected by vessel acceleration</b> \n- <b><<1>>%</b> at <b><<2>> m/s²</b>\n - <b><<3>>%</b> at <b><<4>> m/s²</b>
#LOC_SystemHeat_ModuleSystemHeatRadiator_GroupName = Heat Radiator

#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorStatus_Title = Radiative Flux
Expand Down
139 changes: 131 additions & 8 deletions GameData/SystemHeat/Localization/zh-cn.cfg

Large diffs are not rendered by default.

Binary file modified GameData/SystemHeat/Plugin/SystemHeat.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions GameData/SystemHeat/Versioning/SystemHeat.version
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"VERSION":
{
"MAJOR":0,
"MINOR":7,
"PATCH":5,
"MINOR":8,
"PATCH":0,
"BUILD":0
},
"KSP_VERSION":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ void Awake()
GameEvents.onGUIEngineersReportReady.Add(ReportReady);
GameEvents.onGUIEngineersReportDestroy.Add(ReportDestroyed);
}

public void OnDestroy()
{
GameEvents.onGUIEngineersReportReady.Remove(ReportReady);
GameEvents.onGUIEngineersReportDestroy.Remove(ReportDestroyed);
}
private void AddTest()
{
//Wait for DeltaV simulation to be instantiated and to finish.
Expand Down
59 changes: 53 additions & 6 deletions SystemHeat/SystemHeat/Modules/ModuleSystemHeatRadiator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,27 @@ public class ModuleSystemHeatRadiator : ModuleActiveRadiator
[KSPField(isPersistant = false)]
public FloatCurve temperatureCurve = new FloatCurve();


/// <summary>
/// Whether to scale by atmosphere depth
/// </summary>
[KSPField(isPersistant = false)]
public bool affectedByAtmosphere = false;

/// <summary>
/// This should scale heat radiated by atmosphere depth
/// </summary>
[KSPField(isPersistant = false)]
public FloatCurve atmosphereCurve = new FloatCurve();
/// <summary>
/// Whether to scale by acceleration
/// </summary>
[KSPField(isPersistant = false)]
public bool affectedByAcceleration = false;
/// <summary>
/// This should scale heat radiated by vessel acceleration
/// </summary>
[KSPField(isPersistant = false)]
public FloatCurve accelerationCurve = new FloatCurve();
/// <summary>
/// Convective area
/// </summary>
Expand All @@ -43,7 +63,7 @@ public class ModuleSystemHeatRadiator : ModuleActiveRadiator
public string RadiatorStatus = "Offline";

/// <summary>
/// UI: Current status
/// UI: Current status of convection
/// </summary>
[KSPField(isPersistant = false, guiActive = true, guiActiveEditor = true, guiName = "#LOC_SystemHeat_ModuleSystemHeatRadiator_ConvectionStatus_Title", groupName = "sysheatradiator", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatRadiator_GroupName")]
public string ConvectionStatus = "Offline";
Expand Down Expand Up @@ -133,7 +153,6 @@ public override void Start()
{
this.Events["ToggleEditorSunTracking"].guiActiveEditor = true;
}

}
else
{
Expand All @@ -152,12 +171,29 @@ public override string GetModuleDisplayName()
public override string GetInfo()
{

string message = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo",
string message = Localizer.Format(
"#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo",
Utils.ToSI(temperatureCurve.Curve.keys[0].time, "F0"),
temperatureCurve.Evaluate(temperatureCurve.Curve.keys[0].time).ToString("F0"),
temperatureCurve.Evaluate(temperatureCurve.Curve.keys[0].time).ToString("F0"),
Utils.ToSI(temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time), "F0"),
temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time.ToString("F0")
);
if (affectedByAtmosphere)
{
message += Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo_Atmosphere",
(accelerationCurve.Evaluate(0f) * 100f).ToString("F0"),
0f,
(accelerationCurve.Evaluate(1f) * 100f).ToString("F0"),
1f);
}
if (affectedByAcceleration)
{
message += Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo_Acceleration",
(accelerationCurve.Evaluate(0f) * 100f).ToString("F0"),
0f,
(accelerationCurve.Evaluate(1f) * 100f).ToString("F0"),
1f);
}
message += base.GetInfo();
return message;
}
Expand All @@ -178,17 +214,28 @@ public override void FixedUpdate()

if (vessel.atmDensity > 0d)
{
float densityScale = 1f;
if (affectedByAtmosphere)
{
densityScale = atmosphereCurve.Evaluate((float)vessel.atmDensity);
}
radiativeFlux *= densityScale;
HeatLoop lp = heatModule.Loop;
if (lp != null)
{
float tDelta = lp.ConvectionTemperature - Mathf.Clamp(heatModule.LoopTemperature,
(float)PhysicsGlobals.SpaceTemperature, temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time);

convectiveFlux = Mathf.Clamp(
tDelta * heatModule.Loop.ConvectionFlux * (float)part.heatConvectiveConstant * convectiveArea * 0.5f,
tDelta * heatModule.Loop.ConvectionFlux * (float)part.heatConvectiveConstant * convectiveArea * 0.5f * densityScale,
float.MinValue, 0f);
}
}
if (affectedByAcceleration)
{
float accelScale = accelerationCurve.Evaluate((float)vessel.acceleration.magnitude);
radiativeFlux *= accelScale;
}
heatModule.AddFlux(moduleID, 0f, radiativeFlux + convectiveFlux, false);

if (scalarModule != null)
Expand Down
15 changes: 15 additions & 0 deletions SystemHeat/SystemHeat/SystemHeatEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected void SetupEditorCallbacks()
GameEvents.onEditorPartDeleted.Add(new EventData<Part>.OnEvent(onEditorPartDeleted));
GameEvents.onEditorPodDeleted.Add(new EventVoid.OnEvent(onEditorVesselReset));
GameEvents.onEditorLoad.Add(new EventData<ShipConstruct, KSP.UI.Screens.CraftBrowserDialog.LoadType>.OnEvent(onEditorVesselLoad));
GameEvents.onAboutToSaveShip.Add(new EventData<ShipConstruct>.OnEvent(onEditorSave));

GameEvents.onPartRemove.Add(new EventData<GameEvents.HostTargetAction<Part, Part>>.OnEvent(onEditorVesselPartRemoved));

Expand Down Expand Up @@ -130,6 +131,20 @@ public void onEditorLoad(ShipConstruct ship, KSP.UI.Screens.CraftBrowserDialog.L

InitializeEditorConstruct(ship, false);
}
public void onEditorSave(ShipConstruct ship)
{

Utils.Log("[SystemHeatEditor]: Editor Save", LogType.Simulator);
if (!HighLogic.LoadedSceneIsEditor) { return; }

if (ship != null)
{
if (simulator != null)
{
simulator.ResetTemperatures();
}
}
}
public void onEditorPartDeleted(Part part)
{
Utils.Log($"[SystemHeatEditor]: Part Deleted", LogType.Simulator);
Expand Down
18 changes: 7 additions & 11 deletions SystemHeat/SystemHeat/UI/Overlay/SystemHeatOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,14 @@ protected void OnDestroy()

Utils.Log("[SystemHeatOverlay]: Unsubscribing to events", LogType.Overlay);
GameEvents.onGameSceneLoadRequested.Remove(onSceneChange);
GameEvents.onEditorScreenChange.Remove(onEditorScreenChange);
GameEvents.onEditorPartDeleted.Remove(onEditorPartDeleted);
GameEvents.onEditorPartPicked.Remove(onEditorPartPicked);
GameEvents.onEditorRestart.Remove(onEditorReset);
GameEvents.onEditorStarted.Remove(onEditorStart);
GameEvents.OnMapEntered.Remove(onEnterMapView);
GameEvents.OnMapExited.Remove(onExitMapView);

if (HighLogic.LoadedSceneIsEditor)
{
GameEvents.onEditorScreenChange.Remove(onEditorScreenChange);
GameEvents.onEditorPartDeleted.Remove(onEditorPartDeleted);
GameEvents.onEditorPartPicked.Remove(onEditorPartPicked);
}
else
{
GameEvents.OnMapEntered.Remove(onEnterMapView);
GameEvents.OnMapExited.Remove(onExitMapView);
}
}
protected void Start()
{
Expand Down
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.8.0
------
- Updates to zn-ch localization
- Corrected an issue where the heat simulation would not be reset when using the Hangar mod to launch ships. Note that if you are experiencing this you will need to re-save the ship in the editor
- Additional performance improvements and code cleanup
- Added the ability for radiators to have their output scaled by atmosphere depth and/or acceleration

v0.7.5
------
- Fixed a fission reactor related logging incident
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
================
SystemHeat 0.7.5
SystemHeat 0.8.0
================

A mod for Kerbal Space Program, intended to provide a better experience for heat management, particularly geared towards resource extraction, high energy engines, and nuclear reactors.
Expand Down

0 comments on commit 480a688

Please sign in to comment.