forked from dvize/Donuts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultPluginVars.cs
840 lines (726 loc) · 35.3 KB
/
DefaultPluginVars.cs
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
using System;
using System.Collections.Generic;
using System.Reflection;
using Donuts.Models;
using Newtonsoft.Json;
using UnityEngine;
#pragma warning disable IDE0007, IDE0044
namespace Donuts
{
internal static class DefaultPluginVars
{
// Main Settings
internal static Setting<bool> PluginEnabled;
internal static Setting<bool> DespawnEnabledPMC;
internal static Setting<bool> DespawnEnabledSCAV;
internal static Setting<bool> HardCapEnabled;
internal static Setting<float> coolDownTimer;
internal static Setting<string> pmcGroupChance;
internal static Setting<string> scavGroupChance;
internal static Setting<string> botDifficultiesPMC;
internal static Setting<string> botDifficultiesSCAV;
internal static Setting<string> botDifficultiesOther;
internal static Setting<bool> ShowRandomFolderChoice;
internal static Setting<string> pmcFaction;
internal static Setting<string> forceAllBotType;
internal static Setting<bool> useTimeBasedHardStop;
internal static Setting<bool> hardStopOptionPMC;
internal static Setting<int> hardStopTimePMC;
internal static Setting<int> hardStopPercentPMC;
internal static Setting<bool> hardStopOptionSCAV;
internal static Setting<int> hardStopTimeSCAV;
internal static Setting<int> hardStopPercentSCAV;
internal static Setting<bool> hotspotBoostPMC;
internal static Setting<bool> hotspotBoostSCAV;
internal static Setting<bool> hotspotIgnoreHardCapPMC;
internal static Setting<bool> hotspotIgnoreHardCapSCAV;
internal static Setting<int> pmcFactionRatio;
internal static Setting<float> battleStateCoolDown;
// Global Minimum Spawn Distance From Player
internal static Setting<bool> globalMinSpawnDistanceFromPlayerBool;
internal static Setting<float> globalMinSpawnDistanceFromPlayerFactory;
internal static Setting<float> globalMinSpawnDistanceFromPlayerCustoms;
internal static Setting<float> globalMinSpawnDistanceFromPlayerReserve;
internal static Setting<float> globalMinSpawnDistanceFromPlayerStreets;
internal static Setting<float> globalMinSpawnDistanceFromPlayerWoods;
internal static Setting<float> globalMinSpawnDistanceFromPlayerLaboratory;
internal static Setting<float> globalMinSpawnDistanceFromPlayerShoreline;
internal static Setting<float> globalMinSpawnDistanceFromPlayerGroundZero;
internal static Setting<float> globalMinSpawnDistanceFromPlayerInterchange;
internal static Setting<float> globalMinSpawnDistanceFromPlayerLighthouse;
// Global Minimum Spawn Distance From Other Bots
internal static Setting<bool> globalMinSpawnDistanceFromOtherBotsBool;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsFactory;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsCustoms;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsReserve;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsStreets;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsWoods;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsLaboratory;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsShoreline;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsGroundZero;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsInterchange;
internal static Setting<float> globalMinSpawnDistanceFromOtherBotsLighthouse;
// Advanced Settings
internal static Setting<float> replenishInterval;
internal static Setting<int> maxSpawnTriesPerBot;
internal static Setting<float> despawnInterval;
internal static Setting<string> groupWeightDistroLow;
internal static Setting<string> groupWeightDistroDefault;
internal static Setting<string> groupWeightDistroHigh;
// Debugging
internal static Setting<bool> DebugGizmos;
internal static Setting<bool> gizmoRealSize;
// Spawn Point Maker
internal static Setting<string> spawnName;
internal static Setting<int> groupNum;
internal static Setting<string> wildSpawns;
internal static Setting<float> minSpawnDist;
internal static Setting<float> maxSpawnDist;
internal static Setting<float> botTriggerDistance;
internal static Setting<float> botTimerTrigger;
internal static Setting<int> maxRandNumBots;
internal static Setting<int> spawnChance;
internal static Setting<int> maxSpawnsBeforeCooldown;
internal static Setting<bool> ignoreTimerFirstSpawn;
internal static Setting<float> minSpawnDistanceFromPlayer;
internal static Setting<KeyCode> CreateSpawnMarkerKey;
internal static Setting<KeyCode> DeleteSpawnMarkerKey;
internal static string[] wildSpawnTypes =
{
"arenafighterevent",
"assault",
"assaultgroup",
"bossboar",
"bossboarsniper",
"bossbully",
"bossgluhar",
"bosskilla",
"bossknight",
"bosskojaniy",
"bosssanitar",
"bosstagilla",
"bosszryachiy",
"crazyassaultevent",
"cursedassault",
"exusec-rogues",
"raiders",
"followerbigpipe",
"followerbirdeye",
"followerboar",
"followerbully",
"followergluharassault",
"followergluharscout",
"followergluharsecurity",
"followergluharsnipe",
"followerkojaniy",
"followersanitar",
"followertagilla",
"followerzryachiy",
"gifter",
"marksman",
"pmc",
"sectantpriest",
"sectantwarrior",
"sptusec",
"sptbear",
};
// Save Settings
internal static Setting<bool> saveNewFileOnly;
internal static Setting<KeyCode> WriteToFileKey;
public static Dictionary<string, int[]> groupChanceWeights = new Dictionary<string, int[]>
{
{ "Low", new int[] { 400, 90, 9, 0, 0 } },
{ "Default", new int[] { 210, 210, 45, 25, 10 } },
{ "High", new int[] { 0, 75, 175, 175, 75 } }
};
static string defaultWeightsString = ConvertIntArrayToString(groupChanceWeights["Default"]);
static string lowWeightsString = ConvertIntArrayToString(groupChanceWeights["Low"]);
static string highWeightsString = ConvertIntArrayToString(groupChanceWeights["High"]);
internal static string[] pmcGroupChanceList = { "None", "Default", "Low", "High", "Max", "Random" };
internal static string[] scavGroupChanceList = { "None", "Default", "Low", "High", "Max", "Random" };
internal static string[] pmcFactionList = { "Default", "USEC", "BEAR" };
internal static string[] forceAllBotTypeList = { "Disabled", "SCAV", "PMC" };
internal static string ConvertIntArrayToString(int[] array)
{
return string.Join(",", array);
}
//IMGUI Vars
internal static int selectedTabIndex = 0;
internal static int selectedSubTabIndex = 0;
internal static string[] tabNames = { "Main Settings", "Spawn Settings", "Advanced Settings", "SpawnPoint Maker", "Debugging" };
internal static bool showGUI = false;
internal static string[] botDiffList = { "AsOnline", "Easy", "Normal", "Hard", "Impossible" };
internal static Rect windowRect = new Rect(20, 20, 1664, 936); // Default position and size
//Scenario Selection
internal static List<Folder> pmcScenarios = new List<Folder>();
internal static List<Folder> pmcRandomScenarios = new List<Folder>();
internal static List<Folder> scavScenarios = new List<Folder>();
internal static List<Folder> randomScavScenarios = new List<Folder>();
internal static Setting<string> pmcScenarioSelection;
internal static Setting<string> scavScenarioSelection;
internal static string[] pmcScenarioCombinedArray;
internal static string[] scavScenarioCombinedArray;
//Default Constructor
static DefaultPluginVars()
{
// Main Settings
PluginEnabled = new Setting<bool>(
"Donuts On",
"Enable/Disable Spawning from Donuts Points",
true,
true);
DespawnEnabledPMC = new Setting<bool>(
"Despawn PMCs",
"When enabled, removes furthest PMC bots from player for each new dynamic spawn bot that is over your Donuts bot caps (ScenarioConfig.json).",
true,
true);
DespawnEnabledSCAV = new Setting<bool>(
"Despawn SCAVs",
"When enabled, removes furthest SCAV bots from player for each new dynamic spawn bot that is over your Donuts bot caps (ScenarioConfig.json).",
true,
true);
HardCapEnabled = new Setting<bool>(
"Bot Hard Cap Option",
"When enabled, all bot spawns will be hard capped by your preset caps. In other words, if your bot count is at the total Donuts cap then no more bots will spawn until one dies (vanilla SPT behavior).",
false,
false);
coolDownTimer = new Setting<float>(
"Cool Down Timer",
"Cool Down Timer for after a spawn has successfully spawned a bot the spawn marker's MaxSpawnsBeforeCoolDown",
300f,
300f,
0f,
1000f);
pmcGroupChance = new Setting<string>(
"Donuts PMC Group Chance",
"Setting to determine the odds of PMC groups and group size. All odds are configurable, check Advanced Settings above. See mod page for more details.",
"Default",
"Default",
null,
null,
pmcGroupChanceList);
scavGroupChance = new Setting<string>(
"Donuts SCAV Group Chance",
"Setting to determine the odds of SCAV groups and group size. All odds are configurable, check Advanced Settings above. See mod page for more details. See mod page for more details.",
"Default",
"Default",
null,
null,
scavGroupChanceList);
botDifficultiesPMC = new Setting<string>(
"Donuts PMC Spawn Difficulty",
"Difficulty Setting for All PMC Donuts Related Spawns",
"Normal",
"Normal",
null,
null,
botDiffList);
botDifficultiesSCAV = new Setting<string>(
"Donuts SCAV Spawn Difficulty",
"Difficulty Setting for All SCAV Donuts Related Spawns",
"Normal",
"Normal",
null,
null,
botDiffList
);
botDifficultiesOther = new Setting<string>(
"Other Bot Type Spawn Difficulty",
"Difficulty Setting for all other bot types spawned with Donuts, such as bosses, Rogues, Raiders, etc.",
"Normal",
"Normal",
null,
null,
botDiffList
);
ShowRandomFolderChoice = new Setting<bool>(
"Show Random Spawn Preset Selection",
"Shows the Random Spawn Preset Selected on Raid Start in bottom right",
true,
true);
pmcFaction = new Setting<string>(
"Force PMC Faction",
"Force a specific faction for all PMC spawns or use the default specified faction in the Donuts spawn files. Default is a random faction.",
"Default",
"Default",
null,
null,
pmcFactionList
);
forceAllBotType = new Setting<string>(
"Force Bot Type for All Spawns",
"Force a specific faction for all PMC spawns or use the default specified faction in the Donuts spawn files. Default is a random faction.",
"Disabled",
"Disabled",
null,
null,
forceAllBotTypeList
);
useTimeBasedHardStop = new Setting<bool>(
"Use Time-Based Hard Stop",
"If enabled, the hard stop settings will be the time (in seconds) left in raid (configurable below). If disabled, the hard stop settings will be the percentage of time left in raid (configurable below).",
true,
true);
hardStopOptionPMC = new Setting<bool>(
"PMC Spawn Hard Stop",
"If enabled, all PMC spawns stop completely once there is n time or percentage time left in your raid. This is configurable in either seconds or percentage (see below).",
false,
false);
hardStopPercentPMC = new Setting<int>(
"PMC Spawn Hard Stop: Percent Left of Raid",
"The percentage of time left in your raid that will stop any further PMC spawns (if option is enabled). Default is 50 percent of the full raid time.",
50,
50,
0,
100);
hardStopTimePMC = new Setting<int>(
"PMC Spawn Hard Stop: Time Left in Raid",
"The time (in seconds) left in your raid that will stop any further PMC spawns (if option is enabled). Default is 300 (5 minutes).",
300,
300);
hardStopPercentPMC = new Setting<int>(
"PMC Spawn Hard Stop: Percent Left of Raid",
"The percentage of time left in your raid that will stop any further PMC spawns (if option is enabled). Default is 50 percent of the full raid time.",
50,
50,
0,
100);
hardStopOptionSCAV = new Setting<bool>(
"SCAV Spawn Hard Stop",
"If enabled, all SCAV spawns stop completely once there is n time or percentage time left in your raid. This is configurable in either seconds or percentage (see below).",
false,
false);
hardStopTimeSCAV = new Setting<int>(
"SCAV Spawn Hard Stop: Time Left in Raid",
"The time (in seconds) left in your raid that will stop any further SCAV spawns (if option is enabled). Default is 300 (5 minutes).",
300,
300);
hardStopPercentSCAV = new Setting<int>(
"SCAV Spawn Hard Stop: Percent Left of Raid",
"The percentage of time left in your raid that will stop any further SCAV spawns (if option is enabled). Default is 10 percent of the full raid time.",
10,
10,
0,
100);
hotspotBoostPMC = new Setting<bool>(
"PMC Hot Spot Spawn Boost",
"If enabled, all hotspot points have a much higher chance of spawning more PMCs.",
false,
false);
hotspotBoostSCAV = new Setting<bool>(
"SCAV Hot Spot Spawn Boost",
"If enabled, all hotspot points have a much higher chance of spawning more SCAVs.",
false,
false);
hotspotIgnoreHardCapPMC = new Setting<bool>(
"PMC Hot Spot Ignore Hard Cap",
"If enabled, all hotspot spawn points will ignore the hard cap (if enabled). This applies to any spawn points labeled with 'Hotspot'. I recommended using this option with Despawn + Hardcap + Boost for the best experience with more action in hot spot areas.",
false,
false);
hotspotIgnoreHardCapSCAV = new Setting<bool>(
"SCAV Hot Spot Ignore Hard Cap",
"If enabled, all hotspot spawn points will ignore the hard cap (if enabled). This applies to any spawn points labeled with 'Hotspot'. I recommended using this option with Despawn + Hardcap + Boost for the best experience with more action in hot spot areas.",
false,
false);
pmcFactionRatio = new Setting<int>(
"PMC Faction Ratio",
"USEC/Bear Default Ratio. Default is 50%. Lower value = lower USEC chance, so: 20 would be 20% USEC, 80% Bear, etc.",
50,
50);
battleStateCoolDown = new Setting<float>(
"Battlestate Spawn CoolDown",
"It will stop spawning bots until you haven't been hit for X amount of seconds\nas you are still considered being in battle",
20f,
20f);
// Global Minimum Spawn Distance From Player
#region global mininum spawn distances
globalMinSpawnDistanceFromPlayerBool = new Setting<bool>(
"Use Global Min Distance From Player",
"If enabled, all spawns on all presets will use the global minimum spawn distance from player for each map defined below.",
false,
false);
globalMinSpawnDistanceFromPlayerFactory = new Setting<float>(
"Factory",
"Distance (in meters) that bots should spawn away from the player (you).",
35f,
35f);
globalMinSpawnDistanceFromPlayerCustoms = new Setting<float>(
"Customs",
"Distance (in meters) that bots should spawn away from the player (you).",
60f,
60f);
globalMinSpawnDistanceFromPlayerReserve = new Setting<float>(
"Reserve",
"Distance (in meters) that bots should spawn away from the player (you).",
80f,
80f);
globalMinSpawnDistanceFromPlayerStreets = new Setting<float>(
"Streets",
"Distance (in meters) that bots should spawn away from the player (you).",
80f,
80f);
globalMinSpawnDistanceFromPlayerWoods = new Setting<float>(
"Woods",
"Distance (in meters) that bots should spawn away from the player (you).",
125f,
125f);
globalMinSpawnDistanceFromPlayerLaboratory = new Setting<float>(
"Laboratory",
"Distance (in meters) that bots should spawn away from the player (you).",
40f,
40f);
globalMinSpawnDistanceFromPlayerShoreline = new Setting<float>(
"Shoreline",
"Distance (in meters) that bots should spawn away from the player (you).",
100f,
100f);
globalMinSpawnDistanceFromPlayerGroundZero = new Setting<float>(
"Ground Zero",
"Distance (in meters) that bots should spawn away from the player (you).",
65f,
65f);
globalMinSpawnDistanceFromPlayerInterchange = new Setting<float>(
"Interchange",
"Distance (in meters) that bots should spawn away from the player (you).",
85f,
85f);
globalMinSpawnDistanceFromPlayerLighthouse = new Setting<float>(
"Lighthouse",
"Distance (in meters) that bots should spawn away from the player (you).",
70f,
70f);
// Global Minimum Spawn Distance From Other Bots
globalMinSpawnDistanceFromOtherBotsBool = new Setting<bool>(
"Use Global Min Distance From Other Bots",
"If enabled, all spawns on all presets will use the global minimum spawn distance from player for each map defined below.",
false,
false);
globalMinSpawnDistanceFromOtherBotsFactory = new Setting<float>(
"Factory",
"Distance (in meters) that bots should spawn away from other alive bots.",
20f,
20f);
globalMinSpawnDistanceFromOtherBotsCustoms = new Setting<float>(
"Customs",
"Distance (in meters) that bots should spawn away from other alive bots.",
50f,
50f);
globalMinSpawnDistanceFromOtherBotsReserve = new Setting<float>(
"Reserve",
"Distance (in meters) that bots should spawn away from other alive bots.",
50f,
50f);
globalMinSpawnDistanceFromOtherBotsStreets = new Setting<float>(
"Streets",
"Distance (in meters) that bots should spawn away from other alive bots.",
80f,
80f);
globalMinSpawnDistanceFromOtherBotsWoods = new Setting<float>(
"Woods",
"Distance (in meters) that bots should spawn away from other alive bots.",
100f,
100f);
globalMinSpawnDistanceFromOtherBotsLaboratory = new Setting<float>(
"Laboratory",
"Distance (in meters) that bots should spawn away from other alive bots.",
40f,
40f);
globalMinSpawnDistanceFromOtherBotsShoreline = new Setting<float>(
"Shoreline",
"Distance (in meters) that bots should spawn away from other alive bots.",
80f,
80f);
globalMinSpawnDistanceFromOtherBotsGroundZero = new Setting<float>(
"Ground Zero",
"Distance (in meters) that bots should spawn away from other alive bots.",
65f,
65f);
globalMinSpawnDistanceFromOtherBotsInterchange = new Setting<float>(
"Interchange",
"Distance (in meters) that bots should spawn away from other alive bots.",
80f,
80f);
globalMinSpawnDistanceFromOtherBotsLighthouse = new Setting<float>(
"Lighthouse",
"Distance (in meters) that bots should spawn away from other alive bots.",
60f,
60f);
#endregion
// Advanced Settings
replenishInterval = new Setting<float>(
"Bot Cache Replenish Interval",
"The time interval for Donuts to re-fill its bot data cache. Leave default unless you know what you're doing.",
10f,
10f,
0f,
300f);
maxSpawnTriesPerBot = new Setting<int>(
"Max Spawn Tries Per Bot",
"It will stop trying to spawn one of the bots after this many attempts to find a good spawn point. Lower is better",
5,
5,
0,
10);
despawnInterval = new Setting<float>(
"Despawn Bot Interval",
"This value is the number in seconds that Donuts should despawn bots. Default is 10 seconds. Note: decreasing this value may affect your performance.",
30f,
30f,
5f,
600f);
groupWeightDistroLow = new Setting<string>(
"Low",
"Weight Distribution for Group Chance 'Low'. Use relative weights for group sizes 1/2/3/4/5, respectively. Use this formula: group weight / total weight = % chance.",
lowWeightsString,
lowWeightsString);
groupWeightDistroDefault = new Setting<string>(
"Default",
"Weight Distribution for Group Chance 'Default'. Use relative weights for group sizes 1/2/3/4/5, respectively. Use this formula: group weight / total weight = % chance.",
defaultWeightsString,
defaultWeightsString);
groupWeightDistroHigh = new Setting<string>(
"High",
"Weight Distribution for Group Chance 'High'. Use relative weights for group sizes 1/2/3/4/5, respectively. Use this formula: group weight / total weight = % chance.",
highWeightsString,
highWeightsString);
// Debugging
DebugGizmos = new Setting<bool>(
"Enable Debug Markers",
"When enabled, draws debug spheres on set spawn from json",
false,
false);
gizmoRealSize = new Setting<bool>(
"Debug Sphere Real Size",
"When enabled, debug spheres will be the real size of the spawn radius",
false,
false);
// Spawn Point Maker
#region Spawn Point maker
spawnName = new Setting<string>(
"Name",
"Name used to identify the spawn marker",
"Spawn Name Here",
"Spawn Name Here");
groupNum = new Setting<int>(
"Group Number",
"Group Number used to identify the spawn marker",
1,
1,
1,
100);
wildSpawns = new Setting<string>(
"Wild Spawn Type",
"Select an option.",
"pmc",
"pmc",
null,
null,
wildSpawnTypes);
minSpawnDist = new Setting<float>(
"Min Spawn Distance",
"Min Distance Bots will Spawn From Marker You Set.",
1f,
1f,
0f,
500f);
maxSpawnDist = new Setting<float>(
"Max Spawn Distance",
"Max Distance Bots will Spawn From Marker You Set.",
20f,
20f,
1f,
1000f);
botTriggerDistance = new Setting<float>(
"Bot Spawn Trigger Distance",
"Distance in which the player is away from the fight location point that it triggers bot spawn",
100f,
100f,
0.1f,
1000f);
botTimerTrigger = new Setting<float>(
"Bot Spawn Timer Trigger",
"In seconds before it spawns next wave while player in the fight zone area",
180f,
180f,
0f,
10000f);
maxRandNumBots = new Setting<int>(
"Max Random Bots",
"Maximum number of bots of Wild Spawn Type that can spawn on this marker",
2,
2,
1,
5);
spawnChance = new Setting<int>(
"Spawn Chance for Marker",
"Chance bot will be spawn here after timer is reached",
50,
50,
0,
100);
maxSpawnsBeforeCooldown = new Setting<int>(
"Max Spawns Before Cooldown",
"Number of successful spawns before this marker goes in cooldown",
5,
5,
1,
30);
ignoreTimerFirstSpawn = new Setting<bool>(
"Ignore Timer for First Spawn",
"When enabled for this point, it will still spawn even if timer is not ready for first spawn only",
false,
false);
minSpawnDistanceFromPlayer = new Setting<float>(
"Min Spawn Distance From Player",
"How far the random selected spawn near the spawn marker needs to be from player",
40f,
40f,
0f,
500f);
CreateSpawnMarkerKey = new Setting<KeyCode>(
"Create Spawn Marker Key",
"Press this key to create a spawn marker at your current location",
KeyCode.None,
KeyCode.None);
DeleteSpawnMarkerKey = new Setting<KeyCode>(
"Delete Spawn Marker Key",
"Press this key to delete closest spawn marker within 5m of your player location",
KeyCode.None,
KeyCode.None);
// Save Settings
saveNewFileOnly = new Setting<bool>(
"Save New Locations Only",
"If enabled saves the raid session changes to a new file. Disabled saves all locations you can see to a new file.",
false,
false);
WriteToFileKey = new Setting<KeyCode>(
"Create Temp Json File",
"Press this key to write the json file with all entries so far",
KeyCode.KeypadMinus,
KeyCode.KeypadMinus);
#endregion
}
public static string ExportToJson()
{
var settingsDictionary = new Dictionary<string, object>();
// Get all fields in DefaultPluginVars
var fields = typeof(DefaultPluginVars).GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
foreach (var field in fields)
{
if (field.FieldType.IsGenericType && field.FieldType.GetGenericTypeDefinition() == typeof(Setting<>))
{
var settingValue = field.GetValue(null);
if (settingValue != null)
{
var valueProperty = settingValue.GetType().GetProperty("Value");
if (valueProperty != null)
{
var value = valueProperty.GetValue(settingValue);
settingsDictionary[field.Name] = value;
}
}
}
}
// Add windowRect position and size to the dictionary
settingsDictionary["windowRectX"] = windowRect.x;
settingsDictionary["windowRectY"] = windowRect.y;
settingsDictionary["windowRectWidth"] = windowRect.width;
settingsDictionary["windowRectHeight"] = windowRect.height;
return JsonConvert.SerializeObject(settingsDictionary, Formatting.Indented);
}
public static void ImportFromJson(string json)
{
var settingsDictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
var fields = typeof(DefaultPluginVars).GetFields(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
// Temporarily store the scenario selections to initialize them later
string pmcScenarioSelectionValue = null;
string scavScenarioSelectionValue = null;
foreach (var field in fields)
{
if (field.FieldType.IsGenericType && field.FieldType.GetGenericTypeDefinition() == typeof(Setting<>))
{
if (settingsDictionary.TryGetValue(field.Name, out var value))
{
var settingValue = field.GetValue(null);
if (settingValue == null)
{
Debug.LogError($"Setting value for field {field.Name} is null.");
continue;
}
var valueProperty = settingValue.GetType().GetProperty("Value");
if (valueProperty == null)
{
Debug.LogError($"Value property for setting {field.Name} is not found.");
continue;
}
var fieldType = field.FieldType.GetGenericArguments()[0];
try
{
if (fieldType == typeof(KeyCode))
{
valueProperty.SetValue(settingValue, Enum.Parse(typeof(KeyCode), value.ToString()));
}
else
{
var convertedValue = Convert.ChangeType(value, fieldType);
valueProperty.SetValue(settingValue, convertedValue);
}
// Store the scenario selection values
if (field.Name == nameof(DefaultPluginVars.pmcScenarioSelection))
{
pmcScenarioSelectionValue = value.ToString();
}
else if (field.Name == nameof(DefaultPluginVars.scavScenarioSelection))
{
scavScenarioSelectionValue = value.ToString();
}
}
catch (Exception ex)
{
Debug.LogError($"Error setting value for field {field.Name}: {ex}");
}
}
}
}
// Load windowRect position and size from the dictionary, with defaults if not present
if (settingsDictionary.TryGetValue("windowRectX", out var windowRectX) &&
settingsDictionary.TryGetValue("windowRectY", out var windowRectY) &&
settingsDictionary.TryGetValue("windowRectWidth", out var windowRectWidth) &&
settingsDictionary.TryGetValue("windowRectHeight", out var windowRectHeight))
{
windowRect = new Rect(
Convert.ToSingle(windowRectX),
Convert.ToSingle(windowRectY),
Convert.ToSingle(windowRectWidth),
Convert.ToSingle(windowRectHeight));
}
else
{
// Apply default values if any of the windowRect values are missing
windowRect = new Rect(20, 20, 1664, 936);
}
// Ensure the arrays are initialized before creating the settings
DefaultPluginVars.pmcScenarioCombinedArray ??= new string[0];
DefaultPluginVars.scavScenarioCombinedArray ??= new string[0];
// After loading all settings, initialize the scenario settings with the loaded values
DefaultPluginVars.pmcScenarioSelection = new Setting<string>(
"PMC Raid Spawn Preset Selection",
"Select a preset to use when spawning as PMC",
pmcScenarioSelectionValue ?? "live-like",
"live-like",
null,
null,
DefaultPluginVars.pmcScenarioCombinedArray
);
DefaultPluginVars.scavScenarioSelection = new Setting<string>(
"SCAV Raid Spawn Preset Selection",
"Select a preset to use when spawning as SCAV",
scavScenarioSelectionValue ?? "live-like",
"live-like",
null,
null,
DefaultPluginVars.scavScenarioCombinedArray
);
}
}
}