-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
2900 lines (2452 loc) · 173 KB
/
Plugin.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
998
999
1000
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using MainUI;
using Server;
using UnityEngine;
using Addressable;
using SimpleJSON;
using System.IO;
using BattleUI;
using SD;
using ServerConfig;
using Dungeon;
using Il2CppSystem.Collections.Generic;
namespace ForestForTheFlames;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, "YumYum Enterprises", MyPluginInfo.PLUGIN_VERSION)]
public class Plugin : BasePlugin
{
internal static new ManualLogSource Log;
protected static string SERVER_URL = " http://127.0.0.1:21000";
internal static string DATA_PATH = BepInEx.Paths.PluginPath + "\\ForestForTheFlames";
internal static bool patched = false;
internal static bool networkKill = false;
internal static bool _asPatched = false;
internal static bool _skip1 = false;
internal static bool _egostage = false;
public override void Load()
{
Harmony.CreateAndPatchAll(typeof(Plugin));
Log = base.Log;
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
//Log.LogInfo($"Using custom server at {SERVER_URL}");
//foreach (var x in System.Reflection.Assembly.GetExecutingAssembly().GetTypes())
//{
// Log.LogInfo(x.Name);
//}
//egolist.Add("Abnormality", new System.Collections.Generic.List<(int, int)>());
//egolist.Add("Abnormality_Part", new System.Collections.Generic.List<(int, int)>());
//egolist.Add("Ally", new System.Collections.Generic.List<(int, int)>());
//egolist.Add("Assistant", new System.Collections.Generic.List<(int, int)>());
//egolist.Add("Opponent", new System.Collections.Generic.List<(int, int)>());
egolist.Add("Enemy", new System.Collections.Generic.List<(int, int, int)>());
egolist.Add("Player", new System.Collections.Generic.List<(int, int, int)>());
}
[HarmonyPatch(typeof(HttpApiRequester), "AddRequest")]
[HarmonyPrefix]
public static bool AddRequest(HttpApiRequester __instance, HttpApiSchema httpApiSchema, int priority = 0)
{
if (!_skip1)
{
//httpApiSchema._url.Replace("https://www.limbuscompanyapi.com", SERVER_URL);
Log.LogInfo(httpApiSchema._url + " : " + httpApiSchema.RequestJson);
// change httpApiSchema._url you redirect it to your own host
// _url -> full url
__instance._requestQueue.Enqueue(httpApiSchema, priority);
__instance.ProceedRequest();
}
return false;
}
public static void Callback(object any)
{
Log.LogInfo((string)any);
}
public static void ReplaceSkill(SkillStaticData x, SkillStaticData y)
{
x.skillData = y.skillData;
x.skillTier = y.skillTier;
x.skillType = y.skillType;
x.textID = y.textID;
}
public static Il2CppSystem.Collections.Generic.List<JSONNode> jlist = new Il2CppSystem.Collections.Generic.List<JSONNode>();
public static Il2CppSystem.Collections.Generic.List<JSONNode> lclist = new Il2CppSystem.Collections.Generic.List<JSONNode>();
public static System.Collections.Generic.Dictionary<int, (string, string)> aplist = new System.Collections.Generic.Dictionary<int, (string, string)> { };
public static System.Collections.Generic.Dictionary<int, JSONNode> eslist = new System.Collections.Generic.Dictionary<int, JSONNode> { };
public static System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<(int, int, int)>> egolist = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<(int, int, int)>> { };
// charid, id, who, egoid
public static void PrepareSkillFromLocalJson(string path)
{
Log.LogInfo($"Skill: Preparing to load {path}");
string contents = File.ReadAllText($@"{DATA_PATH}\json\{path}");
jlist.Add(JSONNode.Parse(contents));
}
public static void InitSkills()
{
Log.LogInfo("Loading skills");
foreach (var x in jlist)
{
var y = JsonUtility.FromJson<SkillStaticData>(x.ToString());
if (Singleton<StaticDataManager>.Instance.SkillList.dict.ContainsKey(y.ID))
{
Singleton<StaticDataManager>.Instance.SkillList.dict[y.ID] = y;
}
else
{
//Singleton<StaticDataManager>.Instance.SkillList.list.Add(y);
Singleton<StaticDataManager>.Instance.SkillList.dict.Add(y.ID, y);
}
}
Log.LogInfo("Finished loading skills");
//Log.LogInfo("Clearing [jlist]");
//jlist.Clear();
}
public static void PrepareLocalize(string path)
{
Log.LogInfo($"Localize: Preparing to load {path}");
var p = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string contents = File.ReadAllText($@"{DATA_PATH}\json\{path}");
jlist.Add(JSONNode.Parse(contents));
}
public static void InitLocalize()
{
Log.LogInfo("Loading localization");
foreach (var x in jlist)
{
var y = JsonUtility.FromJson<TextData_Skill>(x.ToString());
if (Singleton<TextDataSet>.Instance.SkillList._dic.ContainsKey(y.ID))
{
Singleton<TextDataSet>.Instance.SkillList._dic[y.ID] = y;
}
else
{
Singleton<TextDataSet>.Instance.SkillList._dic.Add(y.ID, y);
}
}
Log.LogInfo("Finished loading localization");
//Log.LogInfo("Clearing [lclist]");
//lclist.Clear();
}
public static void HotPatch()
{
Log.LogWarning("Hotpatching in progress!");
InitSkills();
InitLocalize();
}
public static void AddPassive(int id, int pid, int level = -1)
{
Log.LogInfo($"Adding passive {pid} to {id}");
foreach (var x in Singleton<StaticDataManager>.Instance.PersonalityPassiveList.list)
{
if (x.personalityID == id)
{
foreach (var y in x.battlePassiveList)
{
if (level != -1)
{
if (y.Level == level)
{
y.passiveIDList.Add(pid);
}
}
else
{
y.passiveIDList.Add(pid);
}
}
}
}
}
public static void RemovePassive(int id, int pid)
{
Log.LogInfo($"Removing passive {pid} from {id}");
foreach (var x in Singleton<StaticDataManager>.Instance.PersonalityPassiveList.list)
{
if (x.personalityID == id)
{
foreach (var y in x.battlePassiveList)
{
if (y.passiveIDList.Contains(pid))
{
y.passiveIDList.Remove(pid);
}
}
}
}
}
public static void LoadAbnoUnit(string path)
{
Log.LogInfo($"AbnoUnit: Loading {path}");
var p = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string contents = File.ReadAllText($@"{DATA_PATH}\json\unit\Abno\{path}");
var y = JsonUtility.FromJson<AbnormalityStaticData>(contents.ToString());
Singleton<StaticDataManager>.Instance.AbnormalityUnitList.list.Add(y);
}
public static void LoadAbnoPartUnit(string path)
{
Log.LogInfo($"AbnoUnitPart: Loading {path}");
var p = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string contents = File.ReadAllText($@"{DATA_PATH}\json\unit\Abno\{path}");
var y = JsonUtility.FromJson<AbnormalityPartStaticData>(contents.ToString());
Singleton<StaticDataManager>.Instance.AbnormalityPartList.list.Add(y);
}
public static void LoadBuffStatic(string path)
{
Log.LogInfo($"BuffStatic: Loading {path}");
var p = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string contents = File.ReadAllText($@"{DATA_PATH}\json\buff\{path}");
var y = JsonUtility.FromJson<BuffStaticData>(contents.ToString());
Singleton<StaticDataManager>.Instance.BuffList.list.Add(y);
}
public static void LoadPersonality(string path)
{
Log.LogInfo($"Personality: Loading {path}");
var p = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
{
string contents = File.ReadAllText($@"{DATA_PATH}\json\unit\Sinners\{path}");
var y = JsonUtility.FromJson<PersonalityStaticData>(contents.ToString());
Singleton<StaticDataManager>.Instance.PersonalityStaticDataList.list.Add(y);
}
{
path.Replace(".json", "_text.json");
string contents = File.ReadAllText($@"{DATA_PATH}\json\unit\Sinners\{path}");
var y = JsonUtility.FromJson<PersonalityStaticData>(contents.ToString());
Singleton<StaticDataManager>.Instance.PersonalityStaticDataList.list.Add(y);
}
}
public static void LoadEgoTextAndStatic(string path)
{
Log.LogInfo($"EgoLoaderAndTextPlusStatic: Loading {path}");
var p = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
{
string contents = File.ReadAllText($@"{DATA_PATH}\json\ego\{path}");
var y = JsonUtility.FromJson<EgoStaticData>(contents.ToString());
Singleton<StaticDataManager>.Instance.EgoList.list.Add(y);
}
{
path.Replace(".json", "_text.json");
string contents = File.ReadAllText($@"{DATA_PATH}\json\ego\{path}");
var y = JsonUtility.FromJson<TextData_Ego>(contents.ToString());
Singleton<TextDataSet>.Instance.EgoList._dic.Add(y.ID, y);
}
}
public static void PrepareExpStage(int id, string path)
{
Log.LogInfo($"ExpStage: Preparing to load {path}");
var p = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string contents = File.ReadAllText($@"{DATA_PATH}\json\stage\{path}");
eslist.Add(id, JSONNode.Parse(contents));
}
public static void InitExpStage()
{
Log.LogInfo("Loading ExpStages");
foreach (var x in eslist)
{
var y = JsonUtility.FromJson<StageStaticData>(x.Value.ToString());
var i = x.Key;
Log.LogInfo($"ExpStage: Loading id:{i}");
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).hasGoldenBough = y.hasGoldenBough;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).hasGoldenBoughGray = y.hasGoldenBoughGray;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).stageLevel = y.stageLevel;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).stageType = y.stageType;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).isBatonPassOn = y.isBatonPassOn;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).stageEnemyType = y.stageEnemyType;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).battleCameraInfo = y.battleCameraInfo;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).includeBoss = y.includeBoss;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).staminaType = y.staminaType;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).staminaCost = y.staminaCost;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).recommendedLevel = y.recommendedLevel;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).story = y.story;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).questlist = y.questlist;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).dangerLevel = y.dangerLevel;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).attributeType = y.attributeType;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).attackType = y.attackType;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).abnormalityEventList = y.abnormalityEventList;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).eventScriptName = y.eventScriptName;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).participantInfo = y.participantInfo;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).waveList = y.waveList;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).turnLimit = y.turnLimit;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).rewardList = y.rewardList;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).blockEnemyInfo = y.blockEnemyInfo;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).forceAllyFormation = y.forceAllyFormation;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).unlockDanteAbility = y.unlockDanteAbility;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).abstainSupporterCharacterIds = y.abstainSupporterCharacterIds;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).lobotomyStageType = y.lobotomyStageType;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).libraryOfRuinaStageType = y.libraryOfRuinaStageType;
Singleton<StaticDataManager>.Instance.ExpDungeonBattleList.GetStage(i).sprName = y.sprName;
}
Log.LogInfo("Finished loading ExpStages");
//Log.LogInfo("Clearing [jlist]");
//jlist.Clear();
}
[HarmonyPatch(typeof(ResourceKeyBuilder), "BuildSdResourceKeyInfo")]
//[HarmonyPatch(new Type[] {typeof(string), typeof(string), typeof(Type), typeof(bool) })]
[HarmonyPostfix]
public static void ResourceLogger(ResourceKeyBuilder.SdResourceType type, string id)
{
Log.LogWarning(type + ":" + id);
}
//static internal System.Collections.Generic.List<object> pss = new System.Collections.Generic.List<object>();
public static System.Collections.Generic.Dictionary<float, System.Collections.Generic.List<object>> pss = new System.Collections.Generic.Dictionary<float, System.Collections.Generic.List<object>>();
//public static float GetSid(BattleUnitModel model)
//{
// float sid = model.UnitDataModel.ClassInfo.ID;
// return sid;
//}
//public static void AssignPassive(BattleUnitModel model, int id)
//{
// float sid = GetSid(model);
// Log.LogInfo($"{sid}:{id}");
// if (!pss.ContainsKey(sid))
// {
// pss.Add(sid, new System.Collections.Generic.List<object>());
// }
// if (id == -1)
// {
// var p = new PassiveAbility_1();
// p.Init(model, null, null);
// pss[sid].Add(p);
// }
//var ps = Type.GetType($"PassiveAbility_1{Math.Abs(id)}");
//if (ps != null)
//{
// var p = (Activator.CreateInstance(ps) as PassiveAbility);
// p.Init(model, null, null);
// pss[sid].Add(p);
//}
//else
//{
// Log.LogFatal($"{id} is null");
//}
//}
// reset passives + set the passive -1 to the abno part not unit!
//public static void NukePassives(BattleUnitModel model)
//{
// float sid = GetSid(model);
// Log.LogInfo($"{sid}");
// if (pss.ContainsKey(sid))
// {
// pss.Remove(sid);
// }
//}
//public static System.Collections.Generic.List<PassiveAbility> GetPassives(BattleUnitModel model = null, float bsid = 0f)
//{
// float sid;
// if (model == null)
// {
// sid = bsid;
// } else
// {
// sid = GetSid(model);
// }
// System.Collections.Generic.List<PassiveAbility> list = new System.Collections.Generic.List<PassiveAbility>();
// Log.LogInfo($"{sid}");
// if (pss.ContainsKey(sid))
// {
// foreach (var x in pss[sid])
// {
// list.Add(x as PassiveAbility);
// }
// return list;
// }
// else
// {
// return list;
// }
//}
//[HarmonyPatch(typeof(BattleUnitModel), "Init")]
//[HarmonyPostfix]
//public static void Scaffold_Init(BattleUnitModel __instance)
//{
// foreach (var psd in __instance._passiveDetail.PassiveList)
// {
// if (psd.GetID() < 0)
// {
// AssignPassive(__instance, psd.GetID());
// }
// }
//}
//[HarmonyPatch(typeof(BattleUnitModel), "OnDie")]
//[HarmonyPostfix]
//public static void Scaffold_OnDie(BattleUnitModel __instance)
//{
// NukePassives(__instance);
//}
//[HarmonyPatch(typeof(BattleUnitModel), "BeforeGiveAttackDamage")]
//[HarmonyPrefix]
//public static void Scaffold_BeforeGiveAttackDamage(BattleUnitModel __instance, BattleActionModel action, CoinModel coin, BattleUnitModel target, BATTLE_EVENT_TIMING timing)
//{
// foreach (var ps in GetPassives(__instance))
// {
// ps.BeforeGiveAttackDamage(action, coin, target, timing);
// }
//}
//[HarmonyPatch(typeof(BattleUnitModel), "OnTakeAttackDamage")]
//[HarmonyPrefix]
//public static void Scaffold_OnTakeAttackDamage(BattleUnitModel __instance, BattleActionModel action, CoinModel coin, int realDmg, int hpDamage, BATTLE_EVENT_TIMING timing, bool isCritical)
//{
// foreach (var ps in GetPassives(__instance))
// {
// ps.OnTakeAttackDamage(action, realDmg, hpDamage, timing);
// }
//}
//[HarmonyPatch(typeof(BattleUnitModel), "GetParryingResultAdder")]
//[HarmonyPrefix]
//public static void Scaffold_GetParryingResultAdder(BattleUnitModel __instance, BattleActionModel action, int actorResult, BattleActionModel oppoAction, int oppoResult, int parryingCount)
//{
// foreach (var ps in GetPassives(__instance))
// {
// actorResult = ps.GetParryingResultAdder(action, actorResult, oppoAction, oppoResult, parryingCount);
// }
//}
//[HarmonyPatch(typeof(BattleUnitModel), "OnRoundEnd")]
//[HarmonyPrefix]
//public static void Scaffold_OnRoundEnd(BattleUnitModel __instance, BATTLE_EVENT_TIMING timing)
//{
// foreach (var ps in GetPassives(__instance))
// {
// ps.OnRoundEnd(timing);
// }
//}
//[HarmonyPatch(typeof(BattleUnitModel), "GetActionSlotAdder")]
//[HarmonyPrefix]
//public static bool Scaffold_GetActionSlotAdder(BattleUnitModel __instance, ref int __result)
//{
// //bsid = GetSid(__instance);
// int total = 0;
// foreach (var ps in GetPassives(__instance))
// {
// total += ps.GetActionSlotAdder();
// }
// Log.LogFatal(total);
// if (__instance._buffDetail != null)
// {
// total += __instance._buffDetail.GetActionSlotAdder();
// }
// Log.LogFatal(total);
// if (__instance._passiveDetail != null)
// {
// total += __instance._passiveDetail.GetActionSlotAdder();
// }
// Log.LogFatal(total);
// __result = total;
// return false;
//}
//internal static float bsid = 0f;
//[HarmonyPatch(typeof(BuffDetail), "GetActionSlotAdder")]
//[HarmonyPrefix]
//public static bool Scaffold_GetActionSlotAdder_Patch(BuffDetail __instance, ref int __result)
//{
// Log.LogFatal((new System.Diagnostics.StackTrace()).GetFrame(1).GetMethod().Name);
// int num = 3;
// //foreach (var ps in GetPassives(bsid: bsid))
// //{
// // num += ps.GetActionSlotAdder();
// //}
// //foreach (BuffModel battleUnitBuff in __instance._grantedBuffList)
// //{
// // if (battleUnitBuff.IsValid(0) && !battleUnitBuff.IsDestroyed())
// // {
// // num += battleUnitBuff.GetActionSlotAdder();
// // }
// //}
// //__instance.CheckBuffsDestroyed();
// __result = num;
// return false;
//}
//[HarmonyPatch(typeof(PassiveModel), MethodType.Constructor, new Type[] { typeof(PassiveStaticData) })]
//[HarmonyPrefix]
//public static bool CustomPassivePatcher(PassiveModel __instance, PassiveStaticData info)
//{
// foreach (var x in System.Reflection.Assembly.GetExecutingAssembly().GetTypes())
// {
// Log.LogInfo(x.Name);
// }
// if (1 == 1)
// {
// //Type type = Type.GetType("PassiveAbility" + "_" + info.ID.ToString());
// Type type = Type.GetType("PassiveAbility_9991001");
// Log.LogFatal(type.FullName);
// Log.LogFatal(type.GetMethods().Count());
// if (type != null)
// {
// PassiveAbility script = (Activator.CreateInstance(type) as PassiveAbility);
// __instance._script = script;
// __instance._script._id = info.id;
// }
// else
// {
// Log.LogFatal("Passive is null");
// }
// __instance._classInfo = info;
// return false;
// }
// Log.LogFatal(info.id);
// return true;
//}
//[HarmonyPatch(typeof(PassiveModel), "Init")]
//[HarmonyPrefix]
//public static void CustomPassivePatcher2(PassiveModel __instance, BattleUnitModel owner)
//{
// foreach (var x in System.Reflection.Assembly.GetExecutingAssembly().GetTypes())
// {
// Log.LogInfo(x.Name);
// }
// {
// //Type type = Type.GetType("PassiveAbility" + "_" + info.ID.ToString());
// PassiveAbility type = new PassiveAbility_9991001();
// Log.LogFatal(type == null);
// Log.LogFatal("Passive 3333");
// Log.LogFatal("Passive 4444444");
// Log.LogFatal("Passive 55555555");
// if (type != null)
// {
// Log.LogFatal("Passive 1111");
// PassiveAbility script = (type as PassiveAbility);
// __instance._script = script;
// __instance._script._id = 9991001;
// Log.LogFatal("Passive 222222");
// }
// else
// {
// Log.LogFatal("Passive is null");
// }
// //__instance._classInfo.id = 9991001;
// }
//}
//[HarmonyPatch(typeof(HttpRequestCommand<ResPacket_NULL, ResPacket_NULL>), "OnResponse")]
//[HarmonyPostfix]
//public static void ResponseLogger(string responseJson)
//{
// Log.LogInfo($"Response: {responseJson}");
// //Log.LogFatal($"LoadingAsset: {label}/{resourceId}");
//}
//[HarmonyPatch(typeof(AddressableManager), "LoadAssetSync")]
//[HarmonyPostfix]
//public static void lol(string label, string resourceId)
//{
// Log.LogFatal($"LoadingAsset: {label}/{resourceId}");
//}
[HarmonyPatch(typeof(BattleUnitView), "Init")]
[HarmonyPostfix]
public static void UniversalSkinPatcher(BattleUnitView __instance, BattleUnitModel model, int instanceID, int level, int gaksungLevel)
{
int id = model.UnitDataModel.ClassInfo.ID;
if (aplist.ContainsKey(id))
{
(string, string) apd = aplist[id];
{
CharacterAppearance characterAppearance = null;
string appearanceID = apd.Item2;
GameObject item = SingletonBehavior<AddressableManager>.Instance.LoadAssetSync<GameObject>(apd.Item1, apd.Item2, __instance.skinPivot, null).Item1;
if (item == null)
{
return;
}
if (item != null)
{
foreach (var x in __instance._appearances)
{
x.gameObject.SetActive(false);
}
__instance._appearances = new Il2CppSystem.Collections.Generic.List<CharacterAppearance>();
characterAppearance = item.GetComponent<CharacterAppearance>();
if (characterAppearance != null)
{
characterAppearance.Initialize(__instance);
characterAppearance.charInfo.appearanceID = appearanceID;
}
}
//CharacterAppearance characterAppearance = SDCharacterSkinUtil.CreateSkin(__instance, model, __instance.skinPivot);
if (characterAppearance == null)
{
Debug.LogError(model.GetAppearanceID() + " is not exist");
}
else
{
__instance._appearances.Add(characterAppearance);
}
__instance._curAppearance = (__instance._mainAppearance = __instance._appearances[0]);
foreach (var x in __instance._appearances)
{
if (__instance._curAppearance != null)
{
__instance._curAppearance.gameObject.SetActive(false);
}
__instance._curAppearance = characterAppearance;
__instance._curAppearance.gameObject.SetActive(true);
__instance._curAppearance.ChangeMotion(MOTION_DETAIL.Idle, false, -1, false, null);
__instance._curAppearance.ChangeDefaultSpineRenderer(true, false);
__instance._mainAppearance = __instance._curAppearance;
__instance.UnitCollition.Init(__instance, __instance._curAppearance.charInfo.character_weight);
__instance.UIManager.Init_ChangeAppearance(__instance._unitModel, __instance);
__instance._viewShadow.SetSize(__instance._curAppearance.charInfo.character_radius);
__instance.RefreshEffects();
x.Init_Spine(characterAppearance);
x.ChangeDefaultSpineRenderer(true, false);
}
__instance._curAppearance.SortRenderQueue(3000);
}
}
else
{
foreach (var x in __instance._appearances)
{
Log.LogInfo(x.name);
}
}
//return true;
}
//public static void AddEgoGiftsToBattleUnit<T>(T __instance)
//{
// Log.LogFatal(__instance.GetType());
// BattleUnitModel _i = __instance as BattleUnitModel;
// if (__instance is BattleUnitModel_Abnormality)
// {
// foreach ((int eid, int pr, int id) in egolist["Abnormality"])
// {
// _i.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
// else if (__instance is BattleUnitModel_Abnormality_Part)
// {
// foreach ((int eid, int pr) in egolist["Abnormality_Part"])
// {
// _i.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
// else if (__instance is BattleUnitModel_Ally)
// {
// foreach ((int eid, int pr) in egolist["Ally"])
// {
// _i.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
// else if (__instance is BattleUnitModel_Assistant)
// {
// foreach ((int eid, int pr) in egolist["Assistant"])
// {
// _i.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
// else if (__instance is BattleUnitModel_Enemy)
// {
// foreach ((int eid, int pr) in egolist["Enemy"])
// {
// _i.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
// else if (__instance is BattleUnitModel_Opponent)
// {
// foreach ((int eid, int pr) in egolist["Opponent"])
// {
// _i.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
// else if (__instance is BattleUnitModel_Player)
// {
// foreach ((int eid, int pr) in egolist["Player"])
// {
// _i.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
//}
//[HarmonyPatch(typeof(PlayerUnitSpriteList), "GetEgoCGData")]
//[HarmonyPrefix]
//public static bool EgoAlephFixer(Sprite __result, string cgId, SKILL_TYPE egoSkillType = SKILL_TYPE.EGO_AWAKEN)
//{
// if (cgId == "20499")
// {
// cgId = "20307";
// }
// if (egoSkillType == SKILL_TYPE.EGO_EROSION)
// {
// __result = SingletonBehavior<AddressableManager>.Instance.LoadAssetSync<Sprite>("Unit_EgoCG", cgId + "_e_cg", null, null).Item1;
// return false;
// }
// __result = SingletonBehavior<AddressableManager>.Instance.LoadAssetSync<Sprite>("Unit_EgoCG", cgId + "_cg", null, null).Item1;
// return false;
// //Log.LogFatal(cgId);
// //if (cgId == "20499")
// //{
// // cgId.Replace("20499", "20307");
// //}
// //return true;
//}
//[HarmonyPatch(typeof(BattleUnitModel), "Init")]
//[HarmonyPostfix]
//public static void egogift(BattleUnitModel __instance)
//{
// if (__instance.GetCharacterID() != -1)
// {
// foreach ((int eid, int pr, int id) in egolist["Player"])
// {
// if (id != 0 && id == __instance.UnitDataModel._classInfo.ID)
// {
// __instance.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// else if (id == 0)
// {
// __instance.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
// }
// else
// {
// foreach ((int eid, int pr, int id) in egolist["Enemy"])
// {
// if (id != 0 && id == __instance.UnitDataModel._classInfo.ID)
// {
// __instance.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// else if (id == 0)
// {
// __instance.AddEgoGiftAbility(Singleton<StaticDataManager>.Instance.EgoGiftDataMediator.GetEgoGiftAbilityById(eid, pr));
// }
// }
// }
//}
[HarmonyPatch(typeof(StageController), "InitStage")]
[HarmonyPrefix]
public static void DungeonFixer(StageController __instance)
{
if (__instance.StageModel.ClassInfo.ID == 1 || __instance.StageModel.ClassInfo.ID == 2 || __instance.StageModel.ClassInfo.ID == 3)
{
DungeonProgressManager._isOnDungeon = true;
DungeonProgressManager._progressBridge = new MirrorDungeonProgressBridge
{
_egoGiftManager = new EgoGiftManager(),
_units = new Il2CppSystem.Collections.Generic.List<DungeonUnitModel>(),
};
Singleton<UserDataManager>.Instance._mirrorDungeonSaveDataManager = new UserMirrorDungeonSaveDataManager();
//var lol = new Il2CppSystem.Collections.Generic.List<int>();
//lol.Add(10109);
//DungeonProgressManager._progressBridge.EgoGiftManager._egoGiftList.Add(new AcquiredEgoGift(9004, 0, lol));
var gifts = new Il2CppSystem.Collections.Generic.List<DungeonMapEgoGift>();
//gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(1))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9004))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9014))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9017))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9021))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9058))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9068))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9118))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9153))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9419))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9423))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9710))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9739))); // Phlebotomy Pack - only works via old method
gifts.Add(new DungeonMapEgoGift(new DungeonMapEgoGiftFormat(9154))); // Phlebotomy Pack - only works via old method
//gifts.Add(new DungeonMapEgoGift(9004)); // Phlebotomy Pack - only works via old method
//gifts.Add(new DungeonMapEgoGift(9014)); // Rusty Commemorative Coin
//gifts.Add(new DungeonMapEgoGift(9017)); // Lithograph
//gifts.Add(new DungeonMapEgoGift(9021)); // Blue Zippo Lighter
//gifts.Add(new DungeonMapEgoGift(9058)); // Disk Fragment
//gifts.Add(new DungeonMapEgoGift(9068)); // Grand Welcome
//gifts.Add(new DungeonMapEgoGift(9118)); // Bone Stake
//gifts.Add(new DungeonMapEgoGift(9153)); // Oracle
//gifts.Add(new DungeonMapEgoGift(9419)); // Spicebush Branch
//gifts.Add(new DungeonMapEgoGift(9423)); // Broken Glasses
//gifts.Add(new DungeonMapEgoGift(9710)); // Huge Gift Sack
//gifts.Add(new DungeonMapEgoGift(9739)); // Crystallized Blood
//gifts.Add(new DungeonMapEgoGift(9154)); // imposed weight
DungeonProgressManager._progressBridge.EgoGiftManager.SetEgoGiftList(gifts, false);
//Log.LogFatal(DungeonProgressManager._progressBridge.EgoGiftManager._egoGiftList[0].EgoGiftID);
Log.LogFatal($"DungeonFixer: {Singleton<StageController>.Instance.IsDungeonOn}");
Log.LogFatal($"DungeonFixer: {DungeonProgressManager.isOnDungeon}");
Log.LogFatal($"DungeonFixer: {DungeonProgressManager.IsMirrorDungeon}");
Log.LogFatal($"DungeonFixer: {DungeonProgressManager.IsRailwayDungeon}");
_egostage = true;
}
}
//else if (__instance.StageModel.ClassInfo.ID == 3)
//{
// DungeonProgressManager._isOnDungeon = true;
// DungeonProgressManager._progressBridge = new RailwayDungeonProgressBridge
// {
// _egoGiftManager = new EgoGiftManager(),
// _units = new Il2CppSystem.Collections.Generic.List<DungeonUnitModel>(),
// };
// Singleton<UserDataManager>.Instance._mirrorDungeonSaveDataManager = new UserMirrorDungeonSaveDataManager();
// //var lol = new Il2CppSystem.Collections.Generic.List<int>();
// //lol.Add(10109);
// //DungeonProgressManager._progressBridge.EgoGiftManager._egoGiftList.Add(new AcquiredEgoGift(9004, 0, lol));
// var gifts = new Il2CppSystem.Collections.Generic.List<DungeonMapEgoGift>();
// //gifts.Add(new DungeonMapEgoGift(9004)); // Phlebotomy Pack - only works via old method
// gifts.Add(new DungeonMapEgoGift(9014)); // Rusty Commemorative Coin
// gifts.Add(new DungeonMapEgoGift(9017)); // Lithograph
// gifts.Add(new DungeonMapEgoGift(9021)); // Blue Zippo Lighter
// gifts.Add(new DungeonMapEgoGift(9058)); // Disk Fragment
// gifts.Add(new DungeonMapEgoGift(9068)); // Grand Welcome
// gifts.Add(new DungeonMapEgoGift(9118)); // Bone Stake
// gifts.Add(new DungeonMapEgoGift(9153)); // Oracle
// gifts.Add(new DungeonMapEgoGift(9419)); // Spicebush Branch
// gifts.Add(new DungeonMapEgoGift(9423)); // Broken Glasses
// gifts.Add(new DungeonMapEgoGift(9710)); // Huge Gift Sack
// gifts.Add(new DungeonMapEgoGift(9739)); // Crystallized Blood
// gifts.Add(new DungeonMapEgoGift(9154)); // imposed weight
// DungeonProgressManager._progressBridge.EgoGiftManager.SetEgoGiftList(gifts, false);
// //Log.LogFatal(DungeonProgressManager._progressBridge.EgoGiftManager._egoGiftList[0].EgoGiftID);
// Log.LogFatal($"DungeonFixer: {Singleton<StageController>.Instance.IsDungeonOn}");
// Log.LogFatal($"DungeonFixer: {DungeonProgressManager.isOnDungeon}");
// Log.LogFatal($"DungeonFixer: {DungeonProgressManager.IsMirrorDungeon}");
// Log.LogFatal($"DungeonFixer: {DungeonProgressManager.IsRailwayDungeon}");
// _egostage = true;
//}
//}
//[HarmonyPatch(typeof(MirrorDungeonProgressBridge), "GetAdditionalEgoGiftAbilityNames")]
//[HarmonyPrefix]
//public static bool DungeonFixer77(Il2CppSystem.Collections.Generic.List<EgoGiftAbilityNameData> __result)
//{
// Log.LogInfo("DungeonFixer77");
// __result = new Il2CppSystem.Collections.Generic.List<EgoGiftAbilityNameData>();
// __result.Add(new EgoGiftAbilityNameData("hi lol", EGO_GIFT_ABILITY_NAME_TYPES.ITEM));
// return true;
//}
[HarmonyPatch(typeof(BattleUIRoot), "Init")]
[HarmonyPrefix]
public static void DungeonFixer1()
{
if (_egostage)
{
Log.LogInfo("DungeonFixer1");
DungeonProgressManager._isOnDungeon = false;
}
//return false;
}
[HarmonyPatch(typeof(StageController), "CreateAllyUnits")]
[HarmonyPrefix]
public static void DungeonFixer2()
{
if (_egostage)
{
Log.LogInfo("DungeonFixer2");
DungeonProgressManager._isOnDungeon = false;
}
//return false;
}
[HarmonyPatch(typeof(VoiceGenerator), "Init_Battle")]
[HarmonyPrefix]
public static void DungeonFixer3()
{
if (_egostage)
{
Log.LogInfo("DungeonFixer3");
DungeonProgressManager._isOnDungeon = true;
}
//return false;
}
[HarmonyPatch(typeof(GlobalGameManager), "LeaveStage")]
[HarmonyPrefix]
public static void DungeonFixer4()
{
pss.Clear();
if (_egostage)
{
Log.LogInfo("DungeonFixer4");
DungeonProgressManager._isOnDungeon = false;
DungeonProgressManager.ClearData();
_egostage = false;
}
//return false;
}
[HarmonyPatch(typeof(MainLobbyUIPanel), "Initialize")]
[HarmonyPostfix]
public static void PostMainUIPatch()
{
if (!patched)
{
Log.LogFatal(JailbreakChecker.IsJailbroken());
Log.LogFatal(RootJailbreakChecker.IsDeviceRootedOrJailbroken());
Log.LogFatal(Singleton<ServerSelector>.Instance.GetServerURL());
Log.LogFatal(Singleton<ServerSelector>.Instance.GetBattleLogServerURL());
Log.LogFatal(Singleton<ServerSelector>.Instance.IsEnablePacketCrypt());
Log.LogFatal(Singleton<ServerSelector>.Instance.IsEnableBattleLogPacketCrypt());
//var nd = new EnemyData {
// isHide = false,
// unitCount = 1,
// unitID = 97712,
// unitLevel = 45,
//};
//var nd1 = new EnemyData
//{
// isHide = false,
// unitCount = 1,
// unitID = 71012,
// unitLevel = 45,
//};
//Singleton<StaticDataManager>.Instance.GetStage(10718).waveList[0].GetEnemyDataList().Add(nd);
//Singleton<StaticDataManager>.Instance.GetStage(10718).waveList[0].GetEnemyDataList().Add(nd1);
//{
// var total = "[";
// foreach (var x in Singleton<TextDataSet>.Instance.EgoGiftData.GetList())
// {
// total += JsonUtility.ToJson(x);
// total += ",";
// }
// total += "]";
// File.WriteAllText(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "Text_EgoGiftData.json", total);
//}
//{
// var total = "[";
// foreach (var x in Singleton<TextDataSet>.Instance.EgoGiftCategory.GetList())
// {
// total += JsonUtility.ToJson(x);
// total += ",";
// }