-
Notifications
You must be signed in to change notification settings - Fork 0
/
IGCC.cs
547 lines (503 loc) · 23.4 KB
/
IGCC.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
using BepInEx;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using IGCCMod.Util;
using Pixelplacement;
using System.Collections;
using System.Reflection;
using UnityEngine;
using static CardSelectSequencers;
using Random = UnityEngine.Random;
namespace IGCCMod;
[BepInPlugin(PluginGuid, PluginName, PluginVersion)]
[BepInDependency("cyantist.inscryption.api")]
[BepInDependency("MADH.inscryption.JSONLoader")]
public class IGCC : BaseUnityPlugin
{
private const string PluginGuid = "IngoH.inscryption.IGCCMod";
private const string PluginName = "IGCCMod";
private const string PluginVersion = "2.5.2";
internal static ManualLogSource Log;
private void Awake()
{
this.Logger.LogInfo($"Loaded {PluginName}!");
Log = this.Logger;
Harmony harmony = new(PluginGuid);
harmony.PatchAll();
}
public static void LookDown()
{
bool skipMove = false;
if (Singleton<ViewManager>.Instance.CurrentView == View.SanctumFloorDown)
{
skipMove = true;
}
Singleton<ViewManager>.Instance.SwitchToView(View.SanctumFloorDown, false, true);
Tween.LocalRotation(Singleton<ViewManager>.Instance.CameraParent, new Vector3(90, 0, 0), 0.25f, 0f,
Tween.EaseInOut);
if (!skipMove)
{
Vector3 pos = Singleton<ViewManager>.Instance.CameraParent.localPosition;
Tween.LocalPosition(Singleton<ViewManager>.Instance.CameraParent,
new Vector3(pos.x, pos.y + 3.25f, pos.z + 4.25f), 0.25f, 0f, Tween.EaseInOut);
}
}
public static void LookUp()
{
Singleton<RuleBookController>.Instance.SetShown(false);
Singleton<ViewManager>.Instance.SwitchToView(View.SanctumFloorUp, false, true);
}
private static void ZoomIn()
{
Vector3 pos = Singleton<ViewManager>.Instance.CameraParent.localPosition;
Tween.LocalPosition(Singleton<ViewManager>.Instance.CameraParent, new Vector3(pos.x, pos.y - 3.0f, pos.z),
0.25f, 0f, Tween.EaseInOut);
}
private static void MoveDown()
{
Vector3 pos = Singleton<ViewManager>.Instance.CameraParent.localPosition;
Tween.LocalPosition(Singleton<ViewManager>.Instance.CameraParent, new Vector3(pos.x, pos.y, pos.z - 1.25f),
0.25f, 0f, Tween.EaseInOut);
}
private static void ResetCamera()
{
Vector3 pos = Singleton<ViewManager>.Instance.CameraParent.localPosition;
Tween.LocalPosition(Singleton<ViewManager>.Instance.CameraParent,
new Vector3(pos.x, pos.y + 3.0f, pos.z + 1.25f), 0.25f, 0f, Tween.EaseInOut);
}
[HarmonyPatch(typeof(DoorKnobInteractable), "OnCursorSelectStart")]
public class DoorPatch : DoorKnobInteractable
{
public static bool Prefix(DoorKnobInteractable __instance)
{
// Set cause of death to PixelP03FinaleBoss, as it clearly is unused for part 1 (and highly unlikely to be used by a mod)
SaveManager.SaveFile.currentRun.causeOfDeath = new RunState.CauseOfDeath(Opponent.Type.PixelP03FinaleBoss);
SaveManager.SaveToFile(false);
// Load when door is clicked
SceneLoader.Load("Part1_Sanctum");
return true;
}
}
[HarmonyPatch(typeof(SanctumSceneSequencer), "IntroSequence")]
public class SanctumIntroPatch : SanctumSceneSequencer
{
public static bool Prefix(SanctumSceneSequencer __instance)
{
// Cancel orignal method
return false;
//if (SaveManager.SaveFile.currentRun.causeOfDeath.opponentType == Opponent.Type.PixelP03FinaleBoss) return false;
//else return true;
}
}
[HarmonyPatch(typeof(SanctumSceneSequencer), "IntroSequence")]
public class PostSanctumIntroPatch : SanctumSceneSequencer
{
public static IEnumerator Postfix(IEnumerator __result, SanctumSceneSequencer __instance)
{
//if (SaveManager.SaveFile.currentRun.causeOfDeath.opponentType == Opponent.Type.PixelP03FinaleBoss)
//{
// Abbreviated version of original method.
__instance.GetType().GetMethod("StartHumLoop", BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(__instance, null);
__instance.GetType().GetMethod("InitializeLeshy", BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(__instance, null);
Singleton<ViewManager>.Instance.SwitchToView(View.SanctumFloorDown, true, true);
yield return new WaitForSeconds(0.5f);
LookUp();
Singleton<InteractionCursor>.Instance.SetHidden(false);
yield return new WaitForSeconds(0.5f);
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(
"You entered the [c:bR]card creation[c:] mode.");
yield return __instance.GetType()
.GetMethod("DeathCardSequence", BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(__instance, null);
//}
}
}
// Rulebook camera cancel
[HarmonyPatch(typeof(ViewManager), "OffsetPosition", typeof(Vector3), typeof(float))]
public class RuleBookCameraPatch : ViewManager
{
public static bool Prefix(ViewManager __instance, Vector3 cameraOffset)
{
if (Instance.CurrentView == View.SanctumFloorDown)
{
Vector3 pos = Instance.CameraParent.localPosition;
if (cameraOffset.z >= 0)
{
Tween.LocalRotation(Instance.CameraParent, new Vector3(90, 0, 0), 0.25f, 0f, Tween.EaseInOut);
}
else
{
Tween.LocalRotation(Instance.CameraParent, new Vector3(105, 0, 0), 0.25f, 0f, Tween.EaseInOut);
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(SanctumSceneSequencer), "DeathCardSequence", null)]
public class DeathCardStartPatch : SanctumSceneSequencer
{
public static bool Prefix(SanctumSceneSequencer __instance)
{
// Cancel orignal method
return false;
//if (SaveManager.SaveFile.currentRun.causeOfDeath.opponentType == Opponent.Type.PixelP03FinaleBoss) return false;
//else return true;
}
}
[HarmonyPatch(typeof(SanctumSceneSequencer), "DeathCardSequence", null)]
public class PostDeathCardStartPatch : SanctumSceneSequencer
{
public static IEnumerator Postfix(IEnumerator __result, SanctumSceneSequencer __instance,
DeathCardCreationSequencer ___deathCardSequencer)
{
//if (SaveManager.SaveFile.currentRun.causeOfDeath.opponentType == Opponent.Type.PixelP03FinaleBoss)
//{
yield return new WaitForSeconds(0.25f);
yield return ___deathCardSequencer.CreateCardSequence(true);
//}
}
}
[HarmonyPatch(typeof(DeathCardCreationSequencer), "CreateCardSequence", typeof(bool))]
public class DeathCardPatch : DeathCardCreationSequencer
{
public static bool Prefix(DeathCardCreationSequencer __instance)
{
// Cancel orignal method
return false;
//if (SaveManager.SaveFile.currentRun.causeOfDeath.opponentType == Opponent.Type.PixelP03FinaleBoss) return false;
//else return true;
}
}
[HarmonyPatch(typeof(DeathCardCreationSequencer), "CreateCardSequence", typeof(bool))]
public class PostDeathCardPatch : DeathCardCreationSequencer
{
public static IEnumerator Postfix(IEnumerator __result, DeathCardCreationSequencer __instance,
KeyboardInputHandler ___keyboardInput)
{
//if (SaveManager.SaveFile.currentRun.causeOfDeath.opponentType == Opponent.Type.PixelP03FinaleBoss)
//{
bool done = false;
if (SaveManager.SaveFile.currentRun.causeOfDeath.opponentType != Opponent.Type.PixelP03FinaleBoss)
{
LookUp();
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("It appears that you lost normally.");
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(
"Only worthy challengers may access the Card Creator.");
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(
"Try again, but this time open the backroom door normally.");
yield return Singleton<TextDisplayer>.Instance.ShowMessage("Goodbye.");
yield return new WaitForSeconds(0.5f);
LeshyAnimationController.Instance.LeftArm.PlayAnimation("takephoto_left");
yield return new WaitForSeconds(1.5f);
if (Random.value > 0.8f)
{
Singleton<VideoCameraRig>.Instance.PlayCameraAnim("refocus_medium");
}
LeshyAnimationController.Instance.LeftArm.SetTrigger("photo_flare");
yield return new WaitForSeconds(1f);
Singleton<TextDisplayer>.Instance.Clear();
AudioSource audioSource2 =
AudioController.Instance.PlaySound2D("camera_flash_gameover", MixerGroup.None, 0.85f);
audioSource2.gameObject.name = "flashSound";
DontDestroyOnLoad(audioSource2.gameObject);
AudioController.Instance.StopAllLoops();
Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>()
.SetColor(GameColors.Instance.nearWhite);
Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>().SetIntensity(1f, 100f);
SaveManager.SaveFile.NewPart1Run();
yield return new WaitForSeconds(1f);
AsyncOperation asyncOp2 = SceneLoader.StartAsyncLoad("Part1_Cabin");
SceneLoader.CompleteAsyncLoad(asyncOp2);
SaveManager.SaveToFile(false);
}
else
{
while (!done)
{
// Create preview card
Transform obj = ((List<Transform>)__instance.GetType()
.GetField("cardPositionMarkers", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(__instance))[0];
Vector3 vector = GetCardIndexLoc(obj, 17);
CardInfo c = ScriptableObject.CreateInstance<CardInfo>();
CardModificationInfo addTo = new() { nameReplacement = "current card" };
c.Mods.Add(addTo);
SelectableCard preview = CreatePreviewCard(__instance, vector, c);
List<int> prevSelects = new();
int i = 1;
int j = 0;
while (i != -1)
{
yield return CardCreationStep(i, prevSelects, __instance, preview);
if (j < 7)
{
i++;
j++;
if (i == 2)
{
i++;
}
}
else
{
IntRef ir = new();
yield return StepSelect(__instance, ir);
i = ir.Value;
}
}
// Move to center
Vector3 vector2 = GetCardIndexLoc(obj, 7);
Tween.Position(preview.transform, vector2, 0.25f, 0f);
// Enter name
___keyboardInput.maxInputLength = 127;
yield return new WaitForSeconds(0.25f);
ZoomIn();
Singleton<TextDisplayer>.Instance.ShowMessage("You should give it a name.");
CardModificationInfo nameMod = new();
preview.Info.Mods.Add(nameMod);
yield return __instance.GetType()
.GetMethod("EnterNameForCard", BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(__instance, new object[] { preview, nameMod });
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("[c:bR]" +
nameMod.nameReplacement.Trim() + "[c:]?");
yield return new WaitForSeconds(0.25f);
// Enter description
___keyboardInput.maxInputLength = 1027;
Singleton<TextDisplayer>.Instance.ShowMessage("Please type the description.");
yield return EnterDescription(___keyboardInput, preview);
yield return new WaitForSeconds(0.25f);
MoveDown();
yield return FinalizeCard(__instance, preview);
// Finalize
if (preview == null)
{
// End
done = true;
}
else
{
// Restart
preview.Anim.PlayDeathAnimation();
Destroy(preview.gameObject, 2f);
yield return new WaitForSeconds(0.25f);
}
ResetCamera();
}
// Take photo and return to table
yield return new WaitForSeconds(0.5f);
yield return Singleton<TextDisplayer>.Instance.ShowMessage("It is time for you to return.");
LookUp();
yield return new WaitForSeconds(0.5f);
LeshyAnimationController.Instance.LeftArm.PlayAnimation("takephoto_left");
yield return new WaitForSeconds(1.5f);
if (Random.value > 0.8f)
{
Singleton<VideoCameraRig>.Instance.PlayCameraAnim("refocus_medium");
}
LeshyAnimationController.Instance.LeftArm.SetTrigger("photo_flare");
yield return new WaitForSeconds(1f);
Singleton<TextDisplayer>.Instance.Clear();
AudioSource audioSource =
AudioController.Instance.PlaySound2D("camera_flash_gameover", MixerGroup.None, 0.85f);
audioSource.gameObject.name = "flashSound";
DontDestroyOnLoad(audioSource.gameObject);
AudioController.Instance.StopAllLoops();
Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>()
.SetColor(GameColors.Instance.nearWhite);
Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>().SetIntensity(1f, 100f);
yield return new WaitForSeconds(1f);
AsyncOperation asyncOp = SceneLoader.StartAsyncLoad("Part1_Cabin");
SceneLoader.CompleteAsyncLoad(asyncOp);
SaveManager.SaveToFile(false);
}
//}
}
private static IEnumerator StepSelect(DeathCardCreationSequencer __instance, IntRef i)
{
yield return CreateStepCard(__instance, i);
}
private static IEnumerator CardCreationStep(int i, List<int> prevSelects, DeathCardCreationSequencer __instance,
SelectableCard preview)
{
CardInfo inf = preview.Info;
switch (i)
{
case 1:
// Cost
yield return CreateCostCard(__instance, preview);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 2:
// Extra Cost
yield return CreateCostCardAdditive(__instance, preview);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 3:
// Attack
yield return CreateAttackCard(__instance, preview);
preview.RenderInfo.hiddenAttack = false;
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 4:
// Health
yield return CreateHealthCard(__instance, preview);
preview.RenderInfo.hiddenHealth = false;
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 5:
// Sigils
if (prevSelects.Contains(5))
{
inf.abilities = new List<Ability>();
inf.evolveParams = null;
inf.iceCubeParams = null;
}
yield return CreateSigilCard(__instance, preview);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
if (preview.Info.Abilities.Contains(Ability.Evolve) ||
preview.Info.Abilities.Contains(Ability.Transformer))
{
// Evolution
yield return CreateEvolution(__instance, preview, 0);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
if (preview.Info.evolveParams != null)
{
yield return CreateEvolutionTurnCount(__instance, preview);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
}
}
if (preview.Info.Abilities.Contains(Ability.IceCube))
{
// Ice cube
yield return CreateEvolution(__instance, preview, 1);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
}
break;
case 6:
// Tribe
if (prevSelects.Contains(6))
{
inf.tribes = new List<Tribe>();
}
yield return CreateTribeCard(__instance, preview);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 7:
// Special Abilities
yield return CreateSpecialAbilities(__instance, preview);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 8:
List<Texture2D> textures = PortraitLoader.Instance.GetPortraits();
// Portrait
yield return CreatePortrait(__instance, preview, textures, 0);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 9:
// Rarity
if (prevSelects.Contains(9))
{
inf.appearanceBehaviour = new List<CardAppearanceBehaviour.Appearance>();
inf.metaCategories = new List<CardMetaCategory>();
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
preview.UpdateAppearanceBehaviours();
yield return new WaitForSeconds(0.25f);
}
yield return CreateRarity(__instance, preview);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 10:
// Complexity
yield return CreateComplexity(__instance, preview);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
default:
yield return new WaitForSeconds(0.25f);
break;
case 11:
List<Texture2D> textures2 = PortraitLoader.Instance.GetPortraits();
// Portrait
yield return CreatePortrait(__instance, preview, textures2, 1);
preview.Anim.PlayTransformAnimation();
yield return new WaitForSeconds(0.15f);
preview.SetInfo(preview.Info);
yield return new WaitForSeconds(0.25f);
break;
case 12:
// DECALS
break;
}
if (!prevSelects.Contains(i))
{
prevSelects.Add(i);
}
}
private static IEnumerator EnterDescription(KeyboardInputHandler ___keyboardInput, SelectableCard preview)
{
___keyboardInput.Reset();
while (!___keyboardInput.EnteredInput)
{
string text = ___keyboardInput.KeyboardInput;
if (text != "")
{
yield return Singleton<TextDisplayer>.Instance.ShowMessage(text);
}
else
{
yield return Singleton<TextDisplayer>.Instance.ShowMessage("Please type the description.");
}
yield return new WaitForEndOfFrame();
preview.Info.description = text;
}
}
}
}
public class IntRef
{
public int Value;
}