Skip to content

Commit 8996496

Browse files
committed
Fix the last compatibility issue that I know of
1 parent 477cc7d commit 8996496

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Plugin.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using UnboundLib.Cards;
33
using UnboundLib;
44
using BepInEx.Logging;
5+
using HarmonyLib;
56

67
namespace SelectAnyNumberRounds
78
{
@@ -27,7 +28,8 @@ private void Awake()
2728
});
2829

2930
// Harmony patching: all patches in the same assembly as this class will be applied
30-
HarmonyLib.Harmony harmony = HarmonyLib.Harmony.CreateAndPatchAll(typeof(Plugin).Assembly);
31+
Harmony harmony = new Harmony(PluginInfo.PLUGIN_GUID);
32+
harmony.PatchAll();
3133
}
3234

3335
internal ManualLogSource GetLogger()

patches/LastCardContinue.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@
22
using UnityEngine;
33
using System.Collections.Generic;
44
using Photon.Pun;
5+
using UnboundLib;
6+
57

68
namespace SelectAnyNumberRounds.Patch
79
{
810
[HarmonyPatch(typeof(CardChoice), "SpawnUniqueCard")]
911
public static class LastCardContinue
1012
{
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)
1316
{
1417
// If this is the last card, set the result to the continue card
1518
if (___spawnedCards.Count == ___children.Length - 1) // It's not yet added to the list, so we need to subtract 1
1619
{
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 });
2124
__result.GetComponent<CardInfo>().sourceCard = Cards.ContinueCard.cardInfoInstance;
2225
__result.GetComponentInChildren<DamagableEvent>().GetComponent<Collider2D>().enabled = false;
2326
}

0 commit comments

Comments
 (0)