|
2 | 2 | using UnityEngine;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using Photon.Pun;
|
| 5 | +using UnboundLib; |
| 6 | + |
5 | 7 |
|
6 | 8 | namespace SelectAnyNumberRounds.Patch
|
7 | 9 | {
|
8 | 10 | [HarmonyPatch(typeof(CardChoice), "SpawnUniqueCard")]
|
9 | 11 | public static class LastCardContinue
|
10 | 12 | {
|
11 |
| - [HarmonyPriority(Priority.Last)] // Run this patch first, as the contune card MUST NOT be overwritten |
12 |
| - public static void Postfix(ref CardChoice __instance, ref GameObject __result, ref List<GameObject> ___spawnedCards, ref Transform[] ___children) |
| 13 | + [HarmonyPriority(Priority.Last)] // Run this patch last, as the contune card MUST NOT be overwritten |
| 14 | + [HarmonyAfter(new string[] { "com.Root.Null" })] // Run this patch after these other Priority.Last patches |
| 15 | + public static void Postfix(ref CardChoice __instance, ref GameObject __result, ref List<GameObject> ___spawnedCards, ref Transform[] ___children, ref int ___pickrID, Vector3 pos, Quaternion rot) |
13 | 16 | {
|
14 | 17 | // If this is the last card, set the result to the continue card
|
15 | 18 | if (___spawnedCards.Count == ___children.Length - 1) // It's not yet added to the list, so we need to subtract 1
|
16 | 19 | {
|
17 |
| - var pos = __result.transform.position; |
18 |
| - var rot = __result.transform.rotation; |
19 |
| - Object.Destroy(__result); |
20 |
| - __result = PhotonNetwork.Instantiate("__SAN__Continue", pos, rot, 0, null); |
| 20 | + GameObject old = __result; |
| 21 | + Plugin.instance.ExecuteAfterFrames(3, () => PhotonNetwork.Destroy(old)); |
| 22 | + // Spawn the continue card |
| 23 | + __result = PhotonNetwork.Instantiate("__SAN__Continue", __result.transform.position, __result.transform.rotation, 0, new object[] { __result.transform.localScale, __result.GetComponent<CardInfo>().sourceCard.name, ___pickrID }); |
21 | 24 | __result.GetComponent<CardInfo>().sourceCard = Cards.ContinueCard.cardInfoInstance;
|
22 | 25 | __result.GetComponentInChildren<DamagableEvent>().GetComponent<Collider2D>().enabled = false;
|
23 | 26 | }
|
|
0 commit comments