-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlugin.cs
More file actions
549 lines (453 loc) · 27.4 KB
/
Plugin.cs
File metadata and controls
549 lines (453 loc) · 27.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
using BarberFixes;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using static UnityEngine.Rendering.DebugUI;
namespace ClaySurgeonOverhaul
{
[BepInPlugin(PLUGIN_GUID, PLUGIN_NAME, PLUGIN_VERSION)]
[BepInDependency("butterystancakes.lethalcompany.ventspawnfix")]
[BepInDependency("butterystancakes.lethalcompany.barberfixes")]
[BepInDependency(LETHAL_CONFIG, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(LOBBY_COMPATIBILITY, BepInDependency.DependencyFlags.SoftDependency)]
public class Plugin : BaseUnityPlugin
{
static ConfigFile configFile;
internal const string PLUGIN_GUID = "dopadream.lethalcompany.ClaySurgeonOverhaul", PLUGIN_NAME = "Clay Surgeon Overhaul", PLUGIN_VERSION = "1.4.0", LETHAL_CONFIG = "ainavt.lc.lethalconfig", LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility";
internal static new ManualLogSource Logger;
internal static GameObject clayPrefab;
internal static GameObject sleepyFilterPrefab;
internal static AudioClip snipClip;
internal static TerminalNode clayNode;
internal static EnemyType dummyType;
internal static Dictionary<string, EnemyType> allEnemiesList = [];
internal static ConfigEntry<bool> configSpawnOverride, configInfestations, configCurve, configKlayWorld;
internal static ConfigEntry<int> configMaxCount, configPowerLevel, configSpawnInGroupsOf;
internal static ConfigEntry<float> configAmbience, configIridescence, configMinVisibility, configMaxVisibility, configScreenEffects, configScreenDistortion;
internal static ConfigEntry<float> configSkin0, configSkin1, configSkin2, configSkin3, configSkin4, configSkin5, configSkin6, configSkin7, configSkin8, configSkin9, configSkin10;
internal static System.Random clayRandom;
static Dictionary<Texture, IntWithRarity[]> clayWeightList = [];
internal static Texture claySkinPurple, claySkinRed, claySkinGreen, claySkinYellow, claySkinOrange, claySkinWhite, claySkinBlack, claySkinPink, claySkinTeal, claySkinCyan, claySkinMagenta;
internal static AnimationCurve intervalCurve;
protected const string anchorPath = "MeshContainer";
protected const string animPath = "MeshContainer/AnimContainer";
protected const string renderPath = "Systems/Rendering";
internal void initLethalConfig()
{
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.BoolCheckBoxConfigItem(configSpawnOverride, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.IntInputFieldConfigItem(configMaxCount, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.IntInputFieldConfigItem(configSpawnInGroupsOf, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.IntInputFieldConfigItem(configPowerLevel, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configMinVisibility, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configMaxVisibility, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configScreenEffects, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configScreenDistortion, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.BoolCheckBoxConfigItem(configInfestations, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.BoolCheckBoxConfigItem(configCurve, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configAmbience, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configIridescence, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin0, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin1, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin2, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin3, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin4, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin5, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin6, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin7, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.FloatSliderConfigItem(configSkin8, false));
LethalConfig.LethalConfigManager.AddConfigItem(new LethalConfig.ConfigItems.BoolCheckBoxConfigItem(configKlayWorld, false));
LethalConfig.LethalConfigManager.SkipAutoGen();
}
void Awake()
{
Logger = base.Logger;
configFile = Config;
intervalCurve = new(
new(0f, 2.75f),
new(0.05f, 2.375f),
new(0.1f, 2.05f),
new(0.15f, 1.8f),
new(0.2f, 1.59f),
new(0.25f, 1.41f),
new(0.3f, 1.27f),
new(0.35f, 1.165f),
new(0.4f, 1.1f),
new(0.45f, 1.05f),
new(0.5f, 1.02f),
new(0.6f, 1f)
);
configSpawnOverride = configFile.Bind("General", "Override Spawn Settings", true,
new ConfigDescription("Overrides spawning logic of Clay Surgeons (Barbers). With this enabled, they will spawn in pairs and be more common. Disable if you want to customize their spawning yourself through plugins such as LethalQuantities."));
configMaxCount = configFile.Bind("General", "Max Spawn Count", 6,
new ConfigDescription("Defines the max spawn count of Clay Surgeons. Override Spawn Settings must be turned on."));
configSpawnInGroupsOf = configFile.Bind("General", "Spawn Group Count", 2,
new ConfigDescription("Defines how many Clay Surgeons spawn in one vent. Override Spawn Settings must be turned on."));
configPowerLevel = configFile.Bind("General", "Power Level", 2,
new ConfigDescription("Defines the power level of Clay Surgeons. Override Spawn Settings must be turned on."));
configMinVisibility = configFile.Bind("General", "Minimum Visibility Distance", 5f,
new ConfigDescription(
"Controls the distance at which the Clay Surgeon is fully visible.",
new AcceptableValueRange<float>(5.0f, 15.0f)));
configMaxVisibility = configFile.Bind("General", "Maximum Visibility Distance", 15f,
new ConfigDescription(
"Controls the distance at which the Clay Surgeon is fully invisible.",
new AcceptableValueRange<float>(7.0f, 15.0f)));
configInfestations = configFile .Bind("General", "Clay Infestations", true,
new ConfigDescription("Adds a chance for Hoarding bug/Nutcracker infestations to be Clay Surgeon Infestations instead."));
configCurve = configFile.Bind("General", "Curved Acceleration", true,
new ConfigDescription("Makes the Clay Surgeon accelerate at a curve rather than a flat rate per hour."));
configAmbience = configFile.Bind("Aesthetics", "Proximity Ambience Volume", 0.35f,
new ConfigDescription(
"Controls the volume of the Clay Surgeon's proximity ambience.",
new AcceptableValueRange<float>(0.0f, 1.0f)));
configScreenEffects = configFile.Bind("Aesthetics", "Screen Effect Intensity", 0.5f,
new ConfigDescription(
"Controls the intensity of the \"sleepiness\" filter when in proximity with a Clay Surgeon.",
new AcceptableValueRange<float>(0.0f, 1.0f)));
configScreenDistortion = configFile.Bind("Aesthetics", "Screen Distortion Intensity", -1.0f,
new ConfigDescription(
"Controls the intensity of the \"sleepiness\" filter's lens distortion when in proximity with a Clay Surgeon.",
new AcceptableValueRange<float>(-1.0f, 1.0f)));
configIridescence = configFile.Bind("Aesthetics", "Iridescence", 0.25f,
new ConfigDescription(
"Controls the iridescence of the Clay Surgeon's clay material.",
new AcceptableValueRange<float>(0.0f, 1.0f)));
configSkin0 = configFile.Bind("Skins", "Default", 300.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin1 = configFile.Bind("Skins", "Red Delicious", 300.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin2 = configFile.Bind("Skins", "Eraser Pink", 0.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin3 = configFile.Bind("Skins", "Snipsy Blue", 0.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin4 = configFile.Bind("Skins", "Slimy Green", 300.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin5 = configFile.Bind("Skins", "Taffy Yellow", 0.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin6 = configFile.Bind("Skins", "Tan Orange", 0.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin7 = configFile.Bind("Skins", "Cheery Cyan", 0.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin8 = configFile.Bind("Skins", "Merry Magenta", 0.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin9 = configFile.Bind("Skins", "Isolated White", 0.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configSkin10 = configFile.Bind("Skins", "Ink Black", 0.0f,
new ConfigDescription(
"Controls the rarity of this skin.",
new AcceptableValueRange<float>(0.0f, 300.0f)));
configKlayWorld = configFile.Bind("Fun", "Klay World", false,
new ConfigDescription("Guarantees clay infestations when possible. Clay infestations must be turned on!"));
if (Chainloader.PluginInfos.ContainsKey(LETHAL_CONFIG))
{
initLethalConfig();
}
//Credits to ButteryStancakes for asset loading code!
try
{
AssetBundle claysurgeonbundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "claysurgeonoverhaul"));
clayPrefab = claysurgeonbundle.LoadAsset("ClaySurgeonNew", typeof(GameObject)) as GameObject;
sleepyFilterPrefab = claysurgeonbundle.LoadAsset("SleepyFilter", typeof(GameObject)) as GameObject;
clayNode = claysurgeonbundle.LoadAsset("ClaySurgeonFile", typeof(TerminalNode)) as TerminalNode;
dummyType = claysurgeonbundle.LoadAsset("DummyEnemyType", typeof(EnemyType)) as EnemyType;
snipClip = claysurgeonbundle.LoadAsset<AudioClip>("snip_flesh");
claySkinPurple = claysurgeonbundle.LoadAsset("cs_default", typeof(Texture)) as Texture;
claySkinRed = claysurgeonbundle.LoadAsset("cs_red_delicious", typeof(Texture)) as Texture;
claySkinPink = claysurgeonbundle.LoadAsset("cs_eraser_pink", typeof(Texture)) as Texture;
claySkinTeal = claysurgeonbundle.LoadAsset("cs_snipsy_blue", typeof(Texture)) as Texture;
claySkinGreen = claysurgeonbundle.LoadAsset("cs_slimy_green", typeof(Texture)) as Texture;
claySkinYellow = claysurgeonbundle.LoadAsset("cs_taffy_yellow", typeof(Texture)) as Texture;
claySkinOrange = claysurgeonbundle.LoadAsset("cs_tan_orange", typeof(Texture)) as Texture;
claySkinCyan = claysurgeonbundle.LoadAsset("cs_cheery_cyan", typeof(Texture)) as Texture;
claySkinMagenta = claysurgeonbundle.LoadAsset("cs_merry_magenta", typeof(Texture)) as Texture;
claySkinWhite = claysurgeonbundle.LoadAsset("cs_isolated_white", typeof(Texture)) as Texture;
claySkinBlack = claysurgeonbundle.LoadAsset("cs_shadow_black", typeof(Texture)) as Texture;
}
catch
{
Logger.LogError("Encountered some error loading asset bundle. Did you install the plugin correctly?");
return;
}
new Harmony(PLUGIN_GUID).PatchAll();
Logger.LogInfo($"{PLUGIN_NAME} v{PLUGIN_VERSION} loaded");
}
[HarmonyPatch]
class ClaySurgeonPatches
{
[HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")]
[HarmonyPostfix]
static void RoundManagerPostRefresh(RoundManager __instance, ref int ___enemyRushIndex)
{
DateTime dateTime = new DateTime(DateTime.Now.Year, 10, 31);
bool num = DateTime.Today == dateTime;
System.Random random2 = new System.Random(StartOfRound.Instance.randomMapSeed + 5781);
if ((num && random2.Next(0, 210) < 3) || random2.Next(0, 1000) < 15 || Plugin.configKlayWorld.Value)
{
if (___enemyRushIndex == -1 && Plugin.configInfestations.Value)
{
for (int j = 0; j < __instance.currentLevel.Enemies.Count; j++)
{
if (__instance.currentLevel.Enemies[j].enemyType.enemyName == "Clay Surgeon")
{
if (__instance.currentLevel.Enemies[j].enemyType.MaxCount > 1)
{
Logger.LogDebug("Clay infestation started!");
(__instance.indoorFog).gameObject.SetActive(random2.Next(0, 100) < 20);
___enemyRushIndex = j;
__instance.currentMaxInsidePower = __instance.currentLevel.Enemies[j].enemyType.PowerLevel * __instance.currentLevel.Enemies[j].enemyType.MaxCount;
break;
}
}
}
}
}
clayRandom = new System.Random(StartOfRound.Instance.randomMapSeed);
}
static Texture getRandomSkin(System.Random random)
{
clayWeightList.Clear();
int percent = random.Next(0, 300);
var configValues = new[]
{
(int)configSkin0.Value,
(int)configSkin1.Value,
(int)configSkin2.Value,
(int)configSkin3.Value,
(int)configSkin4.Value,
(int)configSkin5.Value,
(int)configSkin6.Value,
(int)configSkin7.Value,
(int)configSkin8.Value,
(int)configSkin9.Value,
(int)configSkin10.Value
};
var claySkins = new[]
{
claySkinPurple,
claySkinRed,
claySkinPink,
claySkinTeal,
claySkinGreen,
claySkinYellow,
claySkinOrange,
claySkinCyan,
claySkinMagenta,
claySkinWhite,
claySkinBlack
};
List<int> matchingIndices = new List<int>();
for (int i = 0; i < configValues.Length; i++)
{
if (configValues[i] != 0 && percent <= configValues[i])
{
matchingIndices.Add(i);
}
}
if (matchingIndices.Count > 0)
{
return claySkins[RoundManager.Instance.GetRandomWeightedIndex(configValues.ToArray(), random)];
}
// Default return value if no condition is met
return claySkinPurple;
}
[HarmonyPatch(typeof(QuickMenuManager), "Start")]
[HarmonyPostfix]
static void QuickMenuManagerPostStart(QuickMenuManager __instance)
{
//HDRenderPipelineAsset assetHDRP = QualitySettings.renderPipeline as HDRenderPipelineAsset;
//if (assetHDRP == null) return;
//RenderPipelineSettings settings = assetHDRP.currentPlatformRenderPipelineSettings;
//settings.supportMotionVectors = true;
//assetHDRP.currentPlatformRenderPipelineSettings = settings;
GameObject sleepyFilter = Instantiate(sleepyFilterPrefab, GameObject.Find(renderPath).transform);
allEnemiesList.Clear();
List<SpawnableEnemyWithRarity>[] allEnemyLists =
[
__instance.testAllEnemiesLevel.Enemies
];
if (!Plugin.configSpawnOverride.Value)
return;
foreach (List<SpawnableEnemyWithRarity> enemies in allEnemyLists)
{
foreach (SpawnableEnemyWithRarity spawnableEnemyWithRarity in enemies)
{
string enemyName = spawnableEnemyWithRarity.enemyType.name;
if (allEnemiesList.ContainsKey(enemyName))
{
if (allEnemiesList[enemyName] == spawnableEnemyWithRarity.enemyType)
{
Plugin.Logger.LogWarning($"allEnemiesList: Tried to cache reference to \"{enemyName}\" more than once");
}
else
{
Plugin.Logger.LogWarning($"allEnemiesList: Tried to cache two different enemies by same name ({enemyName})");
}
continue;
}
if (spawnableEnemyWithRarity.enemyType.enemyName == "Clay Surgeon")
{
spawnableEnemyWithRarity.enemyType.spawnInGroupsOf = configSpawnInGroupsOf.Value;
spawnableEnemyWithRarity.enemyType.MaxCount = configMaxCount.Value;
spawnableEnemyWithRarity.enemyType.PowerLevel = configPowerLevel.Value;
spawnableEnemyWithRarity.enemyType.probabilityCurve = dummyType.probabilityCurve;
spawnableEnemyWithRarity.enemyType.numberSpawnedFalloff = dummyType.numberSpawnedFalloff;
spawnableEnemyWithRarity.enemyType.useNumberSpawnedFalloff = true;
Logger.LogDebug("Barber spawn settings overridden!");
return;
}
}
}
}
[HarmonyPatch(typeof(ClaySurgeonAI), "Awake")]
[HarmonyPostfix]
static void ClaySurgeonAIPostWake(ClaySurgeonAI __instance)
{
Destroy(__instance.creatureAnimator.gameObject);
Transform clayClone = Instantiate(clayPrefab, __instance.transform.position, __instance.transform.rotation, __instance.transform.Find(anchorPath)).transform;
__instance.creatureAnimator = clayClone.GetComponentInChildren<Animator>();
__instance.skin = clayClone.GetComponentInChildren<SkinnedMeshRenderer>();
__instance.snipScissors = snipClip;
__instance.gameObject.GetComponentInChildren<ScanNodeProperties>().headerText = "Clay Surgeon";
__instance.skinnedMeshRenderers = clayClone.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
__instance.meshRenderers = clayClone.gameObject.GetComponentsInChildren<MeshRenderer>();
__instance.skin.sharedMaterials[0].mainTexture = getRandomSkin(clayRandom);
__instance.skin.material.SetFloat("_IridescenceMask", Plugin.configIridescence.Value);
clayClone.GetComponentInChildren<EnemyAnimationEvent>().mainScript = __instance.gameObject.GetComponentInChildren<EnemyAnimationEvent>().mainScript;
}
[HarmonyPatch(typeof(ClaySurgeonAI), "Start")]
[HarmonyPostfix]
static void ClaySurgeonAIPostStart(ClaySurgeonAI __instance)
{
Material[] barberMats = new Material[__instance.skin.sharedMaterials.Length];
for (int i = 0; i < barberMats.Length; i++)
barberMats[i] = Instantiate(__instance.skin.materials[i]);
__instance.skin.sharedMaterials = barberMats;
AudioSource[] sources = __instance.gameObject.GetComponentsInChildren<AudioSource>();
foreach (AudioSource source in sources)
{
if (source.clip.name == "csambience")
{
source.volume = configAmbience.Value;
break;
}
}
}
[HarmonyPatch(typeof(ClaySurgeonAI), "Update")]
[HarmonyPostfix]
static void ClaySurgeonAIPostUpdate(ClaySurgeonAI __instance)
{
GameObject sleepyFilter = GameObject.Find("Systems/Rendering/SleepyFilter(Clone)");
if (__instance.isMaster)
{
float minDist = float.MaxValue;
for (int i = 0; i < __instance.allClaySurgeons.Count; i++)
{
if (!(__instance.allClaySurgeons[i] == null) && !__instance.allClaySurgeons[i].isEnemyDead)
{
float dist = Vector3.Distance(StartOfRound.Instance.audioListener.transform.position, __instance.allClaySurgeons[i].transform.position + Vector3.up * 0.7f);
if (dist < minDist)
{
minDist = dist;
}
}
}
if (sleepyFilter != null)
{
sleepyFilter.GetComponentInChildren<Volume>().weight = Math.Clamp(-(minDist - (__instance.minDistance + 8)) / ((__instance.maxDistance + 8) - (__instance.minDistance + 8)), 0, 0.75f);
}
else
{
Plugin.Logger.LogError("sleepyFilter is null!");
}
}
}
[HarmonyPatch(typeof(ClaySurgeonAI), "SetVisibility")]
[HarmonyPostfix]
static void ClaySurgeonAIPostSetVis(ClaySurgeonAI __instance)
{
float num = Vector3.Distance(StartOfRound.Instance.audioListener.transform.position, __instance.transform.position + Vector3.up * 0.7f);
__instance.minDistance = configMinVisibility.Value;
__instance.maxDistance = configMaxVisibility.Value;
Material[] barberMats = __instance.skin.sharedMaterials;
foreach (Material barberMat in barberMats)
barberMat.SetFloat("_AlphaCutoff", (num - __instance.minDistance) / (__instance.maxDistance - __instance.minDistance));
}
[HarmonyPatch(typeof(DanceClock), nameof(DanceClock.Tick))]
[HarmonyPrefix]
static bool DanceClockPreTick()
{
if (Plugin.configCurve.Value)
{
float currentInterval = Mathf.Clamp(intervalCurve.Evaluate((float)TimeOfDay.Instance.hour / TimeOfDay.Instance.numberOfHours), 1.25f, 2.75f);
foreach (EnemyAI enemy in RoundManager.Instance.SpawnedEnemies)
{
if (enemy is ClaySurgeonAI barber)
{
barber.currentInterval = currentInterval;
}
}
// skip the original function
return false;
}
// just do the original function
return true;
}
[HarmonyPatch(typeof(Terminal), "Awake")]
[HarmonyPostfix]
static void TerminalPostWake(Terminal __instance)
{
TerminalKeyword[] keywords = __instance.terminalNodes.allKeywords;
List<TerminalNode> nodes = __instance.enemyFiles;
foreach (TerminalNode node in nodes)
{
if (node.creatureFileID == 24)
{
node.displayVideo = clayNode.displayVideo;
node.displayText = clayNode.displayText;
node.creatureName = clayNode.creatureName;
foreach (TerminalKeyword keyword in keywords)
{
if (keyword.word == "barber")
{
keyword.word = "clay surgeon";
return;
}
}
Logger.LogDebug("Barber bestiary entry replaced!");
return;
}
}
}
}
}
}