Skip to content

Commit 480a688

Browse files
Merge pull request #124 from post-kerbin-mining-corporation/dev
0.8.0
2 parents f953957 + afa662e commit 480a688

10 files changed

Lines changed: 223 additions & 29 deletions

File tree

GameData/SystemHeat/Localization/en-us.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ Localization
144144
/// =================================
145145
#LOC_SystemHeat_ModuleSystemHeatRadiator_DisplayName = Heat Radiator
146146
#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>
147+
#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>
148+
#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>
147149
#LOC_SystemHeat_ModuleSystemHeatRadiator_GroupName = Heat Radiator
148150

149151
#LOC_SystemHeat_ModuleSystemHeatRadiator_RadiatorStatus_Title = Radiative Flux

GameData/SystemHeat/Localization/zh-cn.cfg

Lines changed: 131 additions & 8 deletions
Large diffs are not rendered by default.
1.5 KB
Binary file not shown.

GameData/SystemHeat/Versioning/SystemHeat.version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"VERSION":
66
{
77
"MAJOR":0,
8-
"MINOR":7,
9-
"PATCH":5,
8+
"MINOR":8,
9+
"PATCH":0,
1010
"BUILD":0
1111
},
1212
"KSP_VERSION":

SystemHeat/SystemHeat/EngineerReport/SystemHeatEngineerReport.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ void Awake()
1616
GameEvents.onGUIEngineersReportReady.Add(ReportReady);
1717
GameEvents.onGUIEngineersReportDestroy.Add(ReportDestroyed);
1818
}
19-
19+
public void OnDestroy()
20+
{
21+
GameEvents.onGUIEngineersReportReady.Remove(ReportReady);
22+
GameEvents.onGUIEngineersReportDestroy.Remove(ReportDestroyed);
23+
}
2024
private void AddTest()
2125
{
2226
//Wait for DeltaV simulation to be instantiated and to finish.

SystemHeat/SystemHeat/Modules/ModuleSystemHeatRadiator.cs

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,27 @@ public class ModuleSystemHeatRadiator : ModuleActiveRadiator
2929
[KSPField(isPersistant = false)]
3030
public FloatCurve temperatureCurve = new FloatCurve();
3131

32-
32+
/// <summary>
33+
/// Whether to scale by atmosphere depth
34+
/// </summary>
35+
[KSPField(isPersistant = false)]
36+
public bool affectedByAtmosphere = false;
37+
38+
/// <summary>
39+
/// This should scale heat radiated by atmosphere depth
40+
/// </summary>
41+
[KSPField(isPersistant = false)]
42+
public FloatCurve atmosphereCurve = new FloatCurve();
43+
/// <summary>
44+
/// Whether to scale by acceleration
45+
/// </summary>
46+
[KSPField(isPersistant = false)]
47+
public bool affectedByAcceleration = false;
48+
/// <summary>
49+
/// This should scale heat radiated by vessel acceleration
50+
/// </summary>
51+
[KSPField(isPersistant = false)]
52+
public FloatCurve accelerationCurve = new FloatCurve();
3353
/// <summary>
3454
/// Convective area
3555
/// </summary>
@@ -43,7 +63,7 @@ public class ModuleSystemHeatRadiator : ModuleActiveRadiator
4363
public string RadiatorStatus = "Offline";
4464

4565
/// <summary>
46-
/// UI: Current status
66+
/// UI: Current status of convection
4767
/// </summary>
4868
[KSPField(isPersistant = false, guiActive = true, guiActiveEditor = true, guiName = "#LOC_SystemHeat_ModuleSystemHeatRadiator_ConvectionStatus_Title", groupName = "sysheatradiator", groupDisplayName = "#LOC_SystemHeat_ModuleSystemHeatRadiator_GroupName")]
4969
public string ConvectionStatus = "Offline";
@@ -133,7 +153,6 @@ public override void Start()
133153
{
134154
this.Events["ToggleEditorSunTracking"].guiActiveEditor = true;
135155
}
136-
137156
}
138157
else
139158
{
@@ -152,12 +171,29 @@ public override string GetModuleDisplayName()
152171
public override string GetInfo()
153172
{
154173

155-
string message = Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo",
174+
string message = Localizer.Format(
175+
"#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo",
156176
Utils.ToSI(temperatureCurve.Curve.keys[0].time, "F0"),
157-
temperatureCurve.Evaluate(temperatureCurve.Curve.keys[0].time).ToString("F0"),
177+
temperatureCurve.Evaluate(temperatureCurve.Curve.keys[0].time).ToString("F0"),
158178
Utils.ToSI(temperatureCurve.Evaluate(temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time), "F0"),
159179
temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time.ToString("F0")
160180
);
181+
if (affectedByAtmosphere)
182+
{
183+
message += Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo_Atmosphere",
184+
(accelerationCurve.Evaluate(0f) * 100f).ToString("F0"),
185+
0f,
186+
(accelerationCurve.Evaluate(1f) * 100f).ToString("F0"),
187+
1f);
188+
}
189+
if (affectedByAcceleration)
190+
{
191+
message += Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatRadiator_PartInfo_Acceleration",
192+
(accelerationCurve.Evaluate(0f) * 100f).ToString("F0"),
193+
0f,
194+
(accelerationCurve.Evaluate(1f) * 100f).ToString("F0"),
195+
1f);
196+
}
161197
message += base.GetInfo();
162198
return message;
163199
}
@@ -178,17 +214,28 @@ public override void FixedUpdate()
178214

179215
if (vessel.atmDensity > 0d)
180216
{
217+
float densityScale = 1f;
218+
if (affectedByAtmosphere)
219+
{
220+
densityScale = atmosphereCurve.Evaluate((float)vessel.atmDensity);
221+
}
222+
radiativeFlux *= densityScale;
181223
HeatLoop lp = heatModule.Loop;
182224
if (lp != null)
183225
{
184226
float tDelta = lp.ConvectionTemperature - Mathf.Clamp(heatModule.LoopTemperature,
185227
(float)PhysicsGlobals.SpaceTemperature, temperatureCurve.Curve.keys[temperatureCurve.Curve.keys.Length - 1].time);
186228

187229
convectiveFlux = Mathf.Clamp(
188-
tDelta * heatModule.Loop.ConvectionFlux * (float)part.heatConvectiveConstant * convectiveArea * 0.5f,
230+
tDelta * heatModule.Loop.ConvectionFlux * (float)part.heatConvectiveConstant * convectiveArea * 0.5f * densityScale,
189231
float.MinValue, 0f);
190232
}
191233
}
234+
if (affectedByAcceleration)
235+
{
236+
float accelScale = accelerationCurve.Evaluate((float)vessel.acceleration.magnitude);
237+
radiativeFlux *= accelScale;
238+
}
192239
heatModule.AddFlux(moduleID, 0f, radiativeFlux + convectiveFlux, false);
193240

194241
if (scalarModule != null)

SystemHeat/SystemHeat/SystemHeatEditor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ protected void SetupEditorCallbacks()
6565
GameEvents.onEditorPartDeleted.Add(new EventData<Part>.OnEvent(onEditorPartDeleted));
6666
GameEvents.onEditorPodDeleted.Add(new EventVoid.OnEvent(onEditorVesselReset));
6767
GameEvents.onEditorLoad.Add(new EventData<ShipConstruct, KSP.UI.Screens.CraftBrowserDialog.LoadType>.OnEvent(onEditorVesselLoad));
68+
GameEvents.onAboutToSaveShip.Add(new EventData<ShipConstruct>.OnEvent(onEditorSave));
6869

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

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

131132
InitializeEditorConstruct(ship, false);
132133
}
134+
public void onEditorSave(ShipConstruct ship)
135+
{
136+
137+
Utils.Log("[SystemHeatEditor]: Editor Save", LogType.Simulator);
138+
if (!HighLogic.LoadedSceneIsEditor) { return; }
139+
140+
if (ship != null)
141+
{
142+
if (simulator != null)
143+
{
144+
simulator.ResetTemperatures();
145+
}
146+
}
147+
}
133148
public void onEditorPartDeleted(Part part)
134149
{
135150
Utils.Log($"[SystemHeatEditor]: Part Deleted", LogType.Simulator);

SystemHeat/SystemHeat/UI/Overlay/SystemHeatOverlay.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,14 @@ protected void OnDestroy()
6161

6262
Utils.Log("[SystemHeatOverlay]: Unsubscribing to events", LogType.Overlay);
6363
GameEvents.onGameSceneLoadRequested.Remove(onSceneChange);
64+
GameEvents.onEditorScreenChange.Remove(onEditorScreenChange);
65+
GameEvents.onEditorPartDeleted.Remove(onEditorPartDeleted);
66+
GameEvents.onEditorPartPicked.Remove(onEditorPartPicked);
67+
GameEvents.onEditorRestart.Remove(onEditorReset);
68+
GameEvents.onEditorStarted.Remove(onEditorStart);
69+
GameEvents.OnMapEntered.Remove(onEnterMapView);
70+
GameEvents.OnMapExited.Remove(onExitMapView);
6471

65-
if (HighLogic.LoadedSceneIsEditor)
66-
{
67-
GameEvents.onEditorScreenChange.Remove(onEditorScreenChange);
68-
GameEvents.onEditorPartDeleted.Remove(onEditorPartDeleted);
69-
GameEvents.onEditorPartPicked.Remove(onEditorPartPicked);
70-
}
71-
else
72-
{
73-
GameEvents.OnMapEntered.Remove(onEnterMapView);
74-
GameEvents.OnMapExited.Remove(onExitMapView);
75-
}
7672
}
7773
protected void Start()
7874
{

changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v0.8.0
2+
------
3+
- Updates to zn-ch localization
4+
- 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
5+
- Additional performance improvements and code cleanup
6+
- Added the ability for radiators to have their output scaled by atmosphere depth and/or acceleration
7+
18
v0.7.5
29
------
310
- Fixed a fission reactor related logging incident

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
================
2-
SystemHeat 0.7.5
2+
SystemHeat 0.8.0
33
================
44

55
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.

0 commit comments

Comments
 (0)