using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModdingUtils.Utils;
using Photon.Pun;
using UnboundLib;
using UnboundLib.GameModes;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EmoPatchMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.4.1.0")]
[assembly: AssemblyInformationalVersion("1.4.1")]
[assembly: AssemblyProduct("EmoPatchMod")]
[assembly: AssemblyTitle("EmoPatchMod")]
[assembly: AssemblyVersion("1.4.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 EmoPatchMod
{
[BepInPlugin("emo.rounds.emopatchmod", "EmoPatchMod", "1.4.1")]
[BepInProcess("Rounds.exe")]
[BepInDependency("com.XAngelMoonX.rounds.CosmicRounds", "2.7.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class Plugin : BaseUnityPlugin
{
public const string ModId = "emo.rounds.emopatchmod";
public const string ModName = "EmoPatchMod";
public const string Version = "1.4.1";
internal const string ScmeId = "com.Sfinford.Rounds.SCME";
internal const string MfmId = "com.MrseFuntik.Rounds.MFM";
internal const string WwgmId = "com.willuwontu.rounds.gamemodes";
private Harmony bloodPactHarmony;
internal const string CosmicRoundsId = "com.XAngelMoonX.rounds.CosmicRounds";
internal const string FlairsCardsId = "com.Flair.Mod.FlairsCards";
internal const string CardsPlusId = "com.willis.rounds.cardsplus";
private Harmony harmony;
private Harmony controlFreakHarmony;
private Harmony snakeHarmony;
private Harmony scmeHarmony;
private void Awake()
{
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Expected O, but got Unknown
try
{
PluginInfo val = Chainloader.PluginInfos["com.XAngelMoonX.rounds.CosmicRounds"];
if (val.Metadata.Version != new Version("2.7.0"))
{
throw new NotSupportedException("Zodiac patch targets Cosmic Rounds 2.7.0.");
}
Type type = ((object)val.Instance).GetType().Assembly.GetType("CR.MonoBehaviors.ZodiacMono");
MethodInfo methodInfo = ((type == null) ? null : AccessTools.DeclaredMethod(type, "Update", (Type[])null, (Type[])null));
if (methodInfo == null)
{
throw new MissingMethodException("Cosmic Rounds ZodiacMono.Update was not found.");
}
Type type2 = ((object)val.Instance).GetType().Assembly.GetType("CR.Cards.ZodiacCardPlus");
ZodiacUpgradePatch.UpgradeCardField = ((type2 == null) ? null : AccessTools.DeclaredField(type2, "card"));
if (ZodiacUpgradePatch.UpgradeCardField?.FieldType != typeof(CardInfo) || !ZodiacUpgradePatch.UpgradeCardField.IsStatic || AccessTools.DeclaredField(type, "player")?.FieldType != typeof(Player))
{
throw new MissingMemberException("Zodiac patch targets do not match the supported build.");
}
ZodiacUpgradePatch.ReportError = delegate(Exception error)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"Zodiac upgrade stopped for this player to prevent repeated deck resets. Restart the match/session before retrying.\n{error}");
};
harmony = new Harmony("emo.rounds.emopatchmod");
harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(ZodiacUpgradePatch), "UpdatePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)$"Zodiac+ guarded batch upgrade patch applied (Cosmic Rounds {val.Metadata.Version}).");
}
catch (Exception arg)
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
((BaseUnityPlugin)this).Logger.LogError((object)$"Zodiac+ patch could not be applied. Report this error with your Cosmic Rounds version.\n{arg}");
}
ApplyControlFreakPatch();
ApplySnakeAttackPatch();
ApplyScmePatch();
ApplyBloodPactPatch();
}
private void ApplyControlFreakPatch()
{
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Expected O, but got Unknown
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Expected O, but got Unknown
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Expected O, but got Unknown
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Expected O, but got Unknown
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("com.Flair.Mod.FlairsCards", out var value))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"FlairsCards not installed; Control Freak patch skipped.");
return;
}
try
{
if (value.Metadata.Version != new Version("0.2.0"))
{
throw new NotSupportedException($"Control Freak patch targets FlairsCards 0.2.0; found {value.Metadata.Version}.");
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
Type type = assembly.GetType("FlairsCards.Cards.ControlFreak", throwOnError: true);
Type type2 = assembly.GetType("FlairsCards.MonoBehaviours.ControlFreakMono", throwOnError: true);
MethodInfo methodInfo = AccessTools.DeclaredMethod(type, "SetupCard", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.DeclaredMethod(type2, "RoundStart", (Type[])null, (Type[])null);
MethodInfo methodInfo3 = AccessTools.DeclaredMethod(type2, "Update", (Type[])null, (Type[])null);
MethodInfo methodInfo4 = AccessTools.DeclaredMethod(typeof(Block), "Cooldown", Type.EmptyTypes, (Type[])null);
ControlFreakPatch.CardField = AccessTools.DeclaredField(type, "Card");
if (methodInfo == null || methodInfo2 == null || methodInfo3 == null || methodInfo4 == null || AccessTools.DeclaredField(type2, "player")?.FieldType != typeof(Player) || AccessTools.DeclaredField(type2, "block")?.FieldType != typeof(Block) || ControlFreakPatch.CardField == null || !ControlFreakPatch.CardField.IsStatic || ControlFreakPatch.CardField.FieldType != typeof(CardInfo))
{
throw new MissingMemberException("Control Freak patch targets do not match the supported build.");
}
controlFreakHarmony = new Harmony("emo.rounds.emopatchmod.controlfreak");
controlFreakHarmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(typeof(ControlFreakPatch), "CooldownPostfix", (Type[])null)
{
priority = 0
}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
controlFreakHarmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(ControlFreakPatch), "SetupPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
controlFreakHarmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(ControlFreakPatch), "RoundStartPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
controlFreakHarmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(ControlFreakPatch), "UpdatePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
ControlFreakBattleGate.Register();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Control Freak fixed 1-second cooldown patch applied (FlairsCards 0.2.0); automatic blocks wait for BattleStart.");
}
catch (Exception arg)
{
Harmony obj = controlFreakHarmony;
if (obj != null)
{
obj.UnpatchSelf();
}
ControlFreakBattleGate.Unregister();
((BaseUnityPlugin)this).Logger.LogError((object)$"Control Freak patch could not be applied; Zodiac+ patch is independent.\n{arg}");
}
}
private void ApplySnakeAttackPatch()
{
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Expected O, but got Unknown
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("com.willis.rounds.cardsplus", out var value))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Cards+ not installed; Snake Attack patch skipped.");
return;
}
try
{
if (value.Metadata.Version != new Version("1.8.12"))
{
throw new NotSupportedException($"Snake Attack patch targets Cards+ 1.8.12; found {value.Metadata.Version}.");
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
Type type = assembly.GetType("CardsPlusPlugin.Cards.SnakeSpawner", throwOnError: true);
Type type2 = assembly.GetType("CardsPlusPlugin.Cards.SnakeFollow", throwOnError: true);
MethodInfo methodInfo = AccessTools.DeclaredMethod(type, "DoHitEffect", new Type[1] { typeof(HitInfo) }, (Type[])null);
MethodInfo methodInfo2 = AccessTools.DeclaredMethod(type, "RPC_SpawnSnake", new Type[2]
{
typeof(Vector3),
typeof(float)
}, (Type[])null);
SnakeAttackPatch.SnakeCountField = AccessTools.DeclaredField(type2, "snakeCount");
SnakeAttackPatch.MaxSnakeCountField = AccessTools.DeclaredField(type2, "maxSnakeCount");
if (methodInfo == null || methodInfo.IsStatic || methodInfo2 == null || !methodInfo2.IsStatic || SnakeAttackPatch.SnakeCountField?.FieldType != typeof(int) || SnakeAttackPatch.MaxSnakeCountField?.FieldType != typeof(int) || !SnakeAttackPatch.SnakeCountField.IsStatic || !SnakeAttackPatch.MaxSnakeCountField.IsStatic)
{
throw new MissingMemberException("Snake Attack targets do not match the supported build.");
}
snakeHarmony = new Harmony("emo.rounds.emopatchmod.snakeattack");
snakeHarmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(SnakeAttackPatch), "HitTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
snakeHarmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(SnakeAttackPatch), "SpawnRpcPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Snake Attack owner-to-host spawn patch applied (Cards+ 1.8.12).");
}
catch (Exception arg)
{
Harmony obj = snakeHarmony;
if (obj != null)
{
obj.UnpatchSelf();
}
((BaseUnityPlugin)this).Logger.LogError((object)$"Snake Attack patch could not be applied; other patches are independent.\n{arg}");
}
}
private void ApplyScmePatch()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("com.Sfinford.Rounds.SCME", out var value))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"SCME not installed; Egg modifications skipped.");
return;
}
try
{
if (value.Metadata.Version != new Version("3.1.1"))
{
throw new NotSupportedException($"Egg modifications target SCME 3.1.1; found {value.Metadata.Version}.");
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
scmeHarmony = new Harmony("emo.rounds.emopatchmod.scme");
string[] array = new string[2] { "Egg", "FriedEgg" };
foreach (string text in array)
{
Type type = assembly.GetType("SCME.Cards." + text, throwOnError: true);
MethodInfo methodInfo = AccessTools.DeclaredMethod(type, "SetupCard", new Type[5]
{
typeof(CardInfo),
typeof(Gun),
typeof(ApplyCardStats),
typeof(CharacterStatModifiers),
typeof(Block)
}, (Type[])null);
MethodInfo methodInfo2 = AccessTools.DeclaredMethod(type, "GetStats", Type.EmptyTypes, (Type[])null);
if (methodInfo == null || methodInfo2 == null || methodInfo2.ReturnType != typeof(CardInfoStat[]))
{
throw new MissingMemberException("SCME Egg targets do not match the supported build.");
}
scmeHarmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(ScmeEggPatch), text + "SetupPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
scmeHarmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(ScmeEggPatch), text + "StatsPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"SCME Egg modifications applied: Egg +500 Regen; Fried Egg no Regen and +25000% Damage.");
}
catch (Exception arg)
{
Harmony obj = scmeHarmony;
if (obj != null)
{
obj.UnpatchSelf();
}
((BaseUnityPlugin)this).Logger.LogError((object)$"SCME Egg modifications could not be applied; other patches are independent.\n{arg}");
}
}
private void ApplyBloodPactPatch()
{
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Expected O, but got Unknown
if (!Chainloader.PluginInfos.TryGetValue("com.MrseFuntik.Rounds.MFM", out var value) || !Chainloader.PluginInfos.TryGetValue("com.willuwontu.rounds.gamemodes", out var value2))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"MFM or WillsWackyGameModes not installed; Blood Pact Singleton patch skipped.");
return;
}
try
{
if (value.Metadata.Version != new Version("3.8.2") || value2.Metadata.Version != new Version("0.0.6"))
{
throw new NotSupportedException("Blood Pact Singleton patch targets MFM 3.8.2 and WillsWackyGameModes 0.0.6.");
}
BloodPactSingletonPatch.OfferingCardField = AccessTools.DeclaredField(((object)value.Instance).GetType().Assembly.GetType("MrFuntikMod.Cards.BloodPactOfferingCard", throwOnError: true), "card");
MethodInfo methodInfo = AccessTools.DeclaredMethod(((object)value2.Instance).GetType().Assembly.GetType("WWGM.GameModeModifiers.SingletonModifier", throwOnError: true), "Condition", new Type[2]
{
typeof(Player),
typeof(CardInfo)
}, (Type[])null);
if (BloodPactSingletonPatch.OfferingCardField?.FieldType != typeof(CardInfo) || !BloodPactSingletonPatch.OfferingCardField.IsStatic || methodInfo == null || !methodInfo.IsStatic || methodInfo.ReturnType != typeof(bool))
{
throw new MissingMemberException("Blood Pact Singleton targets do not match the supported builds.");
}
bloodPactHarmony = new Harmony("emo.rounds.emopatchmod.bloodpactsingleton");
bloodPactHarmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(BloodPactSingletonPatch), "ConditionPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Blood Pact Offering Singleton repeat-pick patch applied (MFM 3.8.2 / WWGM 0.0.6).");
}
catch (Exception arg)
{
Harmony obj = bloodPactHarmony;
if (obj != null)
{
obj.UnpatchSelf();
}
((BaseUnityPlugin)this).Logger.LogError((object)$"Blood Pact Singleton patch could not be applied; other patches are independent.\n{arg}");
}
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
Harmony obj2 = controlFreakHarmony;
if (obj2 != null)
{
obj2.UnpatchSelf();
}
ControlFreakBattleGate.Unregister();
Harmony obj3 = snakeHarmony;
if (obj3 != null)
{
obj3.UnpatchSelf();
}
Harmony obj4 = scmeHarmony;
if (obj4 != null)
{
obj4.UnpatchSelf();
}
Harmony obj5 = bloodPactHarmony;
if (obj5 != null)
{
obj5.UnpatchSelf();
}
}
}
internal static class ZodiacUpgradePatch
{
internal sealed class UpgradeState
{
internal bool Busy;
internal bool Failed;
internal float NextCheck;
}
private sealed class DisposableEnumerator : IDisposable
{
internal readonly IEnumerator Iterator;
internal DisposableEnumerator(IEnumerator iterator)
{
Iterator = iterator;
}
public void Dispose()
{
(Iterator as IDisposable)?.Dispose();
}
}
internal static FieldInfo UpgradeCardField;
internal static Action<Exception> ReportError;
private static readonly ConditionalWeakTable<Player, UpgradeState> States = new ConditionalWeakTable<Player, UpgradeState>();
private static readonly HashSet<string> BaseNames = new HashSet<string>(new string[12]
{
"Aquarius", "Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio",
"Sagittarius", "Capricorn"
}.Select((string name) => "__CR__" + name));
internal static bool UpdatePrefix(Player ___player)
{
if ((!PhotonNetwork.OfflineMode && !PhotonNetwork.IsMasterClient) || (Object)(object)___player == (Object)null || (Object)(object)___player.data == (Object)null)
{
return false;
}
UpgradeState value = States.GetValue(___player, (Player _) => new UpgradeState());
if (value.Busy || value.Failed || Time.time < value.NextCheck)
{
return false;
}
value.NextCheck = Time.time + 0.4f;
object? obj = UpgradeCardField?.GetValue(null);
CardInfo val = (CardInfo)((obj is CardInfo) ? obj : null);
if ((Object)(object)val == (Object)null || !___player.data.currentCards.Contains(val))
{
return false;
}
try
{
List<int> list = new List<int>();
List<CardInfo> list2 = new List<CardInfo>();
CardInfo[] array = ___player.data.currentCards.ToArray();
for (int num = 0; num < array.Length; num++)
{
CardInfo val2 = array[num];
if (!((Object)(object)val2 == (Object)null) && BaseNames.Contains(((Object)val2).name))
{
CardInfo cardWithObjectName = Cards.instance.GetCardWithObjectName(((Object)val2).name + "+");
if ((Object)(object)cardWithObjectName == (Object)null)
{
throw new InvalidOperationException("Missing Zodiac upgrade: " + ((Object)val2).name);
}
list.Add(num);
list2.Add(cardWithObjectName);
}
}
if (list.Count == 0)
{
return false;
}
value.Busy = true;
((MonoBehaviour)Unbound.Instance).StartCoroutine(RunBatch(___player, value, list.ToArray(), list2.ToArray()));
}
catch (Exception obj2)
{
value.Failed = true;
value.Busy = false;
ReportError?.Invoke(obj2);
}
return false;
}
private static IEnumerator RunBatch(Player player, UpgradeState state, int[] indices, CardInfo[] replacements)
{
bool completed = false;
try
{
using (DisposableEnumerator operation = new DisposableEnumerator(Cards.instance.ReplaceCards(player, indices, replacements, (string[])null, true)))
{
while (true)
{
bool flag;
try
{
flag = operation.Iterator.MoveNext();
}
catch (Exception obj)
{
ReportError?.Invoke(obj);
yield break;
}
if (!flag)
{
break;
}
yield return operation.Iterator.Current;
}
}
completed = true;
}
finally
{
state.Failed = !completed;
state.Busy = false;
state.NextCheck = Time.time + 0.4f;
}
}
}
internal static class ControlFreakPatch
{
internal static FieldInfo CardField;
internal static void CooldownPostfix(Block __instance, ref float __result)
{
if (OwnsCard(((Component)__instance).GetComponent<Player>()))
{
__result = 1f;
}
}
internal static bool OwnsCard(Player player)
{
object? obj = CardField?.GetValue(null);
CardInfo val = (CardInfo)((obj is CardInfo) ? obj : null);
if ((Object)(object)val != (Object)null && (Object)(object)player != (Object)null && (Object)(object)player.data != (Object)null && player.data.currentCards != null)
{
return player.data.currentCards.Contains(val);
}
return false;
}
internal static bool UpdatePrefix(Player ___player, Block ___block)
{
if (ControlFreakBattleGate.BattleActive && (Object)(object)___block != (Object)null && OwnsCard(___player) && ___player.data.isPlaying)
{
return !___player.data.dead;
}
return false;
}
internal static void SetupPostfix(Block block)
{
block.cdAdd = 0f;
}
internal static bool RoundStartPrefix(ref IEnumerator __result)
{
__result = Array.Empty<object>().GetEnumerator();
return false;
}
}
internal static class ControlFreakBattleGate
{
private static readonly string[] StopEvents = new string[7] { "GameStart", "GameEnd", "PickStart", "RoundStart", "PointStart", "PointEnd", "RoundEnd" };
private static readonly List<string> RegisteredStops = new List<string>();
private static bool registeredStart;
internal static bool BattleActive { get; private set; }
internal static void Register()
{
BattleActive = false;
string[] stopEvents = StopEvents;
foreach (string text in stopEvents)
{
GameModeManager.AddHook(text, (Func<IGameModeHandler, IEnumerator>)StopBattle, int.MaxValue);
RegisteredStops.Add(text);
}
GameModeManager.AddHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)StartBattle, int.MinValue);
registeredStart = true;
}
internal static void Unregister()
{
BattleActive = false;
foreach (string registeredStop in RegisteredStops)
{
GameModeManager.RemoveHook(registeredStop, (Func<IGameModeHandler, IEnumerator>)StopBattle);
}
RegisteredStops.Clear();
if (registeredStart)
{
GameModeManager.RemoveHook("BattleStart", (Func<IGameModeHandler, IEnumerator>)StartBattle);
}
registeredStart = false;
}
internal static IEnumerator StopBattle(IGameModeHandler gameMode)
{
BattleActive = false;
return Array.Empty<object>().GetEnumerator();
}
internal static IEnumerator StartBattle(IGameModeHandler gameMode)
{
if (!BattleActive && (Object)(object)PlayerManager.instance != (Object)null)
{
foreach (Player player in PlayerManager.instance.players)
{
if (ControlFreakPatch.OwnsCard(player))
{
Block component = ((Component)player).GetComponent<Block>();
if ((Object)(object)component != (Object)null)
{
component.counter = 1f;
}
}
}
}
BattleActive = true;
return Array.Empty<object>().GetEnumerator();
}
}
internal static class SnakeAttackPatch
{
internal static FieldInfo SnakeCountField;
internal static FieldInfo MaxSnakeCountField;
internal static bool CanRequestSnake(Component spawner)
{
if (PhotonNetwork.OfflineMode)
{
return true;
}
if ((Object)(object)spawner == (Object)null)
{
return false;
}
SpawnedAttack component = spawner.GetComponent<SpawnedAttack>();
if ((Object)(object)component != (Object)null)
{
return component.IsMine();
}
return false;
}
internal static IEnumerable<CodeInstruction> HitTranspiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
MethodInfo masterGetter = typeof(PhotonNetwork).GetProperty("IsMasterClient").GetGetMethod();
List<int> list2 = (from x in list.Select((CodeInstruction instruction, int index) => new { instruction, index })
where x.instruction.opcode == OpCodes.Call && object.Equals(x.instruction.operand, masterGetter)
select x.index).ToList();
if (list2.Count != 1)
{
throw new InvalidOperationException($"Expected one SnakeSpawner hit authority check; found {list2.Count}. No changes applied.");
}
int num = list2[0];
list[num].opcode = OpCodes.Ldarg_0;
list[num].operand = null;
list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)typeof(SnakeAttackPatch).GetMethod("CanRequestSnake", BindingFlags.Static | BindingFlags.NonPublic)));
return list;
}
internal static bool SpawnRpcPrefix()
{
if (!PhotonNetwork.IsMasterClient && !PhotonNetwork.OfflineMode)
{
return false;
}
if (SnakeCountField == null || MaxSnakeCountField == null)
{
return false;
}
return (int)SnakeCountField.GetValue(null) < (int)MaxSnakeCountField.GetValue(null);
}
}
internal static class ScmeEggPatch
{
internal static void EggSetupPostfix(CharacterStatModifiers statModifiers)
{
statModifiers.regen = 500f;
}
internal static void FriedEggSetupPostfix(Gun gun, CharacterStatModifiers statModifiers)
{
statModifiers.regen = 0f;
gun.damage = 251f;
}
internal static void EggStatsPostfix(ref CardInfoStat[] __result)
{
foreach (CardInfoStat item in __result.Where((CardInfoStat stat) => stat.stat == "Regen"))
{
item.amount = "+500";
}
}
internal static void FriedEggStatsPostfix(ref CardInfoStat[] __result)
{
__result = __result.Where((CardInfoStat stat) => stat.stat != "Regen").ToArray();
foreach (CardInfoStat item in __result.Where((CardInfoStat stat) => stat.stat == "Damage"))
{
item.amount = "+25000%";
}
}
}
internal static class BloodPactSingletonPatch
{
internal static FieldInfo OfferingCardField;
internal static void ConditionPostfix(Player player, CardInfo card, ref bool __result)
{
if (!__result && !((Object)(object)player == (Object)null) && !((Object)(object)player.data == (Object)null) && !((Object)(object)card == (Object)null))
{
object? obj = OfferingCardField?.GetValue(null);
CardInfo val = (CardInfo)((obj is CardInfo) ? obj : null);
if ((Object)(object)val != (Object)null && (Object)(object)card == (Object)(object)val && player.data.currentCards != null && player.data.currentCards.Contains(val))
{
__result = true;
}
}
}
}
}