using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using Microsoft.CodeAnalysis;
using SmallTweak_Hydra.PATCHES;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: AssemblyCompany("SmallTweak_Hydra")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Hydra adapt to your environment please.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+68f5c616a18728a75bdb459887c1a4db3dfdab9c")]
[assembly: AssemblyProduct("SmallTweak_Hydra")]
[assembly: AssemblyTitle("SmallTweak_Hydra")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 SmallTweak_Hydra
{
[BepInPlugin("creator.SmallTweak.Hydra", "Smalltweak Hydra", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SmallTweak_Hydra : BaseUnityPlugin
{
public const string PluginGuid = "creator.SmallTweak.Hydra";
public const string PluginName = "Smalltweak Hydra";
public const string PluginVersion = "1.0.0";
public const string PluginPrefix = "Smalltweak_Hydra";
public static ManualLogSource Log = new ManualLogSource("Smalltweak Hydra");
public static Harmony harmony = new Harmony("creator.SmallTweak.Hydra");
public void Awake()
{
harmony.PatchAll(typeof(HydraPatches));
harmony.PatchAll(typeof(HydraPortraitPatches));
harmony.PatchAll(typeof(HydraRulebookPatches));
((BaseUnityPlugin)this).Logger.LogMessage((object)"creator.SmallTweak.Hydra: Loaded Mod: Smalltweak Hydra - 1.0.0");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SmallTweak_Hydra";
public const string PLUGIN_NAME = "SmallTweak_Hydra";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace SmallTweak_Hydra.PATCHES
{
[HarmonyPatch]
internal static class HydraPatches
{
public static int GetNumberOfTribesInDeck()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
List<CardInfo> list = new List<CardInfo>(((CardCollectionInfo)RunState.Run.playerDeck).Cards);
list.Sort((CardInfo a, CardInfo b) => a.tribes.Count - b.tribes.Count);
HashSet<Tribe> hashSet = new HashSet<Tribe>();
foreach (CardInfo item in list)
{
if (item.HasAbility((Ability)106))
{
continue;
}
foreach (Tribe tribe in item.tribes)
{
if ((int)tribe != 0)
{
hashSet.Add(tribe);
}
}
}
return hashSet.Count;
}
public static int GetHealthNum()
{
List<CardInfo> list = new List<CardInfo>(((CardCollectionInfo)RunState.Run.playerDeck).Cards);
List<int> list2 = new List<int>();
list.Sort((CardInfo a, CardInfo b) => a.Health - b.Health);
foreach (CardInfo item in list)
{
if (!item.HasAbility((Ability)106) && !list2.Contains(item.Health))
{
list2.Add(item.Health);
}
}
return list2.Count;
}
public static int GetPowerNum()
{
List<CardInfo> list = new List<CardInfo>(((CardCollectionInfo)RunState.Run.playerDeck).Cards);
List<int> list2 = new List<int>();
list.Sort((CardInfo a, CardInfo b) => a.Attack - b.Attack);
foreach (CardInfo item in list)
{
if (!item.HasAbility((Ability)106) && !list2.Contains(item.Attack))
{
list2.Add(item.Attack);
}
}
return list2.Count;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(HydraEgg), "RespondsToDrawn")]
public static bool PrefixRespondsToDrawn(ref bool __result)
{
if (GetHealthNum() < 5 || GetPowerNum() < 5)
{
__result = false;
return false;
}
__result = GetNumberOfTribesInDeck() >= 5;
return false;
}
}
[HarmonyPatch]
internal static class HydraPortraitPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(HydraEggPortrait), "ApplyCardInfo")]
public static bool ApplyCardInfo(CardInfo card, HydraEggPortrait __instance)
{
__instance.healthLightRenderers.ForEach(delegate(SpriteRenderer x)
{
((Renderer)x).enabled = false;
});
for (int i = 0; i < Mathf.Min(HydraPatches.GetHealthNum(), __instance.healthLightRenderers.Count); i++)
{
((Renderer)__instance.healthLightRenderers[i]).enabled = true;
}
__instance.powerLightRenderers.ForEach(delegate(SpriteRenderer x)
{
((Renderer)x).enabled = false;
});
for (int j = 0; j < Mathf.Min(HydraPatches.GetPowerNum(), __instance.powerLightRenderers.Count); j++)
{
((Renderer)__instance.powerLightRenderers[j]).enabled = true;
}
__instance.tribeLightRenderers.ForEach(delegate(SpriteRenderer x)
{
((Renderer)x).enabled = false;
});
for (int k = 0; k < Mathf.Min(HydraPatches.GetNumberOfTribesInDeck(), __instance.tribeLightRenderers.Count); k++)
{
((Renderer)__instance.tribeLightRenderers[k]).enabled = true;
}
return false;
}
}
[HarmonyPatch(typeof(RuleBookInfo))]
internal static class HydraRulebookPatches
{
[HarmonyAfter(new string[] { "cyantist.inscryption.api" })]
[HarmonyPostfix]
[HarmonyPatch("ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })]
public static void PostfixUpdateHydraEggRulebook(AbilityMetaCategory metaCategory)
{
AbilityInfo val = ((IEnumerable<AbilityInfo>)AbilityManager.AllAbilityInfos).FirstOrDefault((Func<AbilityInfo, bool>)((AbilityInfo i) => (int)i.ability == 106));
if (!((Object)(object)val == (Object)null))
{
val.rulebookDescription = "A card bearing this Sigil hatches when drawn if 5 unique numbers are in the Health of creatures in your deck, and in their Power, and if there is a creature of 5 unique tribes in your deck. [This Excludes all cards bearing this sigil]";
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}