-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed the camera view locking during the Trapper boss final phase a…
…fter choosing a talking card - Improved fix for the full pack Pack Rat sequence
- Loading branch information
1 parent
ac32a50
commit 20bea46
Showing
8 changed files
with
108 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 17 additions & 72 deletions
89
InscryptionCommunityPatch/Sequencers/PackRatNodeBackgroundFix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,42 @@ | ||
using DiskCardGame; | ||
using HarmonyLib; | ||
using InscryptionAPI.Helpers; | ||
using InscryptionCommunityPatch.Card; | ||
using Pixelplacement; | ||
using System.Collections; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using UnityEngine; | ||
|
||
namespace InscryptionCommunityPatch.Sequencers; | ||
|
||
// 'fixes' the pack rat card not being rare | ||
[HarmonyPatch] | ||
internal class PackRatNodeBackgroundFix | ||
{ | ||
private const string name_RatCard = "DiskCardGame.SelectableCard ratCard"; | ||
private const string name_Reward = "DiskCardGame.CardInfo fullConsumablesReward"; | ||
private const string name_PixelPlacement = "Pixelplacement.TweenSystem.TweenBase Position(UnityEngine.Transform, UnityEngine.Vector3, Single, Single, UnityEngine.AnimationCurve, LoopType, System.Action, System.Action, Boolean)"; | ||
private const string name_GetComponent = "DiskCardGame.SelectableCard GetComponent[SelectableCard]()"; | ||
private static MethodBase TargetMethod() | ||
[HarmonyTranspiler, HarmonyPatch(typeof(GainConsumablesSequencer), nameof(GainConsumablesSequencer.FullConsumablesSequence), MethodType.Enumerator)] | ||
private static IEnumerable<CodeInstruction> FixRareBackground(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
MethodBase baseMethod = AccessTools.Method(typeof(GainConsumablesSequencer), nameof(GainConsumablesSequencer.FullConsumablesSequence)); | ||
return AccessTools.EnumeratorMoveNext(baseMethod); | ||
} | ||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
List<CodeInstruction> codes = new List<CodeInstruction>(instructions); | ||
|
||
object op_RatCard = null; | ||
object op_Reward = null; | ||
|
||
// we want to slowly narrow our search until we find exactly where we want to insert our code | ||
List<CodeInstruction> codes = new(instructions); | ||
|
||
// a part of the code block we want to remove can't be removed without breaking the ienum | ||
// so we cut around it | ||
for (int i = 0; i < codes.Count; i++) | ||
{ | ||
// get the ratCard operand | ||
if (codes[i].opcode == OpCodes.Ldfld && codes[i].operand.ToString() == name_RatCard) | ||
op_RatCard = codes[i].operand; | ||
|
||
if (codes[i].opcode == OpCodes.Ldfld && codes[i].operand.ToString() == name_Reward) | ||
op_Reward = codes[i].operand; | ||
|
||
// look for the original code for `component` | ||
if (codes[i].opcode == OpCodes.Callvirt && codes[i].operand.ToString() == name_GetComponent) | ||
if (codes[i].opcode == OpCodes.Callvirt && codes[i].operand.ToString() == "DiskCardGame.SelectableCard GetComponent[SelectableCard]()") | ||
{ | ||
int startIndex = -1, endIndex = -1; | ||
for (int j = i; j > 0; j--) | ||
int startIndex = i - 3; | ||
for (int j = i + 1; j < codes.Count; j++) | ||
{ | ||
// find the startIndex | ||
if (codes[j].opcode == OpCodes.Ldarg_0) | ||
if (codes[j].opcode == OpCodes.Stloc_2) | ||
{ | ||
startIndex = j; | ||
codes.RemoveRange(startIndex, j - 3 - startIndex); | ||
break; | ||
} | ||
} | ||
|
||
// find the endIndex | ||
for (int k = i; k < codes.Count; k++) | ||
{ | ||
if (codes[k].opcode == OpCodes.Stloc_2) | ||
{ | ||
for (int l = k; l > 0; l--) | ||
{ | ||
if (codes[l].opcode == OpCodes.Callvirt) | ||
{ | ||
endIndex = l + 1; | ||
break; | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
|
||
MethodInfo customMethod = AccessTools.Method(typeof(PackRatNodeBackgroundFix), nameof(PackRatNodeBackgroundFix.InstantiateSelectableCard), new Type[] { typeof(SelectableCard), typeof(CardInfo) }); | ||
|
||
// remove all the old code | ||
codes.RemoveRange(startIndex, endIndex - startIndex); | ||
|
||
// gainConsumablesSequence.ratCard | ||
codes.Insert(startIndex, new CodeInstruction(OpCodes.Ldloc_1)); | ||
codes.Insert(startIndex + 1, new CodeInstruction(OpCodes.Ldfld, op_RatCard)); | ||
|
||
// gainConsumablesSequence.fullConsumablesReward | ||
codes.Insert(startIndex + 2, new CodeInstruction(OpCodes.Ldloc_1)); | ||
codes.Insert(startIndex + 3, new CodeInstruction(OpCodes.Ldfld, op_Reward)); | ||
|
||
// InstantiateSelectableCard | ||
codes.Insert(startIndex + 4, new CodeInstruction(OpCodes.Call, customMethod)); | ||
break; | ||
} | ||
} | ||
|
||
return codes; | ||
} | ||
|
||
public static void InstantiateSelectableCard(SelectableCard card, CardInfo info) | ||
{ | ||
SelectableCard component = UnityObject.Instantiate(card); | ||
component.SetInfo(info); | ||
component.SetInteractionEnabled(false); | ||
UnityObject.Destroy(component); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
InscryptionCommunityPatch/Sequencers/TradeableTalkingCardFix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using DiskCardGame; | ||
using HarmonyLib; | ||
using InscryptionAPI.Card; | ||
using Pixelplacement; | ||
using System.Collections; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using UnityEngine; | ||
|
||
namespace InscryptionCommunityPatch.Sequencers; | ||
|
||
[HarmonyPatch] | ||
internal class TradeableTalkingCardFix | ||
{ | ||
[HarmonyPrefix, HarmonyPatch(typeof(TradeCardsForPelts), nameof(TradeCardsForPelts.OnTradableSelected))] | ||
private static bool OnTalkingCardSelected(TradeCardsForPelts __instance, HighlightedInteractable slot, PlayableCard card) | ||
{ | ||
if (card != null && card.GetComponent<TalkingCard>() == null) | ||
return true; | ||
// the card we selected is a talking card | ||
// talking cards change the view when drawn - this changes it back | ||
// transpiler would probably be better but feh | ||
if (__instance.PeltInHand()) | ||
{ | ||
AscensionStatsData.TryIncrementStat(AscensionStat.Type.PeltsTraded); | ||
PlayableCard pelt = Singleton<PlayerHand>.Instance.CardsInHand.Find((PlayableCard x) => x.Info.HasTrait(Trait.Pelt)); | ||
Singleton<PlayerHand>.Instance.RemoveCardFromHand(pelt); | ||
pelt.SetEnabled(enabled: false); | ||
pelt.Anim.SetTrigger("fly_off"); | ||
Tween.Position(pelt.transform, pelt.transform.position + new Vector3(0f, 3f, 5f), 0.4f, 0f, Tween.EaseInOut, Tween.LoopType.None, null, delegate | ||
{ | ||
UnityObject.Destroy(pelt.gameObject); | ||
}); | ||
card.UnassignFromSlot(); | ||
Tween.Position(card.transform, card.transform.position + new Vector3(0f, 0.25f, -5f), 0.3f, 0f, Tween.EaseInOut, Tween.LoopType.None, null, delegate | ||
{ | ||
UnityObject.Destroy(card.gameObject); | ||
}); | ||
__instance.StartCoroutine(TradeForTalkingCard(card)); | ||
slot.ClearDelegates(); | ||
slot.HighlightCursorType = CursorType.Default; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public static IEnumerator TradeForTalkingCard(PlayableCard card) | ||
{ | ||
yield return Singleton<PlayerHand>.Instance.AddCardToHand(CardSpawner.SpawnPlayableCard(card.Info), new Vector3(0f, 0.5f, -3f), 0f); | ||
ViewManager.Instance.SwitchToView(View.OpponentQueue); | ||
ViewManager.Instance.Controller.SwitchToControlMode(ViewController.ControlMode.TraderCardsForPeltsPhase); | ||
} | ||
} |