using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DiskCardGame;
using GBC;
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.Helpers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("MultiplayerMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows for local hotseat Act 2 multiplayer")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("MultiplayerMod")]
[assembly: AssemblyTitle("MultiplayerMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MultiplayerMod
{
[BepInPlugin("tvflabs.inscryption.MultiplayerMod", "MultiplayerMod", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(VideoCameraRig), "ExitChapterSelect")]
private class VideoCameraRig_ExitChapterSelect_Patch
{
private static bool Prefix(VideoCameraRig __instance)
{
AudioController.Instance.PlaySound2D("videocam_jumpback", (MixerGroup)11, 0.5f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
Application.Quit();
return false;
}
}
[HarmonyPatch(typeof(ChapterSelectMenu), "Start")]
private class ChapterSelectMenu_Start_Patch
{
private static void Postfix()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
GameObject.Find("Clips_Row").SetActive(false);
int num = 0;
foreach (Transform item in GameObject.Find("Chapter_Row").transform)
{
Transform val = item;
if (num != 2)
{
((Component)val).gameObject.SetActive(false);
}
num++;
}
}
}
[HarmonyPatch(typeof(StartScreenController), "Start")]
private class StartScreenController_Start_Patch
{
private static bool Prefix(StartScreenController __instance)
{
Application.runInBackground = GameOptions.Options.runInBackground;
AudioController.Instance.StopAllLoops();
Singleton<InteractionCursor>.Instance.SetHidden(true);
Singleton<InteractionCursor>.Instance.SetEnabled(false);
Cursor.visible = true;
((Component)__instance.menu).gameObject.SetActive(false);
((Component)__instance.backgroundAnim).gameObject.SetActive(false);
Singleton<VideoCameraRig>.Instance.EnterChapterSelect();
return false;
}
}
[HarmonyPatch(typeof(DeckBuildingUI), "Initialize")]
private class DeckbuildingUI_Initialize_Patch
{
private static void Prefix(DeckBuildingUI __instance)
{
if (editingPlayer2Deck)
{
SaveData.Data.deck = player2Deck;
SaveData.Data.collection = player2Collection;
{
foreach (CardInfo card in player2Collection.Cards)
{
SaveData.Data.cardsViewedInCollection.Add(((Object)card).name);
}
return;
}
}
SaveData.Data.deck = player1Deck;
SaveData.Data.collection = player1Collection;
foreach (CardInfo card2 in player1Collection.Cards)
{
SaveData.Data.cardsViewedInCollection.Add(((Object)card2).name);
}
}
}
[HarmonyPatch(typeof(PlayableCard), "Die")]
private class PlayableCard_Die_Patch
{
private static IEnumerator Postfix(IEnumerator values, PlayableCard __instance)
{
if (!__instance.HasAbility((Ability)12) && !__instance.Slot.IsPlayerSlot && !__instance.Dead)
{
if (player2Turn)
{
player1Bones++;
}
else
{
player2Bones++;
}
}
yield return values;
}
}
[HarmonyPatch(typeof(MenuController), "LoadGameFromMenu")]
private class MenuController_LoadGameFromMenu_Patch
{
private static void Postfix(bool newGameGBC, MenuController __instance)
{
if (newGameGBC)
{
LoadingScreenManager.LoadScene("gbc_starting_island");
}
}
}
[HarmonyPatch(typeof(PickupCardPileVolume), "ShowSingleTextLine")]
private class PickupCardPileVolume_ShowSingleTextLine_Patch
{
private static IEnumerator Postfix(IEnumerator values, PickupCardPileVolume __instance)
{
if ((int)__instance.starterDeckType == 0)
{
editingPlayer2Deck = false;
}
else if ((int)__instance.starterDeckType == 2)
{
editingPlayer2Deck = true;
}
comingFromDeckEdit = true;
((PauseMenu)GameObject.Find("PauseMenu").GetComponent<GBCPauseMenu>()).SetPaused(true);
yield break;
}
}
[HarmonyPatch(typeof(GBCPauseMenu), "OnPausedChange")]
private class GBCPauseMenu_OnPausedChange_Patch
{
private static void Postfix(bool paused, GBCPauseMenu __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Invalid comparison between Unknown and I4
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Invalid comparison between Unknown and I4
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Invalid comparison between Unknown and I4
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Invalid comparison between Unknown and I4
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Invalid comparison between Unknown and I4
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Invalid comparison between Unknown and I4
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Invalid comparison between Unknown and I4
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Invalid comparison between Unknown and I4
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Invalid comparison between Unknown and I4
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Invalid comparison between Unknown and I4
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name.ToLower() == "gbc_starting_island"))
{
return;
}
if (dealtWithFirstPause)
{
if (paused && comingFromDeckEdit && SaveManager.SaveFile.IsPart2)
{
((Component)__instance.modifyDeckCard).gameObject.SetActive(true);
((PauseMenu)__instance).menuController.PlayMenuCardImmediate(__instance.modifyDeckCard);
comingFromDeckEdit = false;
editingDeck = true;
}
else if (paused && !comingFromDeckEdit && SaveManager.SaveFile.IsPart2)
{
((Component)__instance.modifyDeckCard).gameObject.SetActive(false);
}
else if (!paused && editingDeck && SaveManager.SaveFile.IsPart2)
{
editingDeck = false;
if (editingPlayer2Deck)
{
player2Deck = SaveData.Data.deck;
}
else
{
player1Deck = SaveData.Data.deck;
}
CardTemple dominantTemple = GetDominantTemple(((CardCollectionInfo)player1Deck).Cards);
CardTemple dominantTemple2 = GetDominantTemple(((CardCollectionInfo)player2Deck).Cards);
if ((int)dominantTemple == 4)
{
player1Style = (Style)4;
}
else if ((int)dominantTemple == 0)
{
player1Style = (Style)0;
}
else if ((int)dominantTemple == 1)
{
player1Style = (Style)1;
}
else if ((int)dominantTemple == 2)
{
player1Style = (Style)2;
}
else if ((int)dominantTemple == 3)
{
player1Style = (Style)3;
}
if ((int)dominantTemple2 == 4)
{
player2Style = (Style)4;
}
else if ((int)dominantTemple2 == 0)
{
player2Style = (Style)0;
}
else if ((int)dominantTemple2 == 1)
{
player2Style = (Style)1;
}
else if ((int)dominantTemple2 == 2)
{
player2Style = (Style)2;
}
else if ((int)dominantTemple2 == 3)
{
player2Style = (Style)3;
}
if (((CardCollectionInfo)player1Deck).Cards.Count >= 20 && ((CardCollectionInfo)player2Deck).Cards.Count >= 20)
{
((MonoBehaviour)plugin).StartCoroutine(StartBattleConfirm());
}
}
}
else
{
dealtWithFirstPause = true;
}
}
}
[HarmonyPatch(typeof(StartingIslandIntroSequencer), "IntroSequence")]
private class StartingIslandIntroSequencer_IntroSequence_Patch
{
private static IEnumerator Postfix(IEnumerator values, StartingIslandIntroSequencer __instance)
{
GameObject.Find("Tablet_Undead").SetActive(false);
GameObject.Find("Tablet_Magic").SetActive(false);
SaveManager.SaveToFile(true);
PauseMenu.pausingDisabled = true;
Singleton<InteractionCursor>.Instance.SetHidden(true);
Singleton<CameraEffects>.Instance.SetFadeSpeed(0.35f);
PauseMenu.SetGamePaused(false);
SaveData data = SaveData.Data;
Vector3 val = (((Component)Singleton<PlayerMovementController>.Instance).transform.position = __instance.startPositionMarker.position);
data.overworldIndoorPosition = Vector2.op_Implicit(val);
yield return (object)new WaitForEndOfFrame();
Singleton<PlayerMovementController>.Instance.SetEnabled(false);
((Component)Singleton<PlayerMovementController>.Instance).gameObject.SetActive(false);
yield return (object)new WaitForSeconds(1f);
((Component)Singleton<PlayerMovementController>.Instance).gameObject.SetActive(true);
ProgressionData.SetMechanicLearned((MechanicsConcept)61);
yield return Singleton<PlayerMovementController>.Instance.Anim.DropAnimation(0.1f);
__instance.startingDeckPiles.ForEach(delegate(PickupCardPileVolume x)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
if ((int)x.starterDeckType == 0 || (int)x.starterDeckType == 2)
{
((Component)x).gameObject.SetActive(true);
}
});
AudioController.Instance.SetLoopAndPlay("gbc_starting_island", 0, true, true);
AudioController.Instance.SetLoopVolumeImmediate(0.8f, 0);
MenuController.PlayMenuCrunchSound(true);
__instance.blockingTextBox.SetActive(true);
PixelText[] componentsInChildren = __instance.blockingTextBox.GetComponentsInChildren<PixelText>();
foreach (PixelText pixelText in componentsInChildren)
{
if (comingFromCompletedBattle)
{
pixelText.SetText("Player 1 wins: " + player1Wins + "\nPlayer 2 wins: " + player2Wins, false);
}
else
{
pixelText.SetText(" EDIT YOUR DECKS, THEN BATTLE!", false);
}
}
Singleton<PlayerMovementController>.Instance.SetEnabled(true);
Singleton<InteractionCursor>.Instance.SetHidden(false);
PauseMenu.pausingDisabled = false;
Singleton<CameraEffects>.Instance.SetFadeSpeed(1f);
yield return (object)new WaitUntil((Func<bool>)(() => __instance.startingDeckPiles.Exists((PickupCardPileVolume x) => x.CardsPickedUp)));
Singleton<PlayerMovementController>.Instance.SetEnabled(false);
yield return (object)new WaitForSeconds(0.1f);
__instance.startingDeckPiles.ForEach(delegate(PickupCardPileVolume x)
{
x.Hide();
});
yield return (object)new WaitForSeconds(1f);
__instance.blockingTextBox.SetActive(false);
Singleton<PlayerMovementController>.Instance.SetEnabled(true);
}
}
[HarmonyPatch(typeof(PixelCombatPhaseManager), "VisualizeExcessLethalDamage")]
private class PixelCombatPhaseManager_VisualizeExcessLethalDamage_Patch
{
private static IEnumerator Postfix(IEnumerator values, int excessDamage, SpecialBattleSequencer specialSequencer, PixelCombatPhaseManager __instance)
{
yield break;
}
}
[HarmonyPatch(typeof(TurnManager), "LifeLossConditionsMet")]
private class TurnManager_LifeLossConditionsMet_Patch
{
private static void Postfix(TurnManager __instance, ref bool __result)
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
if (!__result)
{
return;
}
comingFromCompletedBattle = true;
if (__instance.ScalesTippedToOpponent())
{
if (player2Turn)
{
player2Won = true;
}
else
{
player2Won = false;
}
}
else if (__instance.PlayerSurrendered)
{
if (player2Turn)
{
player2Won = false;
}
else
{
player2Won = true;
}
}
if (decksSwapped)
{
player2Won = !player2Won;
}
if (player2Won)
{
player2Wins++;
}
else
{
player1Wins++;
}
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name.ToLower() == "gbc_cardbattle")
{
SceneManager.LoadScene("gbc_starting_island");
}
}
}
[HarmonyPatch(typeof(TurnManager), "PlayerTurn")]
private class TurnManager_PlayerTurn_Patch
{
private static IEnumerator Postfix(IEnumerator values, TurnManager __instance)
{
if (player2Turn)
{
if (decksSwapped)
{
yield return Singleton<TextBox>.Instance.ShowUntilInput("Player 1's turn", player1Style, (DialogueSpeaker)null, (ScreenPosition)2, 0f, true, false, (Prompt)null, true, (Emotion)0);
}
else
{
yield return Singleton<TextBox>.Instance.ShowUntilInput("Player 2's turn", player2Style, (DialogueSpeaker)null, (ScreenPosition)2, 0f, true, false, (Prompt)null, true, (Emotion)0);
}
}
else if (decksSwapped)
{
yield return Singleton<TextBox>.Instance.ShowUntilInput("Player 2's turn", player2Style, (DialogueSpeaker)null, (ScreenPosition)2, 0f, true, false, (Prompt)null, true, (Emotion)0);
}
else
{
yield return Singleton<TextBox>.Instance.ShowUntilInput("Player 1's turn", player1Style, (DialogueSpeaker)null, (ScreenPosition)2, 0f, true, false, (Prompt)null, true, (Emotion)0);
}
while (values.MoveNext())
{
yield return values.Current;
}
player2Turn = !player2Turn;
yield return SwitchToPlayer(player2Turn);
turnNum++;
if (turnNum >= 2)
{
yield break;
}
List<CardInfo> hand = Singleton<CardDrawPiles>.Instance.Deck.GetFairHand(4, true, (List<CardInfo>)null);
for (int i = 0; i < 4; i++)
{
if (i < hand.Count)
{
yield return Singleton<CardDrawPiles>.Instance.DrawCardFromDeck(hand[i], (Action<PlayableCard>)null);
}
else
{
yield return Singleton<CardDrawPiles>.Instance.DrawCardFromDeck((CardInfo)null, (Action<PlayableCard>)null);
}
}
}
}
[HarmonyPatch(typeof(TurnManager), "OpponentTurn")]
private class TurnManager_OpponentTurn_Patch
{
private static IEnumerator Postfix(IEnumerator values, TurnManager __instance)
{
yield break;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private class SaveFile_RiggedDraws_Get_Patch
{
private static bool Prefix(ref List<string> __result, SaveFile __instance)
{
__result = new List<string>();
return false;
}
}
[HarmonyPatch(typeof(ActivatedAbilityBehaviour), "OnActivatedAbility")]
private class ActivatedAbilityBehaviour_OnActivatedAbility_Patch
{
private static IEnumerator Postfix(IEnumerator values, ActivatedAbilityBehaviour __instance)
{
if (!((Object)(object)((AbilityBehaviour)__instance).Card != (Object)null) || !((AbilityBehaviour)__instance).Card.OpponentCard)
{
while (values.MoveNext())
{
yield return values.Current;
}
}
}
}
[HarmonyPatch(typeof(BrokenCoin), "RespondsToOtherCardAssignedToSlot")]
private class BrokenCoin_RespondsToOtherCardAssignedToSlot_Patch
{
private static void Postfix(PlayableCard otherCard, ActivatedAbilityBehaviour __instance, ref bool __result)
{
__result = false;
}
}
[HarmonyPatch(typeof(DrawCopyOnDeath), "OnDie")]
private class DrawCopyOnDeath_OnDie_Patch
{
private static IEnumerator Postfix(IEnumerator values, bool wasSacrifice, PlayableCard killer, DrawCopyOnDeath __instance)
{
if (((AbilityBehaviour)__instance).Card.OpponentCard)
{
yield return ((AbilityBehaviour)__instance).PreSuccessfulTriggerSequence();
if (player2Turn)
{
PlayableCard copy2 = CardSpawner.SpawnPlayableCard(((Card)((AbilityBehaviour)__instance).Card).Info);
((Component)copy2).gameObject.SetActive(false);
player1CardsInHand.Add(copy2);
}
else
{
PlayableCard copy = CardSpawner.SpawnPlayableCard(((Card)((AbilityBehaviour)__instance).Card).Info);
((Component)copy).gameObject.SetActive(false);
player2CardsInHand.Add(copy);
}
yield return ((AbilityBehaviour)__instance).LearnAbility(0.5f);
}
else
{
while (values.MoveNext())
{
yield return values.Current;
}
}
}
}
[HarmonyPatch(typeof(CardsInHand), "GetStatValues")]
private class CardsInHand_GetStatValues_Patch
{
private static void Postfix(CardsInHand __instance, ref int[] __result)
{
if (((SpecialCardBehaviour)__instance).PlayableCard.OpponentCard)
{
if (player2Turn)
{
__result[0] = player1CardsInHand.Count;
}
else
{
__result[0] = player2CardsInHand.Count;
}
}
}
}
[HarmonyPatch(typeof(QuadrupleBones), "OnDie")]
private class QuadrupleBones_OnDie_Patch
{
private static IEnumerator Postfix(IEnumerator values, bool wasSacrifice, PlayableCard killer, QuadrupleBones __instance)
{
if (((AbilityBehaviour)__instance).Card.OpponentCard)
{
yield return ((AbilityBehaviour)__instance).PreSuccessfulTriggerSequence();
if (player2Turn)
{
player1Bones += 4;
}
else
{
player2Bones += 4;
}
yield return ((AbilityBehaviour)__instance).LearnAbility(0f);
yield return (object)new WaitForSeconds(0.25f);
Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
}
else
{
while (values.MoveNext())
{
yield return values.Current;
}
}
}
}
[HarmonyPatch(typeof(DrawRabbits), "OnResolveOnBoard")]
private class DrawRabbits_OnResolveOnBoard_Patch
{
private static IEnumerator Postfix(IEnumerator values, DrawRabbits __instance)
{
if (((AbilityBehaviour)__instance).Card.OpponentCard)
{
yield return ((AbilityBehaviour)__instance).PreSuccessfulTriggerSequence();
if (player2Turn)
{
PlayableCard copy2 = CardSpawner.SpawnPlayableCard(((DrawCreatedCard)__instance).CardToDraw);
((Component)copy2).gameObject.SetActive(false);
player1CardsInHand.Add(copy2);
}
else
{
PlayableCard copy = CardSpawner.SpawnPlayableCard(((DrawCreatedCard)__instance).CardToDraw);
((Component)copy).gameObject.SetActive(false);
player2CardsInHand.Add(copy);
}
yield return ((AbilityBehaviour)__instance).LearnAbility(0.5f);
}
else
{
while (values.MoveNext())
{
yield return values.Current;
}
}
}
}
[HarmonyPatch(typeof(DrawCopy), "OnResolveOnBoard")]
private class DrawCopy_OnResolveOnBoard_Patch
{
private static IEnumerator Postfix(IEnumerator values, DrawRabbits __instance)
{
if (((AbilityBehaviour)__instance).Card.OpponentCard)
{
yield return ((AbilityBehaviour)__instance).PreSuccessfulTriggerSequence();
if (player2Turn)
{
PlayableCard copy2 = CardSpawner.SpawnPlayableCard(((DrawCreatedCard)__instance).CardToDraw);
foreach (CardModificationInfo tempMod2 in ((DrawCreatedCard)__instance).CardToDrawTempMods)
{
copy2.AddTemporaryMod(tempMod2);
}
((Component)copy2).gameObject.SetActive(false);
player1CardsInHand.Add(copy2);
}
else
{
PlayableCard copy = CardSpawner.SpawnPlayableCard(((DrawCreatedCard)__instance).CardToDraw);
foreach (CardModificationInfo tempMod in ((DrawCreatedCard)__instance).CardToDrawTempMods)
{
copy.AddTemporaryMod(tempMod);
}
((Component)copy).gameObject.SetActive(false);
player2CardsInHand.Add(copy);
}
yield return ((AbilityBehaviour)__instance).LearnAbility(0.5f);
}
else
{
while (values.MoveNext())
{
yield return values.Current;
}
}
}
}
[HarmonyPatch(typeof(DrawNewHand), "OnResolveOnBoard")]
private class DrawNewHand_OnResolveOnBoard_Patch
{
private static IEnumerator Postfix(IEnumerator values, DrawRabbits __instance)
{
if (((AbilityBehaviour)__instance).Card.OpponentCard)
{
yield return ((AbilityBehaviour)__instance).PreSuccessfulTriggerSequence();
yield return (object)new WaitForSeconds(0.25f);
if (player2Turn)
{
List<PlayableCard> list = player1CardsInHand.FindAll((PlayableCard x) => (Object)(object)x != (Object)(object)Singleton<PlayerHand>.Instance.ChoosingSlotCard);
while (list.Count > 0)
{
((Card)list[0]).SetInteractionEnabled(false);
((Card)list[0]).Anim.PlayDeathAnimation(true);
Object.Destroy((Object)(object)((Component)list[0]).gameObject, 1f);
player1CardsInHand.Remove(list[0]);
list.RemoveAt(0);
}
yield return (object)new WaitForSeconds(0.5f);
int num = 0;
for (int i = 0; i < 4; i = num + 1)
{
if (player1CardsInDeck.Count != 0)
{
List<CardInfo> list3 = player1CardsInDeck;
int min2 = 0;
int count2 = player1CardsInDeck.Count;
CardInfo cardInfo2 = list3[Random.Range(min2, count2)];
player1CardsInDeck.Remove(cardInfo2);
player1CardsInHand.Add(CardSpawner.SpawnPlayableCard(cardInfo2));
num = i;
}
}
}
else
{
List<PlayableCard> list2 = player2CardsInHand.FindAll((PlayableCard x) => (Object)(object)x != (Object)(object)Singleton<PlayerHand>.Instance.ChoosingSlotCard);
while (list2.Count > 0)
{
((Card)list2[0]).SetInteractionEnabled(false);
((Card)list2[0]).Anim.PlayDeathAnimation(true);
Object.Destroy((Object)(object)((Component)list2[0]).gameObject, 1f);
player2CardsInHand.Remove(list2[0]);
list2.RemoveAt(0);
}
yield return (object)new WaitForSeconds(0.5f);
int num2 = 0;
for (int j = 0; j < 4; j = num2 + 1)
{
if (player2CardsInDeck.Count != 0)
{
List<CardInfo> list4 = player2CardsInDeck;
int min = 0;
int count = player2CardsInDeck.Count;
CardInfo cardInfo = list4[Random.Range(min, count)];
player2CardsInDeck.Remove(cardInfo);
player2CardsInHand.Add(CardSpawner.SpawnPlayableCard(cardInfo));
num2 = j;
}
}
}
yield return ((AbilityBehaviour)__instance).LearnAbility(0.5f);
}
else
{
while (values.MoveNext())
{
yield return values.Current;
}
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private class CardInfo_Attack_Getter_Patch
{
private static void Postfix(CardInfo __instance, ref int __result)
{
if (!__instance.specialAbilities.Contains((SpecialTriggeredAbility)24))
{
return;
}
__result -= SaveManager.SaveFile.OuroborosDeaths;
if (!((Object)(object)CardExtensions.GetPlayableCard(__instance) != (Object)null))
{
return;
}
if (player2Turn)
{
if (CardExtensions.GetPlayableCard(__instance).OpponentCard)
{
__result += player1OuroborosDeaths;
}
else
{
__result += player2OuroborosDeaths;
}
}
else if (CardExtensions.GetPlayableCard(__instance).OpponentCard)
{
__result += player2OuroborosDeaths;
}
else
{
__result += player1OuroborosDeaths;
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private class CardInfo_Health_Getter_Patch
{
private static void Postfix(CardInfo __instance, ref int __result)
{
if (!__instance.specialAbilities.Contains((SpecialTriggeredAbility)24))
{
return;
}
__result -= SaveManager.SaveFile.OuroborosDeaths;
if (!((Object)(object)CardExtensions.GetPlayableCard(__instance) != (Object)null))
{
return;
}
if (player2Turn)
{
if (CardExtensions.GetPlayableCard(__instance).OpponentCard)
{
__result += player1OuroborosDeaths;
}
else
{
__result += player2OuroborosDeaths;
}
}
else if (CardExtensions.GetPlayableCard(__instance).OpponentCard)
{
__result += player2OuroborosDeaths;
}
else
{
__result += player1OuroborosDeaths;
}
}
}
[HarmonyPatch(typeof(Ouroboros), "OnDie")]
private class Ouroboros_OnDie_Patch
{
private static IEnumerator Postfix(IEnumerator values, bool wasSacrifice, PlayableCard killer, Ouroboros __instance)
{
if (player2Turn)
{
if (((SpecialCardBehaviour)__instance).PlayableCard.OpponentCard)
{
player1OuroborosDeaths++;
}
else
{
player2OuroborosDeaths++;
}
}
else if (((SpecialCardBehaviour)__instance).PlayableCard.OpponentCard)
{
player2OuroborosDeaths++;
}
else
{
player1OuroborosDeaths++;
}
yield break;
}
}
private Harmony harmony = new Harmony("tvflabs.inscryption.MultiplayerMod");
private const string PluginGuid = "tvflabs.inscryption.MultiplayerMod";
private const string PluginName = "MultiplayerMod";
private const string PluginVersion = "1.0.1";
private const string PluginPrefix = "MultiplayerMod";
private static Plugin plugin;
private static DeckInfo player1Deck = new DeckInfo();
private static List<PlayableCard> player1CardsOnBoard = new List<PlayableCard>();
private static List<CardInfo> player1CardsInDeck = new List<CardInfo>();
private static List<PlayableCard> player1CardsInHand = new List<PlayableCard>();
private static int player1Energy = 0;
private static int player1Bones = 0;
private static int player1Weights = 0;
private static DeckInfo player2Deck = new DeckInfo();
private static List<PlayableCard> player2CardsOnBoard = new List<PlayableCard>();
private static List<CardInfo> player2CardsInDeck = new List<CardInfo>();
private static List<PlayableCard> player2CardsInHand = new List<PlayableCard>();
private static int player2Energy = 0;
private static int player2Bones = 0;
private static int player2Weights = 0;
private static bool player2Turn = false;
private static bool decksSwapped = false;
private static Style player1Style = (Style)4;
private static Style player2Style = (Style)4;
private static int turnNum = 0;
private static bool editingPlayer2Deck = false;
private static CardCollectionInfo player1Collection = new CardCollectionInfo();
private static CardCollectionInfo player2Collection = new CardCollectionInfo();
private static bool comingFromDeckEdit = false;
private static bool editingDeck = false;
private static bool comingFromCompletedBattle = false;
private static bool player2Won = false;
private static int player1Wins = 0;
private static int player2Wins = 0;
private static int player1OuroborosDeaths = 0;
private static int player2OuroborosDeaths = 0;
private static bool dealtWithFirstPause = true;
private void Awake()
{
plugin = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded MultiplayerMod!");
string[] array = new string[20]
{
"Squirrel", "Squirrel", "Squirrel", "Squirrel", "Squirrel", "Squirrel", "Squirrel", "Warren", "Warren", "Warren",
"Warren", "Warren", "Stoat", "Stoat", "Stoat", "Hawk", "Hawk", "Hawk", "Adder", "Adder"
};
string[] array2 = new string[20]
{
"Skeleton", "Skeleton", "Skeleton", "Skeleton", "Skeleton", "Skeleton", "Skeleton", "Gravedigger", "Gravedigger", "Gravedigger",
"Gravedigger", "Gravedigger", "Draugr", "Draugr", "Draugr", "Zombie", "Zombie", "Zombie", "FrankNStein", "FrankNStein"
};
string[] array3 = new string[20]
{
"Automaton", "Automaton", "Automaton", "Automaton", "Automaton", "LeapBot", "LeapBot", "LeapBot", "LeapBot", "MineCart",
"MineCart", "MineCart", "MineCart", "Thickbot", "Thickbot", "Thickbot", "Thickbot", "Steambot", "Steambot", "Steambot"
};
string[] array4 = new string[20]
{
"Pupil", "Pupil", "Pupil", "Pupil", "Pupil", "MoxEmerald", "MoxEmerald", "MoxEmerald", "MoxRuby", "MoxRuby",
"MoxRuby", "MoxSapphire", "MoxSapphire", "MoxSapphire", "JuniorSage", "JuniorSage", "MageKnight", "MageKnight", "BlueMage", "BlueMage"
};
string[] array5 = new string[6] { "Kraken", "Kraken", "Kraken", "Squirrel", "Squirrel", "Squirrel" };
foreach (CardInfo item in CardManager.AllCardsCopy)
{
if (CardExtensions.HasCardMetaCategory(item, (CardMetaCategory)5) || CardExtensions.HasCardMetaCategory(item, (CardMetaCategory)4))
{
if (CardExtensions.HasCardMetaCategory(item, (CardMetaCategory)4))
{
for (int i = 0; i < 10; i++)
{
player1Collection.AddCard(item);
player2Collection.AddCard(item);
}
}
else if (((Object)item).name == "Kraken" || ((Object)item).name == "Ouroboros" || ((Object)item).name == "BonelordHorn" || ((Object)item).name == "DrownedSoul")
{
player1Collection.AddCard(item);
player2Collection.AddCard(item);
}
else if (((Object)item).name == "Squirrel" || ((Object)item).name == "Stoat" || ((Object)item).name == "Zombie")
{
for (int j = 0; j < 10; j++)
{
player1Collection.AddCard(item);
player2Collection.AddCard(item);
}
}
else if (((Object)item).name == "FieldMouse_Fused" || ((Object)item).name == "SentryBot_Fused" || ((Object)item).name == "Gravedigger_Fused" || ((Object)item).name == "BlueMage_Fused")
{
for (int k = 0; k < 10; k++)
{
player1Collection.AddCard(item);
player2Collection.AddCard(item);
}
}
}
if (((Object)item).name == "Rabbit")
{
player1Collection.AddCard(item);
player2Collection.AddCard(item);
}
}
harmony.PatchAll();
}
public static CardTemple GetDominantTemple(List<CardInfo> cards)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Invalid comparison between Unknown and I4
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Invalid comparison between Unknown and I4
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Invalid comparison between Unknown and I4
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
foreach (CardInfo card in cards)
{
if ((int)card.temple == 0)
{
num++;
}
else if ((int)card.temple == 1)
{
num2++;
}
else if ((int)card.temple == 2)
{
num3++;
}
else if ((int)card.temple == 3)
{
num4++;
}
}
if (num > num2 && num > num3 && num > num4)
{
return (CardTemple)0;
}
if (num2 > num && num2 > num3 && num2 > num4)
{
return (CardTemple)1;
}
if (num3 > num && num3 > num2 && num3 > num4)
{
return (CardTemple)2;
}
if (num4 > num && num4 > num2 && num4 > num3)
{
return (CardTemple)3;
}
return (CardTemple)4;
}
public static IEnumerator StartBattleConfirm()
{
yield return Singleton<TextBox>.Instance.ShowUntilInput("Both players' decks are valid. Would you like to start the battle now?", (Style)4, (DialogueSpeaker)null, (ScreenPosition)2, 0f, true, false, new Prompt("Start the battle.", "Wait.", (Action<int>)OnTextBoxButtonPressed), true, (Emotion)0);
}
private static void OnTextBoxButtonPressed(int buttonIndex)
{
if (buttonIndex == 0)
{
SceneManager.LoadScene("gbc_cardbattle");
((MonoBehaviour)plugin).StartCoroutine(StartNewCardGame());
}
}
private static IEnumerator StartNewCardGame()
{
EncounterData encounterData = new EncounterData();
encounterData.Difficulty = 5;
encounterData.opponentTurnPlan = new List<List<CardInfo>>();
encounterData.opponentTurnPlan.Add(new List<CardInfo>());
encounterData.opponentType = (Type)0;
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Singleton<TurnManager>.Instance != (Object)null));
player2Turn = false;
turnNum = 0;
player1CardsOnBoard = new List<PlayableCard>();
player1CardsInDeck = new List<CardInfo>();
player1CardsInHand = new List<PlayableCard>();
player1Energy = 0;
player1Bones = 0;
player1Weights = 0;
player1OuroborosDeaths = 0;
player2CardsOnBoard = new List<PlayableCard>();
player2CardsInDeck = new List<CardInfo>();
player2CardsInHand = new List<PlayableCard>();
player2Energy = 0;
player2Bones = 0;
player2Weights = 0;
player2OuroborosDeaths = 0;
if (Random.Range(0f, 1f) >= 0.5f)
{
SaveData.Data.deck = player1Deck;
foreach (CardInfo card in ((CardCollectionInfo)player1Deck).Cards)
{
player1CardsInDeck.Add(card);
}
foreach (CardInfo card2 in ((CardCollectionInfo)player2Deck).Cards)
{
player2CardsInDeck.Add(card2);
}
decksSwapped = false;
}
else
{
SaveData.Data.deck = player2Deck;
foreach (CardInfo card3 in ((CardCollectionInfo)player2Deck).Cards)
{
player1CardsInDeck.Add(card3);
}
foreach (CardInfo card4 in ((CardCollectionInfo)player1Deck).Cards)
{
player2CardsInDeck.Add(card4);
}
decksSwapped = true;
}
SaveData gbcData = SaveManager.SaveFile.gbcData;
gbcData.npcAttempts++;
Singleton<TurnManager>.Instance.StartGame(encounterData);
List<BoardTheme> themeOptions = new List<BoardTheme>();
if ((int)player1Style != 0 && (int)player2Style > 0)
{
themeOptions.Add((BoardTheme)0);
}
if ((int)player1Style != 1 && (int)player2Style != 1)
{
themeOptions.Add((BoardTheme)1);
}
if ((int)player1Style != 2 && (int)player2Style != 2)
{
themeOptions.Add((BoardTheme)2);
}
if ((int)player1Style != 3 && (int)player2Style != 3)
{
themeOptions.Add((BoardTheme)3);
}
BoardTheme chosenTheme = themeOptions[Random.Range(0, themeOptions.Count)];
if ((int)player1Style == 0 && (int)player2Style == 0)
{
chosenTheme = (BoardTheme)0;
}
else if ((int)player1Style == 1 && (int)player2Style == 1)
{
chosenTheme = (BoardTheme)1;
}
else if ((int)player1Style == 2 && (int)player2Style == 2)
{
chosenTheme = (BoardTheme)2;
}
else if ((int)player1Style == 3 && (int)player2Style == 3)
{
chosenTheme = (BoardTheme)3;
}
if ((int)chosenTheme == 0)
{
AudioController.Instance.SetLoopAndPlay("gbc_battle_nature", 0, true, true);
}
else if ((int)chosenTheme == 1)
{
AudioController.Instance.SetLoopAndPlay("gbc_battle_undead", 0, true, true);
}
else if ((int)chosenTheme == 2)
{
AudioController.Instance.SetLoopAndPlay("gbc_battle_tech", 0, true, true);
}
else if ((int)chosenTheme == 3)
{
AudioController.Instance.SetLoopAndPlay("gbc_battle_wizard", 0, true, true);
}
AudioController.Instance.SetLoopVolumeImmediate(1f, 0);
Singleton<PixelBoardSpriteSetter>.Instance.SetSpritesForTheme(chosenTheme);
}
private static IEnumerator SwitchToPlayer(bool player2)
{
PlayerHand hand = Singleton<PlayerHand>.Instance;
Deck deck = Singleton<CardDrawPiles>.Instance.Deck;
BoardManager board = Singleton<BoardManager>.Instance;
ResourcesManager resources = Singleton<ResourcesManager>.Instance;
if (player2)
{
player1CardsInDeck = new List<CardInfo>(deck.Cards);
deck.ClearCards();
foreach (CardInfo card8 in player2CardsInDeck)
{
deck.AddCard(card8);
}
player1CardsInHand.Clear();
foreach (PlayableCard card7 in hand.cardsInHand)
{
if ((Object)(object)card7 != (Object)null)
{
player1CardsInHand.Add(card7);
}
}
foreach (PlayableCard card6 in player1CardsInHand)
{
if ((Object)(object)card6 != (Object)null)
{
hand.RemoveCardFromHand(card6);
((Component)card6).gameObject.SetActive(false);
}
}
foreach (PlayableCard card5 in player2CardsInHand)
{
hand.ParentCardToHand(card5, ((Component)card5).transform.position);
hand.cardsInHand.Add(card5);
hand.OnCardInspected(card5);
hand.SetCardPositions();
((Component)card5).gameObject.SetActive(true);
}
player2CardsOnBoard.Clear();
player1CardsOnBoard.Clear();
foreach (CardSlot slot4 in board.OpponentSlotsCopy)
{
if ((Object)(object)slot4.Card != (Object)null)
{
player2CardsOnBoard.Add(slot4.Card);
}
else
{
player2CardsOnBoard.Add(null);
}
}
foreach (CardSlot slot3 in board.PlayerSlotsCopy)
{
if ((Object)(object)slot3.Card != (Object)null)
{
player1CardsOnBoard.Add(slot3.Card);
}
else
{
player1CardsOnBoard.Add(null);
}
}
for (int l = 0; l < board.PlayerSlotsCopy.Count; l++)
{
if ((Object)(object)player2CardsOnBoard[l] != (Object)null)
{
player2CardsOnBoard[l].SetIsOpponentCard(false);
yield return board.AssignCardToSlot(player2CardsOnBoard[l], board.PlayerSlotsCopy[l], 0f, (Action)null, false);
}
}
for (int k = 0; k < board.OpponentSlotsCopy.Count; k++)
{
if ((Object)(object)player1CardsOnBoard[k] != (Object)null)
{
player1CardsOnBoard[k].SetIsOpponentCard(true);
yield return board.AssignCardToSlot(player1CardsOnBoard[k], board.OpponentSlotsCopy[k], 0f, (Action)null, false);
}
}
player1Bones = resources.PlayerBones;
player1Energy = resources.PlayerMaxEnergy;
int boneDifference2 = player2Bones - player1Bones;
if (boneDifference2 > 0)
{
yield return resources.AddBones(boneDifference2, (CardSlot)null);
}
else if (boneDifference2 < 0)
{
yield return resources.SpendBones(Math.Abs(boneDifference2));
}
int energyDifference2 = player2Energy - player1Energy;
if (energyDifference2 > 0)
{
yield return resources.AddMaxEnergy(energyDifference2);
}
else if (energyDifference2 < 0)
{
yield return ResourcesManagerHelpers.RemoveMaxEnergy(resources, Math.Abs(energyDifference2));
}
resources.ForceGemsUpdate();
player2Weights = Singleton<LifeManager>.Instance.OpponentDamage;
player1Weights = Singleton<LifeManager>.Instance.PlayerDamage;
Singleton<LifeManager>.Instance.SetNumWeightsImmediate(player2Weights, player1Weights);
if (Singleton<LifeManager>.Instance.Scales is PixelScales)
{
Scales scales = Singleton<LifeManager>.Instance.Scales;
((PixelScales)((scales is PixelScales) ? scales : null)).UpdateWeightSprites();
Scales scales2 = Singleton<LifeManager>.Instance.Scales;
((PixelScales)((scales2 is PixelScales) ? scales2 : null)).UpdateScaleRotation();
}
yield break;
}
player2CardsInDeck = new List<CardInfo>(deck.Cards);
deck.ClearCards();
foreach (CardInfo card4 in player1CardsInDeck)
{
deck.AddCard(card4);
}
player2CardsInHand.Clear();
foreach (PlayableCard card3 in hand.cardsInHand)
{
if ((Object)(object)card3 != (Object)null)
{
player2CardsInHand.Add(card3);
}
}
foreach (PlayableCard card2 in player2CardsInHand)
{
if ((Object)(object)card2 != (Object)null)
{
hand.RemoveCardFromHand(card2);
((Component)card2).gameObject.SetActive(false);
}
}
foreach (PlayableCard card in player1CardsInHand)
{
hand.ParentCardToHand(card, ((Component)card).transform.position);
hand.cardsInHand.Add(card);
hand.OnCardInspected(card);
hand.SetCardPositions();
((Component)card).gameObject.SetActive(true);
}
player1CardsOnBoard.Clear();
player2CardsOnBoard.Clear();
foreach (CardSlot slot2 in board.OpponentSlotsCopy)
{
if ((Object)(object)slot2.Card != (Object)null)
{
player1CardsOnBoard.Add(slot2.Card);
}
else
{
player1CardsOnBoard.Add(null);
}
}
foreach (CardSlot slot in board.PlayerSlotsCopy)
{
if ((Object)(object)slot.Card != (Object)null)
{
player2CardsOnBoard.Add(slot.Card);
}
else
{
player2CardsOnBoard.Add(null);
}
}
for (int j = 0; j < board.PlayerSlotsCopy.Count; j++)
{
if ((Object)(object)player1CardsOnBoard[j] != (Object)null)
{
player1CardsOnBoard[j].SetIsOpponentCard(false);
yield return board.AssignCardToSlot(player1CardsOnBoard[j], board.PlayerSlotsCopy[j], 0f, (Action)null, false);
}
}
for (int i = 0; i < board.OpponentSlotsCopy.Count; i++)
{
if ((Object)(object)player2CardsOnBoard[i] != (Object)null)
{
player2CardsOnBoard[i].SetIsOpponentCard(true);
yield return board.AssignCardToSlot(player2CardsOnBoard[i], board.OpponentSlotsCopy[i], 0f, (Action)null, false);
}
}
player2Bones = resources.PlayerBones;
player2Energy = resources.PlayerMaxEnergy;
int boneDifference = player1Bones - player2Bones;
if (boneDifference > 0)
{
yield return resources.AddBones(boneDifference, (CardSlot)null);
}
else if (boneDifference < 0)
{
yield return resources.SpendBones(Math.Abs(boneDifference));
}
int energyDifference = player1Energy - player2Energy;
if (energyDifference > 0)
{
yield return resources.AddMaxEnergy(energyDifference);
}
else if (energyDifference < 0)
{
yield return ResourcesManagerHelpers.RemoveMaxEnergy(resources, Math.Abs(energyDifference));
}
resources.ForceGemsUpdate();
player1Weights = Singleton<LifeManager>.Instance.OpponentDamage;
player2Weights = Singleton<LifeManager>.Instance.PlayerDamage;
Singleton<LifeManager>.Instance.SetNumWeightsImmediate(player1Weights, player2Weights);
if (Singleton<LifeManager>.Instance.Scales is PixelScales)
{
Scales scales3 = Singleton<LifeManager>.Instance.Scales;
((PixelScales)((scales3 is PixelScales) ? scales3 : null)).UpdateWeightSprites();
Scales scales4 = Singleton<LifeManager>.Instance.Scales;
((PixelScales)((scales4 is PixelScales) ? scales4 : null)).UpdateScaleRotation();
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "MultiplayerMod";
public const string PLUGIN_NAME = "MultiplayerMod";
public const string PLUGIN_VERSION = "1.0.1";
}
}