-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfiguration.cs
More file actions
358 lines (301 loc) · 16.4 KB
/
Configuration.cs
File metadata and controls
358 lines (301 loc) · 16.4 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
using BepInEx.Configuration;
using Chameleon.Info;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
namespace Chameleon
{
internal class Configuration
{
internal enum GordionStorms
{
Never = -1,
Chance,
Always
}
internal enum FogQuality
{
Default,
Medium,
High
}
internal struct MoonTypeMapping
{
internal string moon;
internal int type, weight;
}
static ConfigFile configFile;
internal static ConfigEntry<bool> doorLightColors, rainyMarch, autoAdaptSnow, powerOffBreakerBox, powerOffWindows, planetPreview, giantSkins, fixDoorMeshes, fancyFoliage, fogReprojection, fixTitanVolume, fixArtificeVolume, blackoutWindows, dontChangeCaveSteps, snowyCadavers;
internal static ConfigEntry<GordionStorms> stormyGordion;
internal static ConfigEntry<FogQuality> fogQuality;
internal static ConfigEntry<float> weatherAmbience;
internal static ConfigEntry<string> fancyEntrances;
internal static List<MoonTypeMapping> cavernMappings = [], windowMappings = [];
internal static void Init(ConfigFile cfg)
{
configFile = cfg;
RenderingConfig();
ExteriorConfig();
InteriorConfig();
MigrateLegacyConfigs();
}
static void RenderingConfig()
{
planetPreview = configFile.Bind(
"Rendering",
"PlanetPreview",
true,
"The currently orbited planet is visible on the ship's external security camera while in space, as it used to be in v38.\nYou should disable this if you encounter lighting issues on the ship.");
fancyFoliage = configFile.Bind(
"Rendering",
"FancyFoliage",
true,
"Light passes and spreads through the foliage for nicer visuals. Performance impact is negligible.");
fogQuality = configFile.Bind(
"Rendering",
"FogQuality",
FogQuality.Default,
"Controls the overall quality of the fog. Be aware that using anything other than \"Default\" will incur a performance penalty.");
fogReprojection = configFile.Bind(
"Rendering",
"FogReprojection",
false,
"Reduces the noise/\"graininess\" visible in fog, and improves the definition of light shapes. This will improve visuals without hitting performance as much as the FogQuality setting, but note that this will cause some strange artifacts, like flashlights leaving \"trails\" behind the beam.");
fixTitanVolume = configFile.Bind(
"Rendering",
"FixTitanVolume",
true,
"Fixes Titan's global volume erroneously using the default profile instead of the snowy moon profile. This mainly fixes the sky being too brightly visible.");
fixArtificeVolume = configFile.Bind(
"Rendering",
"FixArtificeVolume",
true,
"\"Fixes\" Artifice's global volume, which has the exact opposite issue of Titan. This is more of a subjective change, but makes Artifice look more vibrant.");
}
static void ExteriorConfig()
{
fancyEntrances = configFile.Bind(
"Exterior",
"FancyEntrances",
"Level2Flow,sdmFoyer,sdmBasement,SpookyManorFlow,AquaticDungeonFlow,MuseumInteriorFlow,CabinDungeonFlow,v62Mansion-Level2Flow",
"Changes the front doors to match the manor entrance's doors when one of these interiors generates. Works for ONLY vanilla moons! Leave empty to disable.\nUpon hosting a lobby, the full list of interior names will be printed in the debug log, which you can use as a guide.");
rainyMarch = configFile.Bind(
"Exterior",
"RainyMarch",
true,
"March is constantly rainy, as described in its terminal page. This is purely visual and does not affect quicksand generation.");
stormyGordion = configFile.Bind(
"Exterior",
"StormyGordion",
GordionStorms.Chance,
"Allows for storms on Gordion, as described in its terminal page. This is purely visual and lightning does not strike at The Company.");
giantSkins = configFile.Bind(
"Exterior",
"GiantSkins",
true,
"When the surface is snowy, Forest Keepers will blend in a little better with the environment. They will also appear more charred after being burnt to death.\nIf you are experiencing issues with giants and have other skin mods installed, you should probably disable this setting.");
}
static void InteriorConfig()
{
doorLightColors = configFile.Bind(
"Interior",
"DoorLightColors",
true,
"Dynamically adjust the color of the light behind the entrance doors depending on where you land, the current weather, and the current time of day.");
powerOffBreakerBox = configFile.Bind(
"Interior",
"PowerOffBreakerBox",
true,
"When the apparatus is unplugged, the light on the breaker box will turn off to indicate it is inactive.");
fixDoorMeshes = configFile.Bind(
"Interior",
"FixDoorMeshes",
true,
"Fixes the glass on the steel doors in factories (and some custom interiors) to show on both sides. Also fixes doorknobs looking incorrect on one side.");
weatherAmbience = configFile.Bind(
"Interior",
"WeatherAmbience",
0.4f,
new ConfigDescription(
"On moons where a blizzard or rainstorm is present, you will be able to hear it faintly while inside the building. Set volume from 0 (silent) to 1 (max).",
new AcceptableValueRange<float>(0f, 1f)));
InteriorManorConfig();
InteriorMineshaftConfig();
}
static void InteriorManorConfig()
{
powerOffWindows = configFile.Bind(
"Interior.Manor",
"PowerOffWindows",
true,
"When the breaker box is turned off, the \"fake window\" rooms will also turn off.");
blackoutWindows = configFile.Bind(
"Interior.Manor",
"BlackoutWindows",
false,
"When windows turn off, they will be solid black, instead of darkening the image they normally display.");
PopulateWindowsList(WindowType.Pasture, "Vow:100,March:100,Adamance:100,Artifice:100");
PopulateWindowsList(WindowType.Canyon, "Experimentation:100,Assurance:100,Offense:100,Titan:100");
PopulateWindowsList(WindowType.Snowy, "Rend:100,Dine:100");
PopulateWindowsList(WindowType.Flowery, "Embrion:100");
PopulateWindowsList(WindowType.Beach, string.Empty);
PopulateWindowsList(WindowType.HotSprings, string.Empty);
PopulateWindowsList(WindowType.BrokenScreen, string.Empty);
}
static void PopulateWindowsList(WindowType type, string defaultList)
{
string listName = $"{type}WindowsList";
string customList = configFile.Bind(
"Interior.Manor",
listName,
defaultList,
$"A list of moons for which to assign \"{Regex.Replace(type.ToString(), "([A-Z])", " $1").TrimStart()}\" windows, with their respective weights.{(type != WindowType.Pasture ? " Leave empty to disable." : string.Empty)}\n"
+ "Moon names are not case-sensitive, and can be left incomplete (ex. \"as\" will map to both Assurance and Asteroid-13.) \"ALL\" will add that weight to every moon's pool."
+ (type == WindowType.Pasture ? "\nUpon hosting a lobby, the full list of moon names will be printed in the debug log, which you can use as a guide." : string.Empty)).Value;
if (string.IsNullOrEmpty(customList))
{
Plugin.Logger.LogDebug($"User has no {listName} defined");
return;
}
PopulateGlobalListWithType((int)type, customList, ref windowMappings, listName, type.ToString());
}
static void PopulateGlobalListWithType(int type, string customList, ref List<MoonTypeMapping> mappings, string listName, string displayName)
{
if (string.IsNullOrEmpty(customList))
{
Plugin.Logger.LogDebug($"User has no {listName} defined");
return;
}
try
{
foreach (string weightedMoon in customList.Split(','))
{
string[] moonAndWeight = weightedMoon.Split(':');
int weight = -1;
if (moonAndWeight.Length == 2 && int.TryParse(moonAndWeight[1], out weight))
{
if (weight != 0)
{
string inputName = moonAndWeight[0].ToLower();
MoonTypeMapping mapping = new()
{
moon = inputName == "all" ? "ALL" : inputName,
type = type,
weight = (int)Mathf.Clamp(weight, 1f, 99999f)
};
mappings.Add(mapping);
Plugin.Logger.LogDebug($"Successfully added \"{mapping.moon}\" to \"{displayName}\" list with weight {mapping.weight}");
}
else
Plugin.Logger.LogDebug($"Skipping \"{weightedMoon}\" in \"{listName}\" because weight is 0");
}
else
Plugin.Logger.LogWarning($"Encountered an error parsing entry \"{weightedMoon}\" in the \"{listName}\" setting. It has been skipped");
}
}
catch
{
Plugin.Logger.LogError($"Encountered an error parsing the \"{listName}\" setting. Please double check that your config follows proper syntax, then restart your game.");
}
}
static void InteriorMineshaftConfig()
{
PopulateCavernsList(CavernType.Vanilla, "Vow:100,March:100,Adamance:100,Artifice:100");
PopulateCavernsList(CavernType.Mesa, "Experimentation:100,Titan:100");
PopulateCavernsList(CavernType.Desert, "Assurance:100,Offense:100");
PopulateCavernsList(CavernType.Ice, "Rend:100,Dine:100");
PopulateCavernsList(CavernType.Amethyst, "Embrion:100");
PopulateCavernsList(CavernType.Gravel, string.Empty);
PopulateCavernsList(CavernType.Salt, string.Empty);
PopulateCavernsList(CavernType.Slate, string.Empty);
autoAdaptSnow = configFile.Bind(
"Interior.Mineshaft",
"AutoAdaptSnow",
false,
"Automatically enable ice (or salt, without Buttery Fixes) caverns on modded levels that are snowy.\nIf you have Artifice Blizzard installed, this will also change the caverns specifically only when the blizzard is active.");
dontChangeCaveSteps = configFile.Bind(
"Interior.Mineshaft",
"DontChangeCaveSteps",
false,
"All variants of the cave use vanilla's footstep sounds and effects. This is basically identical to the behavior of the mod if you don't have Buttery Fixes installed.");
snowyCadavers = configFile.Bind(
"Interior.Mineshaft",
"SnowyCadavers",
true,
"Cadavers will appear with a unique frostbitten appearance in ice caverns.");
}
static void PopulateCavernsList(CavernType type, string defaultList)
{
string listName = $"{type}CavesList";
string customList = configFile.Bind(
"Interior.Mineshaft",
listName,
defaultList,
$"A list of moons for which to assign \"{type}\" caves, with their respective weights.{(type != CavernType.Vanilla ? " Leave empty to disable." : string.Empty)}\n"
+ "Moon names are not case-sensitive, and can be left incomplete (ex. \"as\" will map to both Assurance and Asteroid-13.) \"ALL\" will add that weight to every moon's pool."
+ (type == CavernType.Vanilla ? "\nUpon hosting a lobby, the full list of moon names will be printed in the debug log, which you can use as a guide." : string.Empty)).Value;
if (string.IsNullOrEmpty(customList))
{
Plugin.Logger.LogDebug($"User has no {listName} defined");
return;
}
PopulateGlobalListWithType((int)type, customList, ref cavernMappings, listName, type.ToString());
}
static void MigrateLegacyConfigs()
{
// old cavern settings
foreach (string oldCaveKey in new string[]{
"IceCaves",
"AmethystCave",
"DesertCave",
"MesaCave",
"IcyTitan",
"AdaptiveArtifice"})
{
configFile.Bind("Interior", oldCaveKey, false, "Legacy setting, doesn't work");
configFile.Remove(configFile["Interior", oldCaveKey].Definition);
}
if (fixDoorMeshes.Value)
{
if (!configFile.Bind("Interior", "FixDoors", true, "Legacy setting, doesn't work").Value)
fixDoorMeshes.Value = false;
configFile.Remove(configFile["Interior", "FixDoors"].Definition);
}
if (planetPreview.Value)
{
if (!configFile.Bind("Exterior", "PlanetPreview", true, "Legacy setting, doesn't work").Value)
planetPreview.Value = false;
configFile.Remove(configFile["Exterior", "PlanetPreview"].Definition);
}
if (fancyFoliage.Value)
{
if (!configFile.Bind("Exterior", "FancyFoliage", true, "Legacy setting, doesn't work").Value)
fancyFoliage.Value = false;
configFile.Remove(configFile["Exterior", "FancyFoliage"].Definition);
}
configFile.Bind("Exterior", "FancyShrouds", true, "Legacy setting, doesn't work");
configFile.Remove(configFile["Exterior", "FancyShrouds"].Definition);
configFile.Bind("Rendering", "FancyShrouds", true, "Legacy setting, doesn't work");
configFile.Remove(configFile["Rendering", "FancyShrouds"].Definition);
if (giantSkins.Value)
{
if (!configFile.Bind("Exterior", "SnowyGiants", true, "Legacy setting, doesn't work").Value)
giantSkins.Value = false;
configFile.Remove(configFile["Exterior", "SnowyGiants"].Definition);
}
configFile.Bind("Interior", "FixDoorSounds", true, "Legacy setting, doesn't work");
configFile.Remove(configFile["Interior", "FixDoorSounds"].Definition);
configFile.Bind("Interior.Manor", "WindowVariants", true, "Legacy setting, doesn't work");
configFile.Remove(configFile["Interior.Manor", "WindowVariants"].Definition);
configFile.Bind("Exterior", "FancyEntranceDoors", true, "Legacy setting, doesn't work");
configFile.Remove(configFile["Exterior", "FancyEntranceDoors"].Definition);
configFile.Bind("Exterior", "EclipsesBlockMusic", true, "Legacy setting, doesn't work");
configFile.Remove(configFile["Exterior", "EclipsesBlockMusic"].Definition);
configFile.Bind("Exterior", "ReworkFoggyWeather", true, "Legacy setting, doesn't work");
configFile.Remove(configFile["Exterior", "ReworkFoggyWeather"].Definition);
configFile.Bind("Exterior", "RecolorRandomRocks", true, "Legacy setting, doesn't work");
configFile.Remove(configFile["Exterior", "RecolorRandomRocks"].Definition);
configFile.Save();
}
}
}