using System.Collections;
using System.Diagnostics;
using System.IO;
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 UnityEngine;
[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 = "")]
[assembly: AssemblyCompany("more_portrait_replacements")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds the ability to replace more alternate portraits.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("more_portrait_replacements")]
[assembly: AssemblyTitle("more_portrait_replacements")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace more_portrait_replacements;
[BepInPlugin("lily.inscryption.more_portrait_replacements", "More Portrait Replacements", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private const string PluginVersion = "1.0.0";
public const string PluginGuid = "lily.inscryption.more_portrait_replacements";
public const string PluginName = "More Portrait Replacements";
public static string Directory;
private void Awake()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded the More Portrait Replacements mod! - Made by Lily");
Log = ((BaseUnityPlugin)this).Logger;
Directory = ((BaseUnityPlugin)this).Info.Location;
Harmony val = new Harmony("lily.inscryption.more_portrait_replacements");
val.PatchAll();
CardExtensions.SetBrokenShieldPortrait(CardLoader.GetCardByName("MudTurtle"), SpriteFromTexture(GetTexture("turtle.png")));
CardExtensions.SetPortrait(CardLoader.GetCardByName("HydraEgg"), SpriteFromTexture(GetTexture("egg.png")));
}
public static Texture2D GetTexture(string path)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
if (path == null)
{
return null;
}
byte[] array = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(Directory), "Artwork/", path));
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, array);
((Texture)val).filterMode = (FilterMode)0;
return val;
}
public static Sprite SpriteFromTexture(Texture2D tex)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
Rect val = default(Rect);
((Rect)(ref val))..ctor(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height);
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0.5f, 0.5f);
return Sprite.Create(tex, val, val2);
}
}
[HarmonyPatch(typeof(AddSnelkDecals), "ApplyAppearance")]
public class ChangeSnelkDecal
{
[HarmonyPrefix]
public static bool Prefix(CardAppearanceBehaviour __instance)
{
if (__instance.Card is PlayableCard)
{
__instance.Card.Info.TempDecals.Clear();
__instance.Card.Info.TempDecals.Add((Texture)(object)Plugin.GetTexture("snelk.png"));
return false;
}
__instance.Card.Info.TempDecals.Clear();
__instance.Card.Info.TempDecals.Add((Texture)(object)Plugin.GetTexture("snelk_in_deck.png"));
return false;
}
}
[HarmonyPatch(typeof(SteelTrap), "OnTakeDamage")]
public class ChangeSteelTrapDecal
{
[HarmonyPrefix]
public static bool Prefix(SteelTrap __instance, ref IEnumerator __result)
{
__result = SwitchPortrait(__instance);
return false;
}
public static IEnumerator SwitchPortrait(SteelTrap Base)
{
yield return (object)new WaitForSeconds(0.65f);
AudioController.Instance.PlaySound3D("sacrifice_default", (MixerGroup)4, ((Component)((AbilityBehaviour)Base).Card).transform.position, 1f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
yield return (object)new WaitForSeconds(0.1f);
((Card)((AbilityBehaviour)Base).Card).Anim.LightNegationEffect();
((AbilityBehaviour)Base).Card.SwitchToPortrait(Plugin.SpriteFromTexture(Plugin.GetTexture("trap.png")));
AudioController.Instance.PlaySound3D("dial_metal", (MixerGroup)4, ((Component)((AbilityBehaviour)Base).Card).transform.position, 1f, 0f, (Pitch)null, (Repetition)null, (Randomization)null, (Distortion)null, false);
yield return (object)new WaitForSeconds(0.75f);
}
}
[HarmonyPatch(typeof(JerseyDevil), "OnSacrifice")]
public class ChangeChild13
{
[HarmonyPrefix]
public static bool Prefix(JerseyDevil __instance, ref IEnumerator __result)
{
__result = SwitchPortrait(__instance);
return false;
}
public static IEnumerator SwitchPortrait(JerseyDevil Base)
{
Base.sacrificeCount++;
if (Base.sacrificeCount > Base.MAX_SACRIFICES)
{
yield return ((SpecialCardBehaviour)Base).PlayableCard.Die(true, (PlayableCard)null, true);
}
if (Base.sacrificeCount == Base.MAX_SACRIFICES)
{
((SpecialCardBehaviour)Base).PlayableCard.RemoveTemporaryMod(Base.mod, true);
((Card)((SpecialCardBehaviour)Base).PlayableCard).Info.TempDecals.Add((Texture)(object)Plugin.GetTexture("child.png"));
((Card)((SpecialCardBehaviour)Base).PlayableCard).RenderCard();
}
else if (Base.sacrificeCount < Base.MAX_SACRIFICES)
{
Base.attackMode = !Base.attackMode;
if (Base.attackMode)
{
((SpecialCardBehaviour)Base).PlayableCard.SwitchToAlternatePortrait();
((SpecialCardBehaviour)Base).PlayableCard.AddTemporaryMod(Base.mod);
}
else
{
((SpecialCardBehaviour)Base).PlayableCard.SwitchToDefaultPortrait();
((SpecialCardBehaviour)Base).PlayableCard.RemoveTemporaryMod(Base.mod, true);
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "more_portrait_replacements";
public const string PLUGIN_NAME = "more_portrait_replacements";
public const string PLUGIN_VERSION = "1.0.0";
}