forked from KSPModStewards/SystemHeat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystemHeatSettings.cs
More file actions
223 lines (189 loc) · 8.25 KB
/
Copy pathSystemHeatSettings.cs
File metadata and controls
223 lines (189 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace SystemHeat
{
/// <summary>
/// Static class to hold settings and configuration
/// </summary>
public static class SystemHeatSettings
{
public static void ModuleManagerPostLoad()
{
Load();
}
/// <summary>
/// Emit log messages about the UI
/// </summary>
public static bool DebugUI = false;
/// <summary>
/// Emit log messages about the overlay
/// </summary>
public static bool DebugOverlay = false;
/// <summary>
/// Emit log messages about simulations
/// </summary>
public static bool DebugSimulation = false;
/// <summary>
/// Emit log messages about modules
/// </summary>
public static bool DebugModules = false;
/// <summary>
/// Emit log messages about settings
/// </summary>
public static bool DebugSettings = false;
/// <summary>
/// Show debug info in PAW UIs
/// </summary>
public static bool DebugPartUI = false;
/// <summary>
/// Deep space temperature
/// </summary>
public static float SpaceTemperature = 2.7f;
/// <summary>
/// Base coefficient for convection to mirror stock
/// </summary>
public static float ConvectionBaseCoefficient = 0.001f;
/// <summary>
/// Base coefficient to determine how loops slowly cool when there is no flux at all
/// </summary>
public static float HeatLoopDecayCoefficient = 0.15f;
/// <summary>
/// Maximum number of loops
/// </summary>
public static int maxLoopCount = 20;
/// <summary>
///The maximum allowed change in temperature per simulation time step
/// </summary>
public static float UIUpdateInterval = 1f;
/// <summary>
///
/// </summary>
public static float TimeWarpLimit = 100f;
// Simulation settings
// The maximum allows change in temperature per simulation time step
public static float MaxDeltaTPerStep = 25f;
// The minimum number of time steps to take in a simulation frame
public static int MinSteps = 1;
// The maximum number of time steps to take in a simulation frame
public static int MaxSteps = 30;
// The standard timestep in the editor
public static float SimulationRateEditor = 1f;
// Loop flux tolerance
public static float AbsFluxThreshold = 0.5f;
// UI Stuff
public static float UISrollSensitivity = 25f;
// Radiator Performance
// if the optional harvester and converter patches are installed, we can avoid calling the expensive stock radiator logic
public static bool HarvesterPatchesInstalled = false;
public static bool ConverterPatchesInstalled = false;
public static bool ForceStockRadiatorLogic = false;
// Overlay Stuff
public static float OverlayActiveLineWidth = 6f;
public static float OverlayBaseLineWidth = 4f;
public static int OverlayBaseLineQueue = 3000;
public static float OverlayOutlineLineWidth = 4f;
public static int OverlayOutlineLineQueue = 3025;
public static float OverlayActiveLineTextureScaleFactor = 10f;
public static float OverlayActiveLineTextureScrollRate = 2.5f;
public static float OverlayLineBevel = 0.1f;
public static float OverlayLineBevelScale = 0.3f;
public static float OverlayPadding = 0.2f;
public static float OverlayBoundsPadding = 1f;
public static float OverlayPanelFluxTickSize = 500f;
public static float OverlayPanelTemperatureDeltaForMaxColor = 500f;
public static float OverlayPanelMaxTemperatureValue = 2000f;
public static Dictionary<string, CoolantType> CoolantData;
public static Dictionary<int, Color> ColorData = new Dictionary<int, Color> {
{ 0, XKCDColors.Algae},
{ 1, XKCDColors.Reddish},
{ 2, XKCDColors.BlueGrey},
{ 3, XKCDColors.YellowBrown},
{ 4, XKCDColors.GrassGreen},
{ 5, XKCDColors.PurpleGrey},
{ 6, XKCDColors.RustRed},
{ 7, XKCDColors.Saffron},
{ 8, XKCDColors.Sage},
{ 9, XKCDColors.LightIndigo}
};
public static Color GetLoopColor(int id)
{
return SystemHeatSettings.ColorData[Mathf.Clamp(id, 0, 9)];
}
/// <summary>
/// Load data from configuration
/// </summary>
public static void Load()
{
ConfigNode settingsNode;
Utils.Log("[Settings]: Started loading", LogType.Settings);
if (GameDatabase.Instance.ExistsConfigNode("SystemHeat/Settings/SYSTEMHEAT"))
{
Utils.Log("[Settings]: Located settings file");
settingsNode = GameDatabase.Instance.GetConfigNodes("SYSTEMHEAT").First();
settingsNode.TryGetValue("DebugOverlay", ref DebugOverlay);
settingsNode.TryGetValue("DebugUI", ref DebugUI);
settingsNode.TryGetValue("DebugModules", ref DebugModules);
settingsNode.TryGetValue("DebugPartUI", ref DebugPartUI);
settingsNode.TryGetValue("DebugSimulation", ref DebugSimulation);
settingsNode.TryGetValue("maxLoopCount", ref maxLoopCount);
settingsNode.TryGetValue("SpaceTemperature", ref SpaceTemperature);
settingsNode.TryGetValue("ConvectionBaseCoefficient", ref ConvectionBaseCoefficient);
settingsNode.TryGetValue("UIUpdateInterval", ref UIUpdateInterval);
settingsNode.TryGetValue("TimeWarpLimit", ref TimeWarpLimit);
settingsNode.TryGetValue("MaxDeltaTPerStep", ref MaxDeltaTPerStep);
settingsNode.TryGetValue("MinSteps", ref MinSteps);
settingsNode.TryGetValue("MaxSteps", ref MaxSteps);
settingsNode.TryGetValue("SimulationRateEditor", ref SimulationRateEditor);
settingsNode.TryGetValue("AbsFluxThreshold", ref AbsFluxThreshold);
settingsNode.TryGetValue("HeatLoopDecayCoefficient", ref HeatLoopDecayCoefficient);
settingsNode.TryGetValue("UIScrollSensitivity", ref UISrollSensitivity);
settingsNode.TryGetValue("OverlayActiveLineWidth", ref OverlayActiveLineWidth);
settingsNode.TryGetValue("OverlayActiveLineTextureScaleFactor", ref OverlayActiveLineTextureScaleFactor);
settingsNode.TryGetValue("OverlayActiveLineTextureScrollRate", ref OverlayActiveLineTextureScrollRate);
settingsNode.TryGetValue("OverlayBaseLineWidth", ref OverlayBaseLineWidth);
settingsNode.TryGetValue("OverlayLineBevel", ref OverlayLineBevel);
settingsNode.TryGetValue("OverlayLineBevelScale", ref OverlayLineBevelScale);
settingsNode.TryGetValue("OverlayPadding", ref OverlayPadding);
settingsNode.TryGetValue("OverlayBoundsPadding", ref OverlayBoundsPadding);
settingsNode.TryGetValue("OverlayPanelFluxTickSize", ref OverlayPanelFluxTickSize);
settingsNode.TryGetValue("OverlayPanelTemperatureDeltaForMaxColor", ref OverlayPanelTemperatureDeltaForMaxColor);
settingsNode.TryGetValue("OverlayPanelMaxTemperatureValue", ref OverlayPanelMaxTemperatureValue);
settingsNode.TryGetValue(nameof(HarvesterPatchesInstalled), ref HarvesterPatchesInstalled);
settingsNode.TryGetValue(nameof(ConverterPatchesInstalled), ref ConverterPatchesInstalled);
settingsNode.TryGetValue(nameof(ForceStockRadiatorLogic), ref ForceStockRadiatorLogic);
}
else
{
Utils.Log("[Settings]: Couldn't find settings file, using defaults", LogType.Settings);
}
Utils.Log("[Settings]: Loading coolant types ", LogType.Settings);
ConfigNode[] coolantNodes = GameDatabase.Instance.GetConfigNodes("COOLANTTYPE");
CoolantData = new Dictionary<string, CoolantType>();
foreach (ConfigNode node in coolantNodes)
{
CoolantType newCoolant = new CoolantType(node);
CoolantData.Add(newCoolant.Name, newCoolant);
}
Utils.Log("[Settings]: Loaded coolant types", LogType.Settings);
Utils.Log("[Settings]: Finished loading", LogType.Settings);
}
public static CoolantType GetCoolantType(string name)
{
CoolantType coolant;
if (CoolantData.TryGetValue(name, out coolant))
{
Utils.Log(String.Format("[Settings]: Using coolant {0}", coolant.Name), LogType.Settings);
return coolant;
}
else
{
Utils.Log(String.Format("[Settings] {0} not found, using default coolant", name), LogType.Simulator);
return new CoolantType();
}
}
static void OnHotLoad() => Load();
}
}