-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlternativeAscensionPatches.cs
3628 lines (3235 loc) · 176 KB
/
AlternativeAscensionPatches.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 HarmonyLib;
using HarmonyLib.Tools;
using NeedyXML;
using NGO;
using ngov3;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml.Serialization;
using UniRx;
using UnityEngine;
using NeedyEnums;
using Stream = NeedyXML.Stream;
using System.Text.RegularExpressions;
using Cysharp.Threading.Tasks;
using System.Threading;
using System.Reflection.Emit;
using Thread = NeedyXML.Thread;
using Component = UnityEngine.Component;
using TMPro;
using UnityEngine.AddressableAssets;
using ngov3.Effect;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using DG.Tweening;
using UnityEngine.Rendering;
using Extensions;
using UnityEngine.Audio;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.UI;
using System.Runtime.InteropServices.WindowsRuntime;
using System.ComponentModel;
using UnityEngine.SceneManagement;
namespace AlternativeAscension
{
internal partial class AAPatches
{
[HarmonyPatch(typeof(StatusManager))]
public static class StatusManagerPatches
{
[HarmonyPatch(nameof(StatusManager.NewStatus))]
[HarmonyPostfix]
public static void NewStatusPrefix(StatusManager __instance)
{
__instance.statuses.Add(new Status(ModdedStatusType.OdekakeCounter.Swap(), 0, 99, 0, false));
__instance.statuses.Add(new Status(ModdedStatusType.OdekakeStressMultiplier.Swap(), 0, 11, 0, false));
__instance.statuses.Add(new Status(ModdedStatusType.FollowerPlotFlag.Swap(), 0, 20, 0, false));
__instance.statuses.Add(new Status(ModdedStatusType.OdekakeCountdown.Swap(), 2, 2, 0, false));
__instance.statuses.Add(new Status(ModdedStatusType.AMAStress.Swap(), 0, 99, -99, false));
}
[HarmonyPostfix]
[HarmonyPatch(nameof(StatusManager.Diffs))]
public static void DiffsPrefix(CmdMaster.Param cmd, ref StatusManager __instance, ref List<StatusDiff> __result)
{
AltAscMod.log.LogMessage($"Diffing!");
AltAscMod.log.LogMessage($"Getting diff for {cmd?.Id}");
int stressMult = __instance.GetStatus(ModdedStatusType.OdekakeStressMultiplier.Swap());
if (stressMult > 0 && (cmd.Id.StartsWith("Odekake")))
{
int index = __result.FindIndex(diff => diff.statusType == StatusType.Stress);
StatusDiff sd = __result[index];
//NeedyMintsMod.log.LogMessage($"Updating odekake stress diff from {sd.delta} (original) to {sd.delta*(1-stressMult)} (with Follower stress)");
sd.delta = sd.delta * (1 - stressMult);
__result[index] = sd;
}
}
[HarmonyPrefix]
[HarmonyPatch(nameof(StatusManager.UpdateStatusMaxToNumber))]
public static void UpdateStatusMaxToNumberPrefix(ref StatusManager __instance, StatusType type, int to)
{
if (type != StatusType.DayIndex || SingletonMonoBehaviour<AltAscModManager>.Instance.lockDayCount) return;
DayPassing2D dayPassing2D = GameObject.Find("DayPassingCover").GetComponent<DayPassing2D>();
//if (dayPassing2D.playingAnimation && to == 100) return;
// Get new maximum
int oldMax = __instance.statuses.Find(s => s.statusType == type).maxValue.Value;
int destMax = Mathf.Max(30, to);
AltAscMod.log.LogMessage($"Updating day max from {oldMax} to {to}");
if (oldMax == destMax) return;
// Get info / traversal info
MethodInfo dayPassMethod = typeof(DayPassing2D).GetMethod(nameof(DayPassing2D.dayPass), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod);
Traverse tmpTextLabels = new Traverse(dayPassing2D).Field(nameof(DayPassing2D._tmpFader)).Field(nameof(TMPTextsFader._tmpTexts));
Traverse CalendarScroll = new Traverse(dayPassing2D).Field(nameof(DayPassing2D.CalendarScroll));
Traverse SpriteFader = new Traverse(dayPassing2D).Field(nameof(DayPassing2D._spriteFader)).Field(nameof(SpriteRenderersFader._renderers));
// Get day
ReactiveProperty<int> dayIndex = SingletonMonoBehaviour<StatusManager>.Instance.GetStatusObservable(StatusType.DayIndex);
// Get data from traversals
List<TMP_Text> textRenderers = tmpTextLabels.GetValue<List<TMP_Text>>();
RectTransform Calendar = CalendarScroll.GetValue<RectTransform>();
// Remove old subscriptions
dayIndex.Where((int d) => true).Take(1);
// Get data for adding new days
Vector3 offset = Calendar.GetChild(1).transform.position - Calendar.GetChild(0).transform.position;
Transform dayPrefab = Calendar.GetChild(30);
Vector3 dayPos = dayPrefab.position;
// TODO: Calendar is broken since we're trying to add arrows, pls fix ame will be proud of you AND saves will work properly!!!!
// And then you can work on the login stuff and that'll be cool too!!!!! You're almost there!!!!!!!!!!
int arrowIndex = textRenderers.FindIndex(t => t.text == "30") + 1;
TMP_Text arrowPrefab = textRenderers[arrowIndex];
Vector3 arrowPos = arrowPrefab.transform.position;
AltAscMod.log.LogMessage($"Calendar children: {Calendar.childCount}");
if (to > oldMax)
{
// Create new labels
for (int i = oldMax + 1; i < to + 1; i++)
{
Transform newDayObj = UnityEngine.Object.Instantiate(dayPrefab, dayPos + offset * (i - 30), Quaternion.identity, Calendar);
//TMP_Text newArrow = UnityEngine.Object.Instantiate(arrowPrefab, arrowPos + offset * (i - 30), Quaternion.identity, Calendar);
newDayObj.name = $"Day {i}";
AltAscMod.log.LogMessage($"newDayObj childcount: {newDayObj.transform.childCount}");
//Transform newArrowObj = UnityEngine.Object.Instantiate(arrowsPrefab, arrowsPos + offset * (i - 30), Quaternion.identity, Calendar);
// Add day text to opacity
TextMeshPro dayText = newDayObj.GetComponent<TextMeshPro>();
dayText.text = i.ToString();
textRenderers.Add(dayText);
// Add progression arrow
TextMeshPro arrow = newDayObj.GetChild(0).GetComponent<TextMeshPro>();
textRenderers.Add(arrow);
}
}
tmpTextLabels.SetValue(textRenderers);
// Today prevention is to make sure DayPassing doesn't rerender if we change
// the maximum during an event (for example, during Angel Watch)
int today = __instance.statuses.Find(s => s.statusType == type).currentValue.Value;
dayIndex.Where((int d) => d != today).Subscribe(delegate (int t)
{
if (SingletonMonoBehaviour<AltAscModManager>.Instance.lockDayCount) return;
dayPassMethod.Invoke(dayPassing2D, new object[] { dayIndex.Value, 0, 0 });
//nonRefDayPass2D.dayPass(dayIndex.Value, 0, 0);
}).AddTo(dayPassing2D.gameObject);
}
}
[HarmonyPatch(typeof(Action_SleepToTomorrow3))]
public static class SleepToTomorrowPatches
{
/*
[HarmonyPostfix]
[HarmonyPatch(nameof(Action_SleepToTomorrow3.startEvent))]
public static void SleepToTomorrowPostfix()
{
StatusManager evMan = SingletonMonoBehaviour<StatusManager>.Instance;
evMan.UpdateStatus(ModdedStatusType.SleepyAmeCounter.Swap(), 1);
int sleepCount = evMan.GetStatus(ModdedStatusType.SleepyAmeCounter.Swap());
NeedyMintsMod.log.LogMessage($"Slept {sleepCount} time(s)!");
if (sleepCount >= NeedyMintsMod.SLEEPS_TO_SLEEPY)
{
SingletonMonoBehaviour<EventManager>.Instance.nowEnding = (EndingType)ModdedEndingType.Ending_Sleepy;
SingletonMonoBehaviour<EventManager>.Instance.AddEventQueue<Ending_Sleepy>();
Queue<NgoEvent> eventQueue = SingletonMonoBehaviour<EventManager>.Instance.eventQueue;
}
}*/
}
[HarmonyPatch(typeof(NetaManager))]
public static class NetaManagerPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(NetaManager.fetchNextActionHint))]
public static void fetchNextActionPrune(ref List<Tuple<ActionType, AlphaLevel>> __result)
{
//AltAscMod.log.LogMessage("Pruning!");
int sleeps = SingletonMonoBehaviour<AltAscModManager>.Instance.sleepCount;
if (sleeps + 1 >= AltAscMod.SLEEPS_BEFORE_SLEEPY) __result.RemoveAll(t => t.Item1 == ActionType.SleepToTomorrow);
if (CheckComiketAvailable())
{
AlphaLevel alpha = new AlphaLevel((AlphaType)(int)ModdedAlphaType.FollowerAlpha, 1);
__result.Add(Tuple.Create((ActionType)(int)ModdedActionType.OdekakeAriake, alpha));
}
if (SingletonMonoBehaviour<StatusManager>.Instance.GetStatus(ModdedStatusType.FollowerPlotFlag.Swap()) >= (int)FollowerPlotFlagValues.PostDepaz)
{
__result.RemoveAll(t => t.Item1 == ActionType.Internet2ch || t.Item1 == (ActionType)(int)ModdedActionType.Internet2chStalk);
}
if (SingletonMonoBehaviour<StatusManager>.Instance.GetStatus(ModdedStatusType.FollowerPlotFlag.Swap()) == (int)FollowerPlotFlagValues.AngelFuneral)
{
__result.Clear();
}
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NetaManager.Haishined))]
public static void HaishinedPrefix(AlphaType alpha, int level)
{
AltAscMod.log.LogMessage($"Haishined {alpha} level {level}");
}
}
[HarmonyPatch(typeof(JineDataConverter))]
public static class JineDataConverterPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(JineDataConverter.getJineRawList))]
public static void getJineRawListPrefix(out bool __state, ref List<LineMaster.Param> ___JineRawList)
{
__state = ___JineRawList == null;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(JineDataConverter.getJineRawList))]
public static void getJineRawListPostfix(bool __state, ref List<LineMaster.Param> ___JineRawList, ref List<LineMaster.Param> __result)
{
if (!__state) return;
foreach (Jine jine in AltAscMod.DATA.Jines.Jine)
{
LineMaster.Param newParam = new LineMaster.Param()
{
BodyEn = jine.BodyEN,
BodyCn = "",
BodyFr = "",
BodyGe = "",
BodyIt = "",
BodyJp = "[Not translated]",
BodyKo = "",
BodyRu = "",
BodySp = "",
BodyTw = "",
BodyVn = "",
ParentId = jine.Id,
Id = jine.Id,
Speaker = jine.Speaker,
ArgumentType = "N/A",
ImageId = "N/A"
};
AltAscMod.log.LogMessage($"Adding jine {newParam.Id} to jines");
__result.Add(newParam);
}
___JineRawList = __result;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(JineDataConverter.getJineFromTypeId))]
public static bool getJineFromTypeIdPrefix(JineType t)
{
return !CheckModdedPrefix(typeof(JineType), typeof(ModdedJineType), t).Item1;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(JineDataConverter.getJineFromTypeId))]
public static void getJineFromTypeIdPostfix(JineType t, ref LineMaster.Param __result)
{
if (!CheckModdedPrefix(typeof(JineType), typeof(ModdedJineType), t).Item1) return;
ModdedJineType modT = (ModdedJineType)(int)t;
__result = JineDataConverter.getJineRawList().Find((LineMaster.Param j) => j.Id == modT.ToString());
}
}
[HarmonyPatch(typeof(EndingDialog))]
public static class EndingDialogPatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(EndingDialog.OnLanguageChanged))]
public static void OnLanguageChangedPostfix(ref EndingDialog __instance, ref UnityEngine.UI.Button ____submitButton, EndingType ___end)
{
if (!CheckModdedPrefix(typeof(EndingType), typeof(ModdedEndingType), ___end).Item1) return;
if (___end == ModdedEndingType.Ending_Followers.Swap())
{
if (!(SingletonMonoBehaviour<StatusManager>.Instance.GetStatus(ModdedStatusType.OdekakeStressMultiplier.Swap()) > 7 &&
SingletonMonoBehaviour<StatusManager>.Instance.GetStatus(ModdedStatusType.AMAStress.Swap()) >= 15))
{
____submitButton.GetComponentInChildren<TMP_Text>().text = NgoEx.SystemTextFromType(ModdedSystemTextType.System_InternetYamero.Swap(), SingletonMonoBehaviour<Settings>.Instance.CurrentLanguage.Value);
}
else
{
____submitButton.GetComponentInChildren<TMP_Text>().text = NgoEx.SystemTextFromType(ModdedSystemTextType.System_RealYamero.Swap(), SingletonMonoBehaviour<Settings>.Instance.CurrentLanguage.Value);
}
}
else if (___end == ModdedEndingType.Ending_Love.Swap())
{
____submitButton.GetComponentInChildren<TMP_Text>().text = NgoEx.SystemTextFromType(ModdedSystemTextType.System_LoveConfirm.Swap(), SingletonMonoBehaviour<Settings>.Instance.CurrentLanguage.Value);
}
}
}
[HarmonyPatch(typeof(NgoEx))]
public static class NgoExPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.ReasonTextFromEDType))]
public static bool ReasonTextFromEDTypePrefix(EndingType type, LanguageType lang, out int __state)
{
Tuple<bool, int> tuple = CheckModdedPrefix(typeof(EndingType), typeof(ModdedEndingType), type);
__state = tuple.Item2;
return !tuple.Item1;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.ReasonTextFromEDType))]
public static void ReasonTextFromEDTypePostfix(ModdedEndingType __state, ref string __result)
{
AltAscMod.log.LogMessage($"End: {__state}");
if (__state == 0) return;
// Get modded reason
switch (__state)
{
case ModdedEndingType.Ending_Sleepy:
__result = AltAscMod.DATA.Endings.Ending.Find(e => e.Id == "Ending_Sleepy").Osimai;
break;
case ModdedEndingType.Ending_Followers:
__result = AltAscMod.DATA.Endings.Ending.Find(e => e.Id == "Ending_Followers").Osimai;
break;
case ModdedEndingType.Ending_Love:
__result = AltAscMod.DATA.Endings.Ending.Find(e => e.Id == "Ending_Love").Osimai;
break;
default: return;
}
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.CmdFromType))]
public static bool CmdFromTypePrefix(CmdType type, out int __state)
{
Tuple<bool, int> tuple = CheckModdedPrefix(typeof(CmdType), typeof(ModdedCmdType), type);
string v;
if (tuple.Item1) v = ((ModdedCmdType)tuple.Item2).ToString();
else
{
//NeedyMintsMod.log.LogMessage($"Found nat cmdtype {(CmdType)tuple.Item2} {type}");
v = ((CmdType)(int)tuple.Item2).ToString();
}
AltAscMod.log.LogMessage($"{v} modded? {tuple} {type}");
__state = tuple.Item2;
return !tuple.Item1;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.CmdFromType))]
public static void CmdFromTypePostfix(int __state, ref CmdMaster.Param __result)
{
if (!CheckModdedPrefix(typeof(CmdType), typeof(ModdedCmdType), __state).Item1) return;
switch ((ModdedCmdType)__state)
{
case ModdedCmdType.OdekakeAriake:
__result = ModdedCommandParams.OdekakeAriakeParam;
break;
case ModdedCmdType.OkusuriDaypassStalk:
__result = ModdedCommandParams.OkusuriDaypassStalkParam;
break;
case ModdedCmdType.HaishinComiket:
__result = ModdedCommandParams.HaishinComiketParam;
break;
case ModdedCmdType.OdekakePanic1:
__result = ModdedCommandParams.OdekakePanic1Param;
break;
case ModdedCmdType.OdekakePanic2:
__result = ModdedCommandParams.OdekakePanic2Param;
break;
case ModdedCmdType.OdekakePanic3:
__result = ModdedCommandParams.OdekakePanic3Param;
break;
case ModdedCmdType.OdekakePanic4:
__result = ModdedCommandParams.OdekakePanic4Param;
break;
case ModdedCmdType.OdekakeBreak:
__result = ModdedCommandParams.OdekakeBreakParam;
break;
case ModdedCmdType.Internet2chStalk:
__result = ModdedCommandParams.Internet2chStalkParam;
break;
case ModdedCmdType.HaishinAngelWatch:
__result = ModdedCommandParams.HaishinAngelWatch;
break;
case ModdedCmdType.HaishinAngelDeath:
__result = ModdedCommandParams.HaishinAngelDeath;
break;
case ModdedCmdType.OdekakeFuneral:
__result = ModdedCommandParams.OdekakeFuneralParam;
break;
case ModdedCmdType.SleepToEternity:
__result = ModdedCommandParams.SleepToEternityParam;
break;
default:
AltAscMod.log.LogMessage("Invalid modded cmd type!");
break;
}
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.ActFromType))]
public static bool ActfromTypePrefix(ActionType type, out int __state)
{
Tuple<bool, int> tuple = CheckModdedPrefix(typeof(ActionType), typeof(ModdedActionType), type);
__state = tuple.Item2;
return !tuple.Item1;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.ActFromType))]
public static void ActFromTypePostfix(ref ActMaster.Param __result, int __state)
{
if (!CheckModdedPrefix(typeof(ActionType), typeof(ModdedActionType), __state).Item1) return;
ModdedActionType type = (ModdedActionType)__state;
switch (type)
{
case ModdedActionType.OdekakeAriake:
__result = ModdedActionParams.OdekakeAriakeParam;
break;
case ModdedActionType.OdekakePanic1:
__result = ModdedActionParams.OdekakePanic1Param;
break;
case ModdedActionType.OdekakePanic2:
__result = ModdedActionParams.OdekakePanic2Param;
break;
case ModdedActionType.OdekakePanic3:
__result = ModdedActionParams.OdekakePanic3Param;
break;
case ModdedActionType.OdekakePanic4:
__result = ModdedActionParams.OdekakePanic4Param;
break;
case ModdedActionType.OdekakeBreak:
__result = ModdedActionParams.OdekakeBreakParam;
break;
case ModdedActionType.OdekakeFuneral:
__result = ModdedActionParams.OdekakeFuneralParam;
break;
case ModdedActionType.SleepToEternity:
__result = ModdedActionParams.SleepToEternityParam;
break;
default:
break;
}
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.CmdName), new Type[] { typeof(CmdType), typeof(LanguageType) })]
public static bool CmdNamePrefix(CmdType type)
{
return !CheckModdedPrefix(typeof(CmdType), typeof(ModdedCmdType), type).Item1;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.CmdName), new Type[] { typeof(CmdType), typeof(LanguageType) })]
public static void CmdNamePostfix(CmdType type, LanguageType lang, ref string __result)
{
if (!CheckModdedPrefix(typeof(CmdType), typeof(ModdedCmdType), type).Item1) return;
ModdedCmdType modType = (ModdedCmdType)(int)type;
CmdMaster.Param param = NgoEx.getCmds().FirstOrDefault((CmdMaster.Param x) => x.Id == modType.ToString());
switch (lang)
{
case LanguageType.JP:
__result = param.LabelJp;
return;
case LanguageType.CN:
__result = param.LabelCn;
return;
case LanguageType.KO:
__result = param.LabelKo;
return;
case LanguageType.TW:
__result = param.LabelTw;
return;
case LanguageType.VN:
__result = param.LabelVn;
return;
case LanguageType.FR:
__result = param.LabelFr;
return;
case LanguageType.IT:
__result = param.LabelIt;
return;
case LanguageType.GE:
__result = param.LabelGe;
return;
case LanguageType.SP:
__result = param.LabelSp;
return;
case LanguageType.RU:
__result = param.LabelRu;
return;
}
__result = param.LabelEn;
//NeedyMintsMod.log.LogMessage($"Outputting {__result} from {Environment.StackTrace}");
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.getCmds))]
public static void getCmdsPrefix(out bool __state, List<CmdMaster.Param> ___Cmds)
{
//NeedyMintsMod.log.LogMessage($"{Environment.StackTrace}");
__state = ___Cmds == null;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.getCmds))]
public static void getCmdsPostfix(bool __state, ref List<CmdMaster.Param> __result, ref List<CmdMaster.Param> ___Cmds)
{
if (!__state) return;
__result.Add(ModdedCommandParams.OdekakeAriakeParam);
__result.Add(ModdedCommandParams.OdekakePanic1Param);
__result.Add(ModdedCommandParams.OdekakePanic2Param);
__result.Add(ModdedCommandParams.OdekakePanic3Param);
__result.Add(ModdedCommandParams.OdekakePanic4Param);
__result.Add(ModdedCommandParams.OdekakeBreakParam);
__result.Add(ModdedCommandParams.OkusuriDaypassStalkParam);
__result.Add(ModdedCommandParams.HaishinComiketParam);
__result.Add(ModdedCommandParams.HaishinAngelWatch);
__result.Add(ModdedCommandParams.HaishinAngelDeath);
__result.Add(ModdedCommandParams.HaishinAngelFuneral);
__result.Add(ModdedCommandParams.Internet2chStalkParam);
__result.Add(ModdedCommandParams.OdekakeFuneralParam);
___Cmds = __result;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.getTenComments))]
public static void getTenCommentsPrefix(out bool __state, List<TenCommentMaster.Param> ___TenComments)
{
__state = ___TenComments == null;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.getTenComments))]
public static void getTenCommentsPostfix(bool __state, ref List<TenCommentMaster.Param> __result, ref List<TenCommentMaster.Param> ___TenComments)
{
if (!__state) return;
foreach (Stream stream in AltAscMod.DATA.Streams.Stream)
{
foreach (Speak spk in stream.Dialogue.Speak)
{
if (!__result.Any(t => t.Id == spk.Id))
{
TenCommentMaster.Param newParam = new TenCommentMaster.Param()
{
BodyEn = spk.BodyEN,
Id = stream.AlphaType + stream.AlphaLevel + "_" + spk.Id
};
__result.Add(newParam);
}
}
if (!__result.Any(t => t.Id == stream.AlphaType + stream.AlphaLevel + "_STREAMNAME"))
{
TenCommentMaster.Param newParam = new TenCommentMaster.Param()
{
BodyEn = stream.Name,
Id = stream.AlphaType + stream.AlphaLevel + "_STREAMNAME"
};
__result.Add(newParam);
}
}
___TenComments = __result;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.getEndings))]
public static void getEndingsPrefix(out bool __state, List<EndingMaster.Param> ___Endings)
{
__state = ___Endings == null;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.getEndings))]
public static void getEndingsPostfix(bool __state, ref List<EndingMaster.Param> __result, ref List<EndingMaster.Param> ___Endings)
{
if (!__state) return;
foreach (object obj in AltAscMod.DATA.Endings.Ending)
foreach (Ending ending in AltAscMod.DATA.Endings.Ending)
{
if (!__result.Any(t => t.Id == ending.Id))
{
EndingMaster.Param newParam = new EndingMaster.Param()
{
Id = ending.Id,
EndingNameEn = ending.Name,
ReasonEn = ending.Osimai,
JissekiEn = ending.JissekiEn
};
__result.Add(newParam);
}
}
___Endings = __result;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.EndingFromType))]
public static bool EndingFromTypePrefix(EndingType type, out int __state)
{
Tuple<bool, int> tuple = CheckModdedPrefix(typeof(EndingType), typeof(ModdedEndingType), type);
string v;
if (tuple.Item1) v = ((ModdedEndingType)tuple.Item2).ToString();
else
{
//NeedyMintsMod.log.LogMessage($"Found nat cmdtype {(CmdType)tuple.Item2} {type}");
v = ((EndingType)(int)tuple.Item2).ToString();
}
AltAscMod.log.LogMessage($"{v} modded? {tuple} {type}");
__state = tuple.Item2;
return !tuple.Item1;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.EndingFromType))]
public static void EndingFromTypePostfix(int __state, EndingType type, ref EndingMaster.Param __result)
{
if (!CheckModdedPrefix(typeof(EndingType), typeof(ModdedEndingType), __state).Item1) return;
__result = NgoEx.getEndings().FirstOrDefault((EndingMaster.Param x) => x.Id == ((ModdedEndingType)(int)type).ToString());
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.getKusoComments))]
public static void getKusoCommentsPrefix(out bool __state, List<KusoCommentMaster.Param> ___Kusokomes)
{
__state = ___Kusokomes == null;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.getKusoComments))]
public static void getKusoCommentsPostfix(bool __state, ref List<KusoCommentMaster.Param> __result, ref List<KusoCommentMaster.Param> ___Kusokomes)
{
if (!__state) return;
foreach (Stream stream in AltAscMod.DATA.Streams.Stream)
{
foreach (Msg msg in stream.Chat.Msg)
{
if (!__result.Any(t => t.Id == msg.Id))
{
KusoCommentMaster.Param newParam = new KusoCommentMaster.Param()
{
BodyEn = msg.BodyEN,
Id = stream.AlphaType + stream.AlphaLevel + "_" + msg.Id
};
//NeedyMintsMod.log.LogMessage($"Added {newParam.Id} to kusos");
__result.Add(newParam);
}
}
}
___Kusokomes = __result;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.getKitunes))]
public static void getKitunesPrefix(out bool __state, List<KituneMaster.Param> ___Kitunes)
{
__state = ___Kitunes == null;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.getKitunes))]
public static void getKitunesPostfix(bool __state, ref List<KituneMaster.Param> ___Kitunes, ref List<KituneMaster.Param> __result)
{
if (!__state) return;
foreach (Thread thread in AltAscMod.DATA.ST.Threads)
{
foreach (Comment com in thread.Comments.Comment)
{
if (!__result.Any(t => t.Id == com.Id))
{
Regex rx = new Regex(@"\d*$");
int res = int.Parse(rx.Match(com.Id).Value);
KituneMaster.Param newParam = new KituneMaster.Param()
{
BodyEn = com.BodyEN,
FollowerRank = thread.Id,
Id = "Kitune_" + thread.Id + "_" + com.Id,
ResNumber = res
};
//NeedyMintsMod.log.LogMessage($"Added {newParam.Id} to kusos");
__result.Add(newParam);
}
}
}
___Kitunes = __result;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.getSuretais))]
public static void getSuretaisPrefix(out bool __state, List<KituneSuretaiMaster.Param> ___Suretais)
{
__state = ___Suretais == null;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.getSuretais))]
public static void getSuretaisPostfix(bool __state, ref List<KituneSuretaiMaster.Param> ___Suretais, ref List<KituneSuretaiMaster.Param> __result)
{
if (!__state) return;
foreach (Thread thread in AltAscMod.DATA.ST.Threads)
{
KituneSuretaiMaster.Param newParam = new KituneSuretaiMaster.Param()
{
Id = "Suretai_" + thread.Id,
BodyEn = thread.Title.BodyEN
};
__result.Add(newParam);
}
___Suretais = __result;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.getSystemTexts))]
public static void getSystemTextsPrefix(out bool __state, List<SystemTextMaster.Param> ___systemTexts)
{
__state = ___systemTexts == null;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.getSystemTexts))]
public static void getSystemTextsPostfix(bool __state, ref List<SystemTextMaster.Param> ___systemTexts, ref List<SystemTextMaster.Param> __result)
{
if (!__state) return;
AltAscMod.log.LogMessage($"TESTING: {AltAscMod.DATA.ST.Threads}");
foreach (Thread thread in AltAscMod.DATA.ST.Threads)
{
SystemTextMaster.Param newParam = new SystemTextMaster.Param()
{
Id = "Suretai_" + thread.Id,
BodyEn = thread.Title.BodyEN
};
AltAscMod.log.LogMessage($"Adding new system type suretai {newParam.Id}");
__result.Add(newParam);
}
foreach (NeedyXML.String str in AltAscMod.DATA.SysStrings.Strings)
{
SystemTextMaster.Param newParam = new SystemTextMaster.Param()
{
Id = str.Id,
BodyEn = str.BodyEN
};
AltAscMod.log.LogMessage($"Adding new system type {newParam.Id}");
__result.Add(newParam);
}
___systemTexts = __result;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.SystemTextFromTypeString))]
public static void SystemTypeFromTextStringPrefix(string type)
{
AltAscMod.log.LogMessage($"Attempting to get system type {type}");
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.SystemTextFromType))]
public static bool SystemTextFromTypePrefix(SystemTextType type, out bool __state)
{
__state = CheckModdedPrefix(typeof(SystemTextType), typeof(ModdedSystemTextType), type).Item1;
return !__state;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.SystemTextFromType))]
public static void SystemTextFromTypePostfix(SystemTextType type, LanguageType lang, bool __state, ref string __result)
{
if (!__state) return;
ModdedSystemTextType modType = (ModdedSystemTextType)(int)type;
SystemTextMaster.Param param = NgoEx.getSystemTexts().FirstOrDefault((SystemTextMaster.Param x) => x.Id == modType.ToString());
switch (lang)
{
case LanguageType.JP:
__result = param.BodyJp;
return;
case LanguageType.CN:
__result = param.BodyCn;
return;
case LanguageType.KO:
__result = param.BodyKo;
return;
case LanguageType.TW:
__result = param.BodyTw;
return;
case LanguageType.VN:
__result = param.BodyVn;
return;
case LanguageType.FR:
__result = param.BodyFr;
return;
case LanguageType.IT:
__result = param.BodyIt;
return;
case LanguageType.GE:
__result = param.BodyGe;
return;
case LanguageType.SP:
__result = param.BodySp;
return;
case LanguageType.RU:
__result = param.BodyRu;
return;
}
__result = param.BodyEn;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.TenTalk), new Type[] { typeof(TenCommentType), typeof(LanguageType) })]
public static bool TenTalkPrefix(TenCommentType type, LanguageType lang, ref string __result)
{
if (!CheckModdedPrefix(typeof(TenCommentType), typeof(ModdedTenCommentType), type).Item1) return true;
string id = ((ModdedTenCommentType)(int)type).ToString();
AltAscMod.log.LogMessage(id);
if (id == "None")
{
__result = "";
return false;
}
switch (lang)
{
case LanguageType.JP:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyJP;
return false;
case LanguageType.CN:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyCn;
return false;
case LanguageType.KO:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyKo;
return false;
case LanguageType.TW:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyTw;
return false;
case LanguageType.VN:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyVn;
return false;
case LanguageType.FR:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyFr;
return false;
case LanguageType.IT:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyIt;
return false;
case LanguageType.GE:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyGe;
return false;
case LanguageType.SP:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodySp;
return false;
case LanguageType.RU:
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyRu;
return false;
}
__result = NgoEx.getTenComments().FirstOrDefault((TenCommentMaster.Param x) => x.Id == id).BodyEn;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(nameof(NgoEx.TenTalk), new Type[] { typeof(string), typeof(LanguageType) })]
public static void TenTalk2Prefix(string id, LanguageType lang)
{
AltAscMod.log.LogMessage($"Tried to get {id}");
}
[HarmonyPostfix]
[HarmonyPatch(nameof(NgoEx.DayText))]
public static void DayTextPostfix(LanguageType lang, bool isLive, ref string __result)
{
try
{
if (SingletonMonoBehaviour<AltAscModManager>.Instance.isLoveLoop)
{
__result = NgoEx.SystemTextFromType(ModdedSystemTextType.System_LoveDay.Swap(), lang);
}
}
catch
{
return;
}
}
}
[HarmonyPatch(typeof(EndingManager))]
public static class EndingManagerPatches
{
[HarmonyPrefix]
[HarmonyPatch(nameof(EndingManager.GetEndingName))]
public static bool GetEndingNamePre(EndingType end, out ModdedEndingType __state)
{
Tuple<bool, int> tuple = CheckModdedPrefix(typeof(EndingType), typeof(ModdedEndingType), end);
__state = (ModdedEndingType)(int)tuple.Item2;
return !tuple.Item1;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(EndingManager.GetEndingName))]
public static void GetEndingNamePost(EndingType end, ref string __result)
{
Tuple<bool, int> data = CheckModdedPrefix(typeof(EndingType), typeof(ModdedEndingType), end);
if (!data.Item1) return;
__result = AltAscMod.DATA.GetEndingByID(((ModdedEndingType)(int)end).ToString()).Name;
}
/*[HarmonyTranspiler]
[HarmonyPatch(nameof(EndingManager.Awake))]
public static IEnumerable<CodeInstruction> AwakeTranspiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> ins = instructions.ToList();
List<CodeInstruction> outs = new List<CodeInstruction>();
for (int i = 0; i < ins.Count; i++)
{
if (ins[i].opcode == OpCodes.Ldtoken && ins[i].operand == typeof(EndingType) &&
ins[i + 2].opcode == OpCodes.Call && (ins[i + 2].operand as MethodInfo)?.Name == nameof(Enum.GetNames))
{
outs.Add(new CodeInstruction(OpCodes.Call, typeof(MintyOverdosePatches).GetMethod(nameof(MintyOverdosePatches.GetBothEndingNames))));
i += 2;
}
else outs.Add(ins[i]);
}
return outs;
}*/
[HarmonyPostfix]
[HarmonyPatch(nameof(EndingManager.Awake))]
public static void AwakePostfix(GameObject ____endingAchievement, ref EndingManager __instance, GameObject ____achievingBlock,
GameObject ____achievedBlock, GameObject ____unachievedBlock, EndingType ___end)
{
Transform endParent = ____endingAchievement.transform;
EndingBlockMaker(endParent, 24);
List<EndingType> mitaEnd = SingletonMonoBehaviour<Settings>.Instance.mitaEnd;
string[] moddedNames = Enum.GetNames(typeof(ModdedEndingType));
for (int i = 0; i < moddedNames.Length; i++)
{
string id = moddedNames[i];
if (id == ((ModdedEndingType)(int)___end).ToString())
{
global::UnityEngine.Object.Instantiate<GameObject>(____achievingBlock, endParent);
}
else if (mitaEnd.Exists((EndingType gotend) => ((ModdedEndingType)(int)gotend).ToString() == id))
{
global::UnityEngine.Object.Instantiate<GameObject>(____achievedBlock, endParent);
}
else
{
global::UnityEngine.Object.Instantiate<GameObject>(____unachievedBlock, endParent);
}
}
foreach (Component comp in endParent.GetComponents<Component>())
{
AltAscMod.log.LogMessage($"EndingManager Comp: {comp}");
}
}
}
[HarmonyPatch(typeof(ngov3.Odekake))]
public static class OdekakePatches
{
[HarmonyPostfix]
[HarmonyPatch(nameof(Odekake.Awake))]
public static void AwakePostfix(Odekake __instance)
{
FieldInfo actionTypeField = typeof(ActionButton).GetField(nameof(ActionButton.actionType), BindingFlags.Instance | BindingFlags.NonPublic);