-
Notifications
You must be signed in to change notification settings - Fork 10
/
ClickerModCalls.cs
997 lines (927 loc) · 31.4 KB
/
ClickerModCalls.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
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
using ClickerClass.Items;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;
namespace ClickerClass
{
public static class ClickerModCalls
{
//All calls are "documented" on the ClickerClassExampleMod repo: https://github.com/SamsonAllen13/ClickerClassExampleMod/blob/master/ClickerCompat.cs
//Not everything is exposed via API yet
public static object Call(params object[] args)
{
ClickerClass clickerClass = ClickerClass.mod;
Version latestVersion = clickerClass.Version;
//Simplify code by resizing args
Array.Resize(ref args, 25);
string success = "Success";
try
{
string message = args[0] as string;
//Future-proofing. Allowing new info to be returned while maintaining backwards compat if necessary
object apiString = args[1];
Version apiVersion = apiString is string ? new Version(apiString as string) : latestVersion;
//Starting index of all parameters for a call
int index = 2;
if (message == "SetClickerWeaponDefaults")
{
var item = args[index + 0] as Item;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
ClickerSystem.SetClickerWeaponDefaults(item);
return success;
}
else if (message == "SetSFXButtonDefaults")
{
var item = args[index + 0] as Item;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
ClickerSystem.SetSFXButtonDefaults(item);
return success;
}
else if (message == "SetClickerProjectileDefaults")
{
var projectile = args[index + 0] as Projectile;
if (projectile == null)
{
throw new Exception($"Call Error: The projectile argument for the attempted message, \"{message}\" has returned null.");
}
ClickerSystem.SetClickerProjectileDefaults(projectile);
return success;
}
else if (message == "RegisterClickerProjectile")
{
var modProj = args[index + 0] as ModProjectile;
if (modProj == null)
{
throw new Exception($"Call Error: The modProjectile argument for the attempted message, \"{message}\" has returned null.");
}
ClickerSystem.RegisterClickerProjectile(modProj);
return success;
}
else if (message == "RegisterClickerWeaponProjectile")
{
var modProj = args[index + 0] as ModProjectile;
if (modProj == null)
{
throw new Exception($"Call Error: The modProjectile argument for the attempted message, \"{message}\" has returned null.");
}
ClickerSystem.RegisterClickerWeaponProjectile(modProj);
return success;
}
else if (message == "RegisterClickerItem")
{
var modItem = args[index + 0] as ModItem;
if (modItem == null)
{
throw new Exception($"Call Error: The modItem argument for the attempted message, \"{message}\" has returned null.");
}
ClickerSystem.RegisterClickerItem(modItem);
return success;
}
else if (message == "RegisterClickerWeapon")
{
var modItem = args[index + 0] as ModItem;
var borderTexture = args[index + 1] as string;
if (modItem == null)
{
throw new Exception($"Call Error: The modItem argument for the attempted message, \"{message}\" has returned null.");
}
ClickerSystem.RegisterClickerWeapon(modItem, borderTexture);
return success;
}
else if (message == "RegisterSFXButton")
{
var modItem = args[index + 0] as ModItem;
var playSoundAction = args[index + 1] as Action<int>;
if (modItem == null)
{
throw new Exception($"Call Error: The modItem argument for the attempted message, \"{message}\" has returned null.");
}
ClickerSystem.RegisterSFXButton(modItem, playSoundAction);
return success;
}
//Mod mod, string internalName, int amount, Color color, Action<Player, EntitySource_ItemUse_WithAmmo, Vector2, int, int, float> action, bool preHardMode = false, object[] nameArgs = null, object[] descriptionArgs = null
else if (message == "RegisterClickEffect")
{
var mod = args[index + 0] as Mod;
var internalName = args[index + 1] as string;
var amount = args[index + 2] as int?;
var color = args[index + 3] as Color?;
var colorFunc = args[index + 3] as Func<Color>; //Try another type variation because of overload
var action = args[index + 4] as Action<Player, EntitySource_ItemUse_WithAmmo, Vector2, int, int, float>;
var preHardMode = args[index + 5] as bool?;
var nameArgs = args[index + 6] as object[]; //Defaults to null in the register calls
var descriptionArgs = args[index + 7] as object[]; //Defaults to null in the register calls
string nameOfargument = string.Empty;
if (mod == null)
nameOfargument = "mod";
if (internalName == null)
nameOfargument = "internalName";
if (amount == null)
nameOfargument = "amount";
if (color == null && colorFunc == null)
nameOfargument = "color";
if (action == null)
nameOfargument = "action";
if (preHardMode == null)
nameOfargument = "preHardMode"; //Defaults to false in the register calls, so null is a problem
if (nameOfargument != string.Empty)
{
throw new Exception($"Call Error: The {nameOfargument} argument for the attempted message, \"{message}\" has returned null.");
}
Func<Color> useColor = colorFunc;
if (colorFunc == null)
{
//Fall back to old (regular) call without func
useColor = () => color.Value;
}
return ClickerSystem.RegisterClickEffect(mod, internalName, amount.Value, useColor, action, preHardMode.Value, nameArgs, descriptionArgs);
}
else if (message == "GetPathToBorderTexture")
{
var type = args[index + 0] as int?;
if (type == null)
{
throw new Exception($"Call Error: The type argument for the attempted message, \"{message}\" has returned null.");
}
return ClickerSystem.GetPathToBorderTexture(type.Value);
}
else if (message == "IsClickerProj")
{
var proj = args[index + 0] as Projectile;
var type = args[index + 0] as int?; //Try another type variation because of overload
if (proj != null)
{
return ClickerSystem.IsClickerProj(proj);
}
else if (type != null)
{
return ClickerSystem.IsClickerProj(type.Value);
}
else
{
throw new Exception($"Call Error: The projectile/type argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "IsClickerWeaponProj")
{
var proj = args[index + 0] as Projectile;
var type = args[index + 0] as int?; //Try another type variation because of overload
if (proj != null)
{
return ClickerSystem.IsClickerWeaponProj(proj);
}
else if (type != null)
{
return ClickerSystem.IsClickerWeaponProj(type.Value);
}
else
{
throw new Exception($"Call Error: The projectile/type argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "IsClickerItem")
{
var item = args[index + 0] as Item;
var type = args[index + 0] as int?; //Try another type variation because of overload
if (item != null)
{
return ClickerSystem.IsClickerItem(item);
}
else if (type != null)
{
return ClickerSystem.IsClickerItem(type.Value);
}
else
{
throw new Exception($"Call Error: The item/type argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "IsClickerWeapon")
{
var item = args[index + 0] as Item;
var type = args[index + 0] as int?; //Try another type variation because of overload
if (item != null)
{
return ClickerSystem.IsClickerWeapon(item);
}
else if (type != null)
{
return ClickerSystem.IsClickerWeapon(type.Value);
}
else
{
throw new Exception($"Call Error: The item/type argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "IsSFXButton")
{
var item = args[index + 0] as Item;
var type = args[index + 0] as int?; //Try another type variation because of overload
if (item != null)
{
return ClickerSystem.IsSFXButton(item);
}
else if (type != null)
{
return ClickerSystem.IsSFXButton(type.Value);
}
else
{
throw new Exception($"Call Error: The item/type argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "GetSFXButton")
{
var item = args[index + 0] as Item;
var type = args[index + 0] as int?; //Try another type variation because of overload
Action<int> playSound;
if (item != null)
{
return ClickerSystem.IsSFXButton(item.type, out playSound) ? playSound : null;
}
else if (type != null)
{
return ClickerSystem.IsSFXButton(type.Value, out playSound) ? playSound : null;
}
else
{
throw new Exception($"Call Error: The item/type argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "IsClickEffect")
{
var effectName = args[index + 0] as string;
if (effectName == null)
{
throw new Exception($"Call Error: The effectName argument for the attempted message, \"{message}\" has returned null.");
}
return ClickerSystem.IsClickEffect(effectName);
}
//Clicker Weapon/Item specifics now
else if (message == "SetColor")
{
var item = args[index + 0] as Item;
var color = args[index + 1] as Color?;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
if (color == null)
{
color = Color.White;
}
ClickerWeapon.SetColor(item, color.Value);
return success;
}
else if (message == "SetAccessoryType")
{
var item = args[index + 0] as Item;
var accessoryTypeString = args[index + 1] as string;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
if (accessoryTypeString == null)
{
throw new Exception($"Call Error: The accessoryTypeString argument for the attempted message, \"{message}\" has returned null.");
}
if (!Enum.TryParse(typeof(ClickerAccessoryType), accessoryTypeString, out object result))
{
throw new Exception($"Call Error: The accessoryTypeString argument for the attempted message, \"{message}\" is not valid.");
}
ClickerItem.SetAccessoryType(item, (ClickerAccessoryType)result);
return success;
}
else if (message == "SetDisplayTotalClicks")
{
var item = args[index + 0] as Item;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
ClickerItem.SetDisplayTotalClicks(item);
return success;
}
else if (message == "SetDisplayMoneyGenerated")
{
var item = args[index + 0] as Item;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
ClickerItem.SetDisplayMoneyGenerated(item);
return success;
}
else if (message == "SetDust")
{
var item = args[index + 0] as Item;
var dust = args[index + 1] as int?;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
if (dust == null)
{
dust = 0;
}
ClickerWeapon.SetDust(item, dust.Value);
return success;
}
else if (message == "SetRadius")
{
var item = args[index + 0] as Item;
var radius = args[index + 1] as float?;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
if (radius == null)
{
radius = 0f;
}
ClickerWeapon.SetRadius(item, radius.Value);
return success;
}
else if (message == "AddEffect")
{
var item = args[index + 0] as Item;
var name = args[index + 1] as string;
var names = args[index + 1] as IEnumerable<string>; //type variation
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
if (name != null)
{
ClickerWeapon.AddEffect(item, name);
return success;
}
else if (names != null)
{
ClickerWeapon.AddEffect(item, names);
return success;
}
else
{
throw new Exception($"Call Error: The name/names argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "GetAllEffectNames")
{
//List<string>
return ClickerSystem.GetAllEffectNames();
}
else if (message == "GetClickEffectAsDict")
{
var effectName = args[index + 0] as string;
if (effectName == null)
{
throw new Exception($"Call Error: The effectName argument for the attempted message, \"{message}\" has returned null.");
}
//Dictionary<string, object>
return ClickerSystem.GetClickEffectAsDict(effectName);
}
//Player specifics now
else if (message == "GetPlayerStat")
{
var player = args[index + 0] as Player;
var statName = args[index + 1] as string;
if (statName == null)
{
throw new Exception($"Call Error: The statName argument for the attempted message, \"{message}\" has returned null.");
}
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
if (statName == "clickerRadius")
{
return clickerPlayer.clickerRadius;
}
else if (statName == "clickAmountTotal")
{
var item = args[index + 2] as Item;
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
string name = args[index + 3] as string;
if (name == null)
{
name = string.Empty;
}
return clickerPlayer.GetClickAmountTotal(item, name);
}
else if (statName == "clickAmount")
{
return clickerPlayer.clickAmount;
}
else if (statName == "clickerPerSecond")
{
return clickerPlayer.clickerPerSecond;
}
throw new Exception($"Call Error: The statName argument for the attempted message, \"{message}\" has no valid entry point.");
}
else if (message == "GetArmorSet")
{
var player = args[index + 0] as Player;
var setName = args[index + 1] as string;
if (setName == null)
{
throw new Exception($"Call Error: The setName argument for the attempted message, \"{message}\" has returned null.");
}
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
//setMotherboard, setOverclock, setPrecursor, setMice
if (setName == "Motherboard")
{
return clickerPlayer.setMotherboard;
}
else if (setName == "Overclock")
{
return clickerPlayer.setOverclock;
}
else if (setName == "Precursor")
{
return clickerPlayer.setPrecursor;
}
else if (setName == "Mice")
{
return clickerPlayer.setMice;
}
else if (setName == "RGB")
{
return clickerPlayer.setRGB;
}
throw new Exception($"Call Error: The setName argument for the attempted message, \"{message}\" has no valid entry point.");
}
else if (message == "GetAccessory")
{
var player = args[index + 0] as Player;
var accName = args[index + 1] as string;
if (accName == null)
{
throw new Exception($"Call Error: The accName argument for the attempted message, \"{message}\" has returned null.");
}
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
//accEnchantedLED, accEnchantedLED2, accGlassOfMilk, accCookie, accCookie2, accClickingGlove, accAncientClickingGlove, accRegalClickingGlove
//accPortableParticleAccelerator
//accMouseTrap, accHotKeychain, accTriggerFinger, accButtonMasher, accAimbotModule, accAimbotModule2
if (accName == "EnchantedLED")
{
return clickerPlayer.accEnchantedLED;
}
else if (accName == "EnchantedLED2")
{
return clickerPlayer.accEnchantedLED2;
}
else if (accName == "GlassOfMilk")
{
return clickerPlayer.accGlassOfMilk;
}
else if (accName == "CookieVisual")
{
return clickerPlayer.accCookie;
}
else if (accName == "CookieVisual2")
{
return clickerPlayer.accCookie2;
}
else if (accName == "ClickingGlove")
{
return clickerPlayer.accClickingGlove;
}
else if (accName == "AncientClickingGlove")
{
return clickerPlayer.accAncientClickingGlove;
}
else if (accName == "RegalClickingGlove")
{
return clickerPlayer.accRegalClickingGlove;
}
else if (accName == "PortableParticleAccelerator")
{
return clickerPlayer.accPortableParticleAccelerator;
}
else if (accName == "MouseTrap")
{
return clickerPlayer.accMouseTrap;
}
else if (accName == "HotKeychain")
{
return clickerPlayer.accHotKeychain;
}
else if (accName == "TriggerFinger")
{
return clickerPlayer.accTriggerFinger;
}
else if (accName == "ButtonMasher")
{
return clickerPlayer.accButtonMasher;
}
else if (accName == "AimAssistModule")
{
return clickerPlayer.accAimbotModule;
}
else if (accName == "AimbotModule")
{
return clickerPlayer.accAimbotModule2;
}
throw new Exception($"Call Error: The accName argument for the attempted message, \"{message}\" has no valid entry point.");
}
else if (message == "GetAccessoryItem")
{
var player = args[index + 0] as Player;
var accName = args[index + 1] as string;
if (accName == null)
{
throw new Exception($"Call Error: The accName argument for the attempted message, \"{message}\" has returned null.");
}
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
//accCookieItem
//accAMedalItem, accFMedalItem, accSMedalItem, accGoldenTicketItem, accPaperclipsItem
if (accName == "Cookie")
{
return clickerPlayer.accCookieItem;
}
else if (accName == "AMedal")
{
return clickerPlayer.accAMedalItem;
}
else if (accName == "FMedal")
{
return clickerPlayer.accFMedalItem;
}
else if (accName == "SMedal")
{
return clickerPlayer.accSMedalItem;
}
else if (accName == "GoldenTicket")
{
return clickerPlayer.accGoldenTicketItem;
}
else if (accName == "BottomlessBoxOfPaperclips")
{
return clickerPlayer.accPaperclipsItem;
}
throw new Exception($"Call Error: The accName argument for the attempted message, \"{message}\" has no valid entry point.");
}
else if (message == "SetPlayerStat")
{
var player = args[index + 0] as Player;
var statName = args[index + 1] as string;
if (statName == null)
{
throw new Exception($"Call Error: The statName argument for the attempted message, \"{message}\" has returned null.");
}
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
if (statName == "clickerCritAdd")
{
var crit = args[index + 2] as int?;
if (crit == null)
{
throw new Exception($"Call Error: The crit argument for the attempted message, \"{message}\" has returned null.");
}
ref var critChance = ref player.GetCritChance<ClickerDamage>();
critChance += crit.Value;
critChance = Utils.Clamp(critChance, 0, 100);
return success;
}
else if (statName == "clickerDamageFlatAdd")
{
var flat = args[index + 2] as int?;
if (flat == null)
{
throw new Exception($"Call Error: The flat argument for the attempted message, \"{message}\" has returned null.");
}
ref var clickerDamage = ref player.GetDamage<ClickerDamage>();
clickerDamage.Flat += flat.Value;
//clickerDamage.Flat = Math.Max(0, clickerDamage.Flat);
return success;
}
else if (statName == "clickerDamageAdd")
{
var damage = args[index + 2] as float?;
if (damage == null)
{
throw new Exception($"Call Error: The damage argument for the attempted message, \"{message}\" has returned null.");
}
ref var clickerDamage = ref player.GetDamage<ClickerDamage>();
clickerDamage += damage.Value;
//clickerDamage = Math.Max(0f, clickerDamage);
return success;
}
else if (statName == "clickerBonusAdd")
{
var bonus = args[index + 2] as int?;
if (bonus == null)
{
throw new Exception($"Call Error: The bonus argument for the attempted message, \"{message}\" has returned null.");
}
clickerPlayer.clickerBonus += bonus.Value;
clickerPlayer.clickerBonus = Math.Max(0, clickerPlayer.clickerBonus);
return success;
}
else if (statName == "clickerBonusPercentAdd")
{
var bonus = args[index + 2] as float?;
if (bonus == null)
{
throw new Exception($"Call Error: The bonus argument for the attempted message, \"{message}\" has returned null.");
}
clickerPlayer.clickerBonusPercent += bonus.Value;
clickerPlayer.clickerBonusPercent = Math.Max(0f, clickerPlayer.clickerBonusPercent);
return success;
}
else if (statName == "clickerRadiusAdd")
{
var radius = args[index + 2] as float?;
if (radius == null)
{
throw new Exception($"Call Error: The radius argument for the attempted message, \"{message}\" has returned null.");
}
clickerPlayer.clickerRadius += radius.Value;
clickerPlayer.clickerRadius = Math.Max(0f, clickerPlayer.clickerRadius);
return success;
}
throw new Exception($"Call Error: The statName argument for the attempted message, \"{message}\" has no valid entry point.");
}
else if (message == "SetAccessory")
{
var player = args[index + 0] as Player;
var accName = args[index + 1] as string;
if (accName == null)
{
throw new Exception($"Call Error: The accName argument for the attempted message, \"{message}\" has returned null.");
}
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
//accEnchantedLED, accEnchantedLED2, accGlassOfMilk, accCookie, accCookie2, accClickingGlove, accAncientClickingGlove, accRegalClickingGlove
//accPortableParticleAccelerator
//accMouseTrap, accHotKeychain, accTriggerFinger, accButtonMasher, accAimbotModule, accAimbotModule2
if (accName == "EnchantedLED")
{
clickerPlayer.accEnchantedLED = true;
return success;
}
else if (accName == "EnchantedLED2")
{
clickerPlayer.accEnchantedLED2 = true;
return success;
}
else if (accName == "GlassOfMilk")
{
clickerPlayer.accGlassOfMilk = true;
return success;
}
else if (accName == "CookieVisual")
{
clickerPlayer.accCookie = true;
return success;
}
else if (accName == "CookieVisual2")
{
clickerPlayer.accCookie2 = true;
return success;
}
else if (accName == "ClickingGlove")
{
clickerPlayer.accClickingGlove = true;
return success;
}
else if (accName == "AncientClickingGlove")
{
clickerPlayer.accAncientClickingGlove = true;
return success;
}
else if (accName == "RegalClickingGlove")
{
clickerPlayer.accRegalClickingGlove = true;
return success;
}
else if (accName == "PortableParticleAccelerator")
{
clickerPlayer.accPortableParticleAccelerator = true;
return success;
}
else if (accName == "MouseTrap")
{
clickerPlayer.accMouseTrap = true;
return success;
}
else if (accName == "HotKeychain")
{
clickerPlayer.accHotKeychain = true;
return success;
}
else if (accName == "TriggerFinger")
{
clickerPlayer.accTriggerFinger = true;
return success;
}
else if (accName == "ButtonMasher")
{
clickerPlayer.accButtonMasher = true;
return success;
}
else if (accName == "AimAssistModule")
{
clickerPlayer.accAimbotModule = true;
return success;
}
else if (accName == "AimbotModule")
{
clickerPlayer.accAimbotModule2 = true;
return success;
}
throw new Exception($"Call Error: The accName argument for the attempted message, \"{message}\" has no valid entry point.");
}
else if (message == "SetAccessoryItem")
{
var player = args[index + 0] as Player;
var accName = args[index + 1] as string;
var item = args[index + 2] as Item;
if (accName == null)
{
throw new Exception($"Call Error: The accName argument for the attempted message, \"{message}\" has returned null.");
}
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
if (item == null)
{
throw new Exception($"Call Error: The item argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
//accCookieItem
//accAMedalItem, accFMedalItem, accSMedalItem, accGoldenTicketItem, accPaperclipsItem
if (accName == "Cookie")
{
clickerPlayer.accCookieItem = item;
return success;
}
else if (accName == "AMedal")
{
clickerPlayer.accAMedalItem = item;
return success;
}
else if (accName == "FMedal")
{
clickerPlayer.accFMedalItem = item;
return success;
}
else if (accName == "SMedal")
{
clickerPlayer.accSMedalItem = item;
return success;
}
else if (accName == "GoldenTicket")
{
clickerPlayer.accGoldenTicketItem = item;
return success;
}
else if (accName == "BottomlessBoxOfPaperclips")
{
clickerPlayer.accPaperclipsItem = item;
return success;
}
throw new Exception($"Call Error: The accName argument for the attempted message, \"{message}\" has no valid entry point.");
}
else if (message == "EnableClickEffect")
{
var player = args[index + 0] as Player;
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
var effectName = args[index + 1] as string;
var effectNames = args[index + 1] as IEnumerable<string>; //type variation
if (effectName != null)
{
clickerPlayer.EnableClickEffect(effectName);
return success;
}
else if (effectNames != null)
{
clickerPlayer.EnableClickEffect(effectNames);
return success;
}
else
{
throw new Exception($"Call Error: The effectName/effectNames argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "HasClickEffect")
{
var player = args[index + 0] as Player;
var effectName = args[index + 1] as string;
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
if (effectName == null)
{
throw new Exception($"Call Error: The effectName argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
return clickerPlayer.HasClickEffect(effectName);
}
else if (message == "GetAllSFXButtonStacks")
{
var player = args[index + 0] as Player;
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
return clickerPlayer.GetAllSFXButtonStacks();
}
else if (message == "AddSFXButtonStack")
{
var player = args[index + 0] as Player;
var item = args[index + 1] as Item;
var type = args[index + 1] as int?; //Try another type variation because of overload
if (player == null)
{
throw new Exception($"Call Error: The player argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
if (item != null)
{
return clickerPlayer.AddSFXButtonStack(item);
}
else if (type != null)
{
var stack = args[index + 2] as int?;
if (stack == null)
{
throw new Exception($"Call Error: The stack argument for the attempted message, \"{message}\" has returned null.");
}
return clickerPlayer.AddSFXButtonStack(type.Value, stack.Value);
}
else
{
throw new Exception($"Call Error: The item/type argument for the attempted message, \"{message}\" has returned null.");
}
}
else if (message == "SetAutoReuseEffect")
{
var player = args[index + 0] as Player;
var speedFactor = args[index + 1] as float?;
var controlledByKeyBind = args[index + 2] as bool?;
var preventsClickEffects = args[index + 3] as bool?;
if (speedFactor == null)
{
throw new Exception($"Call Error: The speedFactor argument for the attempted message, \"{message}\" has returned null.");
}
if (controlledByKeyBind == null)
{
throw new Exception($"Call Error: The controlledByKeyBind argument for the attempted message, \"{message}\" has returned null.");
}
if (preventsClickEffects == null)
{
throw new Exception($"Call Error: The preventsClickEffects argument for the attempted message, \"{message}\" has returned null.");
}
ClickerPlayer clickerPlayer = player.GetModPlayer<ClickerPlayer>();
clickerPlayer.SetAutoReuseEffect(new AutoReuseEffect(speedFactor.Value, controlledByKeyBind.Value, preventsClickEffects.Value));
return success;
}
}
catch (Exception e)
{
clickerClass.Logger.Error($"Call Error: {e.StackTrace} {e.Message}");
}
return null;
}
}
}