forked from ButteryStancakes/Chameleon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration.cs
More file actions
308 lines (261 loc) · 13 KB
/
Copy pathConfiguration.cs
File metadata and controls
308 lines (261 loc) · 13 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
using BepInEx.Configuration;
using Chameleon.Info;
using System.Collections.Generic;
using UnityEngine;
namespace Chameleon
{
internal class Configuration
{
internal enum GordionStorms
{
Never = -1,
Chance,
Always
}
internal enum FogQuality
{
Default,
Medium,
High
}
internal struct MoonCavernMapping
{
internal string moon;
internal CavernType type;
internal int weight;
}
static ConfigFile configFile;
internal static ConfigEntry<bool> fancyEntranceDoors, recolorRandomRocks, doorLightColors, rainyMarch, eclipsesBlockMusic, autoAdaptSnow, powerOffBreakerBox, powerOffWindows, planetPreview, giantSkins, fixDoorMeshes, fancyFoliage, fancyShrouds, fogReprojection, windowVariants, fixTitanVolume, fixArtificeVolume;
internal static ConfigEntry<GordionStorms> stormyGordion;
internal static ConfigEntry<FogQuality> fogQuality;
internal static ConfigEntry<float> weatherAmbience;
internal static List<MoonCavernMapping> mappings = [];
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.");
fancyShrouds = configFile.Bind(
"Rendering",
"FancyShrouds",
true,
"Applies FancyFoliage's changes to Vain Shrouds as well. (Really puts the \"vain\" in Vain Shrouds.)");
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",
false,
"\"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()
{
fancyEntranceDoors = configFile.Bind(
"Exterior",
"FancyEntranceDoors",
true,
"Changes the front doors to match how they look on the inside when a manor interior generates. (Works for ONLY vanilla levels!)");
recolorRandomRocks = configFile.Bind(
"Exterior",
"RecolorRandomRocks",
true,
"Recolors random boulders to be white on snowy moons so they blend in better.");
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.");
eclipsesBlockMusic = configFile.Bind(
"Exterior",
"EclipsesBlockMusic",
true,
"Prevents the morning/afternoon ambience music from playing during Eclipsed weather, which has its own ambient track.");
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.7f,
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.");
windowVariants = configFile.Bind(
"Interior.Manor",
"WindowVariants",
true,
"The images displayed on the \"fake windows\" will change depending on the moon's exterior.");
}
static void InteriorMineshaftConfig()
{
PopulateGlobalListWithCavernType(CavernType.Vanilla, "Vow:100,March:100,Adamance:100,Artifice:80");
PopulateGlobalListWithCavernType(CavernType.Mesa, "Experimentation:100,Titan:100");
PopulateGlobalListWithCavernType(CavernType.Desert, "Assurance:100,Offense:100");
PopulateGlobalListWithCavernType(CavernType.Ice, "Rend:100,Dine:100");
PopulateGlobalListWithCavernType(CavernType.Amethyst, "Embrion:100");
PopulateGlobalListWithCavernType(CavernType.Gravel, "Artifice:20");
autoAdaptSnow = configFile.Bind(
"Interior.Mineshaft",
"AutoAdaptSnow",
true,
"Automatically enable ice caverns on modded levels that are snowy.\nIf you have Artifice Blizzard installed, this will also change the caverns to ice specifically when the blizzard is active.");
}
static void PopulateGlobalListWithCavernType(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.)"
+ (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;
}
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)
{
MoonCavernMapping mapping = new()
{
moon = moonAndWeight[0].ToLower(),
type = type,
weight = (int)Mathf.Clamp(weight, 1f, 99999f)
};
mappings.Add(mapping);
Plugin.Logger.LogDebug($"Successfully added \"{mapping.moon}\" to \"{mapping.type}\" caves 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 //(System.Exception e)
{
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 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);
}
if (fancyShrouds.Value)
{
if (!configFile.Bind("Exterior", "FancyShrouds", true, "Legacy setting, doesn't work").Value)
fancyShrouds.Value = false;
configFile.Remove(configFile["Exterior", "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.Save();
}
}
}