using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AnsiConsolePlugin.Util;
using BepInEx;
using BepInEx.Configuration;
using CsvHelper;
using CsvHelper.Configuration;
using CsvHelper.Configuration.Attributes;
using DeathcardGenerator.Helpers.Logging;
using DiskCardGame;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using TextureReplacer.Configuration;
using TextureReplacer.PATCHES.Deathcards;
using TextureReplacer.Utility.CSVs;
using TextureReplacer.Utility.Deathcards;
using TextureReplacer.Utility.Deathcards.LostEye;
using TextureReplacer.Utility.Deathcards.Presets;
using TextureReplacer.Utility.Deathcards.Presets.Objects;
using TextureReplacer.Utility.Deathcards.Saves;
using TextureReplacer.Utility.Deathcards.Saves.Objects;
using TextureReplacer.Utility.Images;
using TextureReplacer.Utility.Pathing;
using TextureReplacer.Utility.Reloading;
using TextureReplacer.Utility.Reloading.Deathcards;
using TimeElapsingConsolePlugin.Util;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("AnsiConsolePlugin")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("TimeElapsingConsolePlugin")]
[assembly: AssemblyCompany("Texture Replacer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A Texture replacer for Inscryption")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+508c945f9754bee0d94822bd3e7ff808d275bed3")]
[assembly: AssemblyProduct("Texture Replacer")]
[assembly: AssemblyTitle("Texture Replacer")]
[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 DeathcardGenerator.Helpers.Logging
{
public static class Logger
{
public static void Log(string from, string level, string content)
{
if (level == "Error")
{
Console.WriteLine(string.Format("[{0}{1}, {2}{3}]: {4}{5}{6}", GetColorFromTypeFunctions.GetColorFromString("Red", "HighIntensityHighlighter"), DateTime.Now, from, "\u001b[0m", GetColorFromTypeFunctions.GetColorFromString("Red", "Regular"), content, "\u001b[0m"));
}
if (level == "Warning")
{
Console.WriteLine(string.Format("[{0}{1}, {2}{3}]: {4}{5}{6}", GetColorFromTypeFunctions.GetColorFromString("Yellow", "HighIntensityHighlighter"), DateTime.Now, from, "\u001b[0m", GetColorFromTypeFunctions.GetColorFromString("Yellow", "Regular"), content, "\u001b[0m"));
}
if (level == "Info")
{
Console.WriteLine(string.Format("[{0}{1}, {2}{3}]: {4}{5}{6}", GetColorFromTypeFunctions.GetColorFromString("Magenta", "HighIntensityHighlighter"), DateTime.Now, from, "\u001b[0m", GetColorFromTypeFunctions.GetColorFromString("Magenta", "Regular"), content, "\u001b[0m"));
}
}
}
}
namespace TextureReplacer
{
[BepInPlugin("creator.inscryption.TextureReplacerInscryption", "Texture Replacer", "1.0.0")]
public class TextureReplacer : BaseUnityPlugin
{
public const string PluginGuid = "creator.inscryption.TextureReplacerInscryption";
public const string PluginName = "Texture Replacer";
public const string PluginVersion = "1.0.0";
public const string PluginPrefix = "Texture_Replacer";
public static Harmony Harmony = new Harmony("creator.inscryption.TextureReplacerInscryption");
public static Assembly assembly = Assembly.GetExecutingAssembly();
public static string DLLPath = Path.GetDirectoryName(assembly.Location);
public static string ConfigPath = GoUpAFolderUntilX.Approach("BepInEx", DLLPath) + "\\config\\TextureReplacer";
public void Awake()
{
Logger.Log("Texture Replacer", "Info", "Began loading for Texture Replacer.");
Logger.Log("Texture Replacer", "Info", "Make sure the the Deathcard System config is set otherwise the mod will bork.");
Logger.Log("Texture Replacer", "Info", "Currently loading version: 1.0.0");
Logger.Log("Texture Replacer", "Info", "Creating the config...");
Information obj = Logging.StartWaitTime("Creating Basic Configuration", "ms", "Texture Replacer");
BasicConfiguration.Config = ((BaseUnityPlugin)this).Config;
BasicConfiguration.Init();
Logging.StopWaitTime(obj);
Logger.Log("Texture Replacer", "Info", "Runtime stuff...");
if (BasicConfiguration.enableDeathcardReplacement.Value)
{
Information obj2 = Logging.StartWaitTime("Handling Local Files; Deathcards", "ms", "Texture Replacer");
LoadNORight.Load();
HandleTrees.LoadPeices();
LoadPresets.load();
LoadSaves.Load();
Logging.StopWaitTime(obj2);
}
Logger.Log("Texture Replacer", "Info", "Patching...");
Information obj3 = Logging.StartWaitTime("Patching The Game", "ms", "Texture Replacer");
Harmony.PatchAll(typeof(DeathCardPortraitPatches));
Harmony.PatchAll(typeof(SaveFilePatches));
Logging.StopWaitTime(obj3);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Texture Replacer";
public const string PLUGIN_NAME = "Texture Replacer";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace TextureReplacer.Utility.Reloading
{
public class ReloadClass
{
public static void Initialize<T>(EventHandler reloader, params ConfigEntry<T>[] configs)
{
for (int i = 0; i < configs.Length; i++)
{
configs[i].SettingChanged += reloader;
}
}
}
}
namespace TextureReplacer.Utility.Reloading.Deathcards
{
public class ReloadDeathcardsClass
{
public static void ReloadDeathcards(object sender, EventArgs args)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if (BasicConfiguration.enableDeathcardReplacement.Value)
{
Logger.Log("Reload", "Info", "Spotted a change in configuration specifically " + ((ConfigEntryBase)sender).Definition.Key + " for Deathcards, reloading base directories associated with Deathcards Please Hold...");
Information obj = Logging.StartWaitTime("Handling Local Files; Deathcards", "ms", "Texture Replacer");
LoadNORight.Load();
HandleTrees.LoadPeices();
LoadPresets.load();
LoadSaves.Load();
Logging.StopWaitTime(obj);
}
}
}
}
namespace TextureReplacer.Utility.Pathing
{
public class GoUpAFolderUntilX
{
public static string Approach(string X, string path)
{
while (Path.GetFileName(Path.GetFullPath(path)) != X)
{
Logger.Log("Approach", "Info", "Currently attempting path; " + Path.GetFullPath(path));
path += "\\..";
}
Logger.Log("Approach", "Info", "Found path where end equals " + X + "; " + Path.GetFullPath(path));
return path;
}
}
}
namespace TextureReplacer.Utility.Images
{
public class GetCustomImageClass
{
public static Sprite GetCustomImage(string fileName, string imagePath)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = LoadCustomPNGClass.LoadCustomPNG(fileName, imagePath);
if ((Object)(object)val != (Object)null)
{
Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
((Object)obj).name = fileName;
return obj;
}
Logger.Log("GetCustomImage", "Error", "Sprite creation failed for: " + fileName + " at path: " + imagePath);
return null;
}
}
public class LoadCustomPNGClass
{
public static Texture2D LoadCustomPNG(string fileName, string imagePath)
{
return LoadCustomTextureClass.LoadCustomTexture(fileName, imagePath);
}
}
public class LoadCustomTextureClass
{
public static Texture2D LoadCustomTexture(string fileName, string imagePath)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0033: Expected O, but got Unknown
string text = Path.Combine(imagePath, fileName + ".png");
if (File.Exists(text))
{
byte[] array = File.ReadAllBytes(text);
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
ImageConversion.LoadImage(val, array);
return val;
}
Logger.Log("LoadCustomTexture", "Error", "Texture not found at path: " + text);
return null;
}
}
public class LoadCustomTextureFromBase64Class
{
public static void LoadCustomTextureFromBase64(string base64, string filename)
{
Logger.Log("LoadCustomTextureFromBase64", "Info", "Converting base64: " + base64 + " into a png.");
ImageExtensions.SaveAsPng((Image)(object)Image.Load<Rgba32>(Convert.FromBase64String(base64)), Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits\\" + filename + ".png"));
}
}
}
namespace TextureReplacer.Utility.Deathcards
{
public class CheckConditions
{
public static bool Check(string name, Conditions conditions, CardModificationInfo modificationInfo)
{
//IL_0125: 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_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
Logger.Log("Check", "Info", $"Name Check Evaluates to {name == modificationInfo.nameReplacement}");
Logger.Log("Check", "Info", $"Attack Check Evaluates to {conditions.attack == modificationInfo.attackAdjustment}");
Logger.Log("Check", "Info", $"Health Check Evaluates to {conditions.health == modificationInfo.healthAdjustment}");
Logger.Log("Check", "Info", $"Abilities Check Evaluates to {modificationInfo.abilities.All(conditions.abilities.Contains)}");
Logger.Log("Check", "Info", $"Blood Cost Check Evaluates to {conditions.bloodCost == modificationInfo.bloodCostAdjustment}");
Logger.Log("Check", "Info", $"Bone Cost Check Evaluates to {conditions.boneCost == modificationInfo.bonesCostAdjustment}");
Logger.Log("Check", "Info", $"Stat Icon Check Evaluates to {conditions.statIcon == modificationInfo.statIcon}");
Logger.Log("Check", "Info", $"Special Abilities Check Evaluates to {modificationInfo.specialAbilities.All(conditions.specialAbilities.Contains)}");
Logger.Log("Check", "Info", $"Lost Eye Check Evaluates to {conditions.lostEye == modificationInfo.deathCardInfo.lostEye}");
if (name == modificationInfo.nameReplacement && conditions.attack == modificationInfo.attackAdjustment && conditions.health == modificationInfo.healthAdjustment && modificationInfo.abilities.All(conditions.abilities.Contains) && conditions.bloodCost == modificationInfo.bloodCostAdjustment && conditions.boneCost == modificationInfo.bonesCostAdjustment && conditions.statIcon == modificationInfo.statIcon && modificationInfo.specialAbilities.All(conditions.specialAbilities.Contains))
{
return conditions.lostEye == modificationInfo.deathCardInfo.lostEye;
}
return false;
}
}
public class ChooseRandomPeices
{
public static (List<Image<Rgba32>>, List<Image<Rgba32>>) PeiceSelection()
{
Logger.Log("PeiceSelection", "Info", "Randomly selecting peices from the pool.");
List<Image<Rgba32>> list = new List<Image<Rgba32>>();
List<Image<Rgba32>> list2 = new List<Image<Rgba32>>();
int num = 0;
Random random = new Random();
foreach (List<Image<Rgba32>> peice in HandleTrees.Peices)
{
int num2 = random.Next(0, peice.Count);
list.Add(peice[num2]);
Logger.Log("PeiceSelection", "Info", $"Selected peice {num2} from current set {num} of peices.");
try
{
list2.Add(HandleTrees.EmissivePeices[num][num2]);
num++;
}
catch
{
num++;
}
}
return (list, list2);
}
}
public class CompilePortrait
{
public static void compile(List<Image<Rgba32>> compiledPieces, List<Image<Rgba32>> compiledEPieces, string Name, bool Losteye)
{
Logger.Log("Compile", "Info", "Compiling Deathcard Portrait.");
Image<Rgba32> val = new Image<Rgba32>(114, 94);
ProcessingExtensions.Mutate<Rgba32>(val, (Action<IImageProcessingContext>)delegate(IImageProcessingContext img)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
foreach (Image<Rgba32> compiledPiece in compiledPieces)
{
DrawImageExtensions.DrawImage(img, (Image)(object)compiledPiece, new Point(0, 0), 1f);
}
});
Logger.Log("Compile", "Info", "Attempting to Compile Deathcard Emission.");
Image<Rgba32> val2 = new Image<Rgba32>(114, 94);
if (compiledEPieces.Count > 0)
{
ProcessingExtensions.Mutate<Rgba32>(val2, (Action<IImageProcessingContext>)delegate(IImageProcessingContext img)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
foreach (Image<Rgba32> compiledEPiece in compiledEPieces)
{
DrawImageExtensions.DrawImage(img, (Image)(object)compiledEPiece, new Point(0, 0), 1f);
}
});
}
if (Losteye)
{
(val, val2) = HandleLostEye.LOSTMAEYE(val, val2);
}
Logger.Log("Compile", "Info", "Saving Deathcard Portrait at " + Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits\\" + Name + ".png"));
ImageExtensions.SaveAsPng((Image)(object)val, Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits\\" + Name + ".png"));
((Image)val).Dispose();
Logger.Log("Compile", "Info", "Saving Deathcard Emission at " + Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits\\" + Name + "_Emissive.png"));
ImageExtensions.SaveAsPng((Image)(object)val2, Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits\\" + Name + "_Emissive.png"));
((Image)val2).Dispose();
}
}
public class HandleTrees
{
public static List<List<Image<Rgba32>>> Peices = new List<List<Image<Rgba32>>>();
public static List<List<Image<Rgba32>>> EmissivePeices = new List<List<Image<Rgba32>>>();
public static void LoadPeices()
{
Logger.Log("LoadPeices", "Info", "Clearing Lists");
Information obj = Logging.StartWaitTime("List Clearence", "ms", "Texture Replacer");
Peices.Clear();
EmissivePeices.Clear();
Logging.StopWaitTime(obj);
string[] directories = Directory.GetDirectories(Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value));
foreach (string text in directories)
{
if (Path.GetFileName(text).StartsWith("RESERVED-"))
{
Logger.Log("LoadPeices", "Info", "Found a reserved prefixed item, skipping. ");
continue;
}
Logger.Log("LoadPeices", "Info", "Scanning through " + Path.GetFileName(text) + ". ");
List<Image<Rgba32>> list = new List<Image<Rgba32>>();
List<Image<Rgba32>> list2 = new List<Image<Rgba32>>();
string[] files = Directory.GetFiles(Path.GetFullPath(text));
foreach (string text2 in files)
{
if (text2.EndsWith(".png") && !Path.GetFileName(text2).StartsWith("RESERVED-"))
{
Logger.Log("LoadPeices", "Info", "Found a piece item, named/at " + text2 + ". ");
list.Add(Image.Load<Rgba32>(text2));
}
}
string path = Path.Combine(text, "Emissive");
if (Directory.Exists(path))
{
files = Directory.GetFiles(path);
foreach (string text3 in files)
{
if (text3.EndsWith(".png") && !Path.GetFileName(text3).StartsWith("RESERVED-"))
{
Logger.Log("LoadPeices", "Info", "Found a piece item, named/at " + text3 + ". ");
list2.Add(Image.Load<Rgba32>(text3));
}
}
}
Peices.Add(list);
EmissivePeices.Add(list2);
}
}
}
}
namespace TextureReplacer.Utility.Deathcards.Saves
{
public class LoadSaves
{
public static Dictionary<string, Conditions> conditionals = new Dictionary<string, Conditions>();
public static Dictionary<string, SavedImage> saveimagals = new Dictionary<string, SavedImage>();
public static List<string> savedNames = new List<string>();
public static void Load()
{
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
Information obj = Logging.StartWaitTime("List Clearence", "ms", "Texture Replacer");
conditionals.Clear();
saveimagals.Clear();
savedNames.Clear();
Logging.StopWaitTime(obj);
string fullPath = Path.GetFullPath(Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value) + "\\RESERVED-Saves.csv");
Logger.Log("Load", "Info", "Loading Saved Associations from " + fullPath);
if (!File.Exists(fullPath))
{
return;
}
foreach (Saves_CSV item in ParseCSVClass.ParseCSV<Saves_CSV>(fullPath))
{
if (item.name == "name")
{
Logger.Log("Load", "Info", "Skipping, this is for those that read the file.");
continue;
}
string name = item.name;
Logger.Log("Load", "Info", "Name set to " + name);
int num = int.Parse(item.attack);
Logger.Log("Load", "Info", $"{name}); Attack set to {num}");
int num2 = int.Parse(item.health);
Logger.Log("Load", "Info", $"{name}); Health set to {num2}");
List<Ability> list = new List<Ability>();
if (item.abilities != "[]")
{
string[] array = item.abilities.Replace("[", "").Replace("]", "").Split(new char[1] { ';' });
for (int i = 0; i < array.Length; i++)
{
Enum.TryParse<Ability>(array[i], out Ability result);
Logger.Log("Load", "Info", name + "); Adding ability " + ((object)(Ability)(ref result)).ToString() + " to the Ability list.");
list.Add(result);
}
}
int num3 = int.Parse(item.blood);
Logger.Log("Load", "Info", $"{name}); Blood Cost set to {num3}");
int num4 = int.Parse(item.bone);
Logger.Log("Load", "Info", $"{name}); Bone Cost set to {num4}");
SpecialStatIcon statIcon = (SpecialStatIcon)0;
if (item.statIcon != "None")
{
Enum.TryParse<SpecialStatIcon>(item.statIcon, out SpecialStatIcon result2);
Logger.Log("Load", "Info", name + "); Stat Icon set to " + ((object)(SpecialStatIcon)(ref result2)).ToString());
statIcon = result2;
}
List<SpecialTriggeredAbility> list2 = new List<SpecialTriggeredAbility>();
if (item.specialAbilities != "[]")
{
string[] array = item.specialAbilities.Replace("[", "").Replace("]", "").Split(new char[1] { ';' });
for (int i = 0; i < array.Length; i++)
{
Enum.TryParse<SpecialTriggeredAbility>(array[i], out SpecialTriggeredAbility result3);
Logger.Log("Load", "Info", name + "); Special Ability " + ((object)(SpecialTriggeredAbility)(ref result3)).ToString() + " added to Special Ability list");
list2.Add(result3);
}
}
bool lostEye = bool.Parse(item.lostEye);
Logger.Log("Load", "Info", name + "); Lost Eye set to " + lostEye);
Conditions value = new Conditions(num, num2, list, num3, num4, statIcon, list2, lostEye);
string portraitbase = item.portraitbase64;
Logger.Log("Load", "Info", name + "); Portrait set to " + portraitbase);
string emissionbase = item.emissionbase64;
Logger.Log("Load", "Info", name + "); Portrait set to " + emissionbase);
SavedImage value2 = new SavedImage(portraitbase, emissionbase);
Logger.Log("Load", "Info", "Adding afforementioned conditions, and images to the Lists");
conditionals.Add(name, value);
saveimagals.Add(name, value2);
savedNames.Add(name);
}
}
public static void LoadLast()
{
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
string fullPath = Path.GetFullPath(Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value) + "\\RESERVED-Saves.csv");
Logger.Log("Write", "Info", "Loading Last Saved Association from " + fullPath);
Saves_CSV saves_CSV = ParseCSVClass.ParseCSV<Saves_CSV>(fullPath).Last();
string name = saves_CSV.name;
Logger.Log("Load", "Info", "Name set to " + name);
int num = int.Parse(saves_CSV.attack);
Logger.Log("Load", "Info", $"{name}); Attack set to {num}");
int num2 = int.Parse(saves_CSV.health);
Logger.Log("Load", "Info", $"{name}); Health set to {num2}");
List<Ability> list = new List<Ability>();
if (saves_CSV.abilities != "[]")
{
string[] array = saves_CSV.abilities.Replace("[", "").Replace("]", "").Split(new char[1] { ';' });
for (int i = 0; i < array.Length; i++)
{
Enum.TryParse<Ability>(array[i], out Ability result);
Logger.Log("Load", "Info", name + "); Adding ability " + ((object)(Ability)(ref result)).ToString() + " to the Ability list.");
list.Add(result);
}
}
int num3 = int.Parse(saves_CSV.blood);
Logger.Log("Load", "Info", $"{name}); Blood Cost set to {num3}");
int num4 = int.Parse(saves_CSV.bone);
Logger.Log("Load", "Info", $"{name}); Bone Cost set to {num4}");
SpecialStatIcon statIcon = (SpecialStatIcon)0;
if (saves_CSV.statIcon != "None")
{
Enum.TryParse<SpecialStatIcon>(saves_CSV.statIcon, out SpecialStatIcon result2);
Logger.Log("Load", "Info", name + "); Stat Icon set to " + ((object)(SpecialStatIcon)(ref result2)).ToString());
statIcon = result2;
}
List<SpecialTriggeredAbility> list2 = new List<SpecialTriggeredAbility>();
if (saves_CSV.specialAbilities != "[]")
{
string[] array = saves_CSV.specialAbilities.Replace("[", "").Replace("]", "").Split(new char[1] { ';' });
for (int i = 0; i < array.Length; i++)
{
Enum.TryParse<SpecialTriggeredAbility>(array[i], out SpecialTriggeredAbility result3);
Logger.Log("Load", "Info", name + "); Special Ability " + ((object)(SpecialTriggeredAbility)(ref result3)).ToString() + " added to Special Ability list");
list2.Add(result3);
}
}
bool lostEye = bool.Parse(saves_CSV.lostEye);
Logger.Log("Load", "Info", name + "); Lost Eye set to " + lostEye);
Conditions value = new Conditions(num, num2, list, num3, num4, statIcon, list2, lostEye);
string portraitbase = saves_CSV.portraitbase64;
Logger.Log("Load", "Info", name + "); Portrait set to " + portraitbase);
string emissionbase = saves_CSV.emissionbase64;
Logger.Log("Load", "Info", name + "); Portrait set to " + emissionbase);
SavedImage value2 = new SavedImage(portraitbase, emissionbase);
Logger.Log("Load", "Info", "Adding afforementioned conditions, and images to the Lists");
conditionals.Add(name, value);
saveimagals.Add(name, value2);
savedNames.Add(name);
}
}
public class WriteSaves
{
public static void Write(CardModificationInfo mods, string Portrait, string PortraitEmission)
{
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
string fullPath = Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value);
string fullPath2 = Path.GetFullPath(fullPath + "\\RESERVED-Saves.csv");
Logger.Log("Write", "Info", "Saving Deathcard Portrait as a Preset to " + Path.GetFullPath(fullPath + "\\RESERVED-Saves.csv"));
if (!File.Exists(fullPath2))
{
Logger.Log("Write", "Info", "Creating save file since it is not present");
StreamWriter streamWriter = new StreamWriter(fullPath2, append: false);
streamWriter.WriteLine("name,attack,health,abilities[],blood,bones,statIcon,specialAbilities[],lostEye,portrait,emission");
streamWriter.Close();
}
Logger.Log("Write", "Info", "Opening Saves in append mode");
StreamWriter streamWriter2 = new StreamWriter(fullPath2, append: true);
string text = $"{mods.nameReplacement},{mods.attackAdjustment},{mods.healthAdjustment},";
string text2 = "[";
int num = 0;
foreach (Ability ability in mods.abilities)
{
Ability current = ability;
text2 = ((num != 0) ? (text2 + ";" + ((object)(Ability)(ref current)).ToString()) : (text2 + ((object)(Ability)(ref current)).ToString()));
num++;
}
text2 += "]";
text += $"{text2},{mods.bloodCostAdjustment},{mods.bonesCostAdjustment},{mods.statIcon},";
text2 = "[";
num = 0;
foreach (SpecialTriggeredAbility specialAbility in mods.specialAbilities)
{
SpecialTriggeredAbility current2 = specialAbility;
text2 = ((num != 0) ? (text2 + ";" + ((object)(SpecialTriggeredAbility)(ref current2)).ToString()) : (text2 + ((object)(SpecialTriggeredAbility)(ref current2)).ToString()));
num++;
}
text2 += "]";
text += string.Format("{0},{1},\"{2}\",\"{3}\"", text2, mods.deathCardInfo.lostEye, Portrait.Replace("data:image/png;base64,", ""), PortraitEmission.Replace("data:image/png;base64,", ""));
Logger.Log("Write", "Info", "Writing the following line to save file.");
Logger.Log("Write", "Info", text ?? "");
streamWriter2.WriteLine(text);
streamWriter2.Close();
}
}
}
namespace TextureReplacer.Utility.Deathcards.Saves.Objects
{
public class SavedImage
{
public string PortraitImage;
public string EmissionImage;
public SavedImage(string PortraitImage, string EmissionImage)
{
this.PortraitImage = PortraitImage;
this.EmissionImage = EmissionImage;
}
}
public class Saves_CSV
{
public string name { get; set; }
public string attack { get; set; }
public string health { get; set; }
[Name("abilities[]")]
public string abilities { get; set; }
public string blood { get; set; }
[Name("bones")]
public string bone { get; set; }
public string statIcon { get; set; }
[Name("specialAbilities[]")]
public string specialAbilities { get; set; }
public string lostEye { get; set; }
[Name("portrait")]
public string portraitbase64 { get; set; }
[Name("emission")]
public string emissionbase64 { get; set; }
}
}
namespace TextureReplacer.Utility.Deathcards.Presets
{
public class LoadPresets
{
public static Dictionary<string, Conditions> conditionals = new Dictionary<string, Conditions>();
public static Dictionary<string, Preset> presetals = new Dictionary<string, Preset>();
public static List<string> presetNames = new List<string>();
public static void load()
{
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
Information obj = Logging.StartWaitTime("List Clearence", "ms", "Texture Replacer");
conditionals.Clear();
presetals.Clear();
presetNames.Clear();
Logging.StopWaitTime(obj);
foreach (Presets_CSV item in ParseCSVClass.ParseCSV<Presets_CSV>(Path.GetFullPath(Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value) + "\\RESERVED-Presets.csv")))
{
if (item.name == "name")
{
Logger.Log("Load", "Info", "Skipping, this is for those that read the file.");
continue;
}
string name = item.name;
Logger.Log("Load", "Info", "Name set to " + name);
int num = int.Parse(item.attack);
Logger.Log("Load", "Info", $"{name}); Attack set to {num}");
int num2 = int.Parse(item.health);
Logger.Log("Load", "Info", $"{name}); Attack set to {num2}");
List<Ability> list = new List<Ability>();
if (item.abilities != "null")
{
string[] array = item.abilities.Replace("[", "").Replace("]", "").Split(new char[1] { ';' });
for (int i = 0; i < array.Length; i++)
{
Enum.TryParse<Ability>(array[i], out Ability result);
Logger.Log("Load", "Info", name + "); Adding ability " + ((object)(Ability)(ref result)).ToString() + " to the Ability list.");
list.Add(result);
}
}
int num3 = int.Parse(item.blood);
Logger.Log("Load", "Info", $"{name}); Blood Cost set to {num3}");
int num4 = int.Parse(item.bone);
Logger.Log("Load", "Info", $"{name}); Bone Cost set to {num4}");
SpecialStatIcon statIcon = (SpecialStatIcon)0;
if (item.statIcon != "null")
{
Enum.TryParse<SpecialStatIcon>(item.statIcon, out SpecialStatIcon result2);
Logger.Log("Load", "Info", name + "); Stat Icon set to " + ((object)(SpecialStatIcon)(ref result2)).ToString());
statIcon = result2;
}
List<SpecialTriggeredAbility> list2 = new List<SpecialTriggeredAbility>();
if (item.specialAbilities != "null")
{
string[] array = item.specialAbilities.Replace("[", "").Replace("]", "").Split(new char[1] { ';' });
for (int i = 0; i < array.Length; i++)
{
Enum.TryParse<SpecialTriggeredAbility>(array[i], out SpecialTriggeredAbility result3);
Logger.Log("Load", "Info", name + "); Special Ability " + ((object)(SpecialTriggeredAbility)(ref result3)).ToString() + " added to Special Ability list");
list2.Add(result3);
}
}
bool lostEye = bool.Parse(item.lostEye);
Logger.Log("Load", "Info", name + "); Lost Eye set to " + lostEye);
Conditions value = new Conditions(num, num2, list, num3, num4, statIcon, list2, lostEye);
string portraitFile = item.portraitFile;
Logger.Log("Load", "Info", name + "); Portrait Name set to " + portraitFile);
string emissionFile = item.emissionFile;
Logger.Log("Load", "Info", name + "); Emission Name set to " + portraitFile);
Preset value2 = new Preset(portraitFile, emissionFile);
Logger.Log("Load", "Info", "Adding afforementioned conditions, and presets to the Lists");
conditionals.Add(name, value);
presetals.Add(name, value2);
presetNames.Add(name);
}
}
}
}
namespace TextureReplacer.Utility.Deathcards.Presets.Objects
{
public class Conditions
{
public int attack { get; set; }
public int health { get; set; }
public List<Ability> abilities { get; set; }
public int bloodCost { get; set; }
public int boneCost { get; set; }
public SpecialStatIcon statIcon { get; set; }
public List<SpecialTriggeredAbility> specialAbilities { get; set; }
public bool lostEye { get; set; }
public Conditions(int attack, int health, List<Ability> abilities, int bloodCost, int boneCost, SpecialStatIcon statIcon, List<SpecialTriggeredAbility> specialAbilities, bool lostEye)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
this.attack = attack;
this.health = health;
this.abilities = abilities;
this.bloodCost = bloodCost;
this.boneCost = boneCost;
this.statIcon = statIcon;
this.specialAbilities = specialAbilities;
this.lostEye = lostEye;
}
}
public class Presets_CSV
{
public string name { get; set; }
public string attack { get; set; }
public string health { get; set; }
[Name("abilities[]")]
public string abilities { get; set; }
public string blood { get; set; }
[Name("bones")]
public string bone { get; set; }
public string statIcon { get; set; }
[Name("specialAbilities[]")]
public string specialAbilities { get; set; }
public string lostEye { get; set; }
[Name("preset")]
public string portraitFile { get; set; }
[Name("preset_emission")]
public string emissionFile { get; set; }
}
public class Preset
{
public string PortraitPath;
public string EmissionPath;
public string PortraitName;
public string EmissionName;
public Preset(string PortraitName, string EmissionName)
{
PortraitPath = Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value + "\\RESERVED-Presets");
EmissionPath = Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value + "\\RESERVED-Presets");
this.PortraitName = PortraitName;
this.EmissionName = EmissionName;
}
}
}
namespace TextureReplacer.Utility.Deathcards.LostEye
{
public class HandleLostEye
{
public static (Image<Rgba32> basePortrait, Image<Rgba32> baseEmission) LOSTMAEYE(Image<Rgba32> basePortrait, Image<Rgba32> baseEmission)
{
string fullPath = Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value);
string text = "RESERVED-NORIGHT.txt";
Path.GetFullPath(fullPath + "\\" + text);
Logger.Log("HandleLostEye", "Info", "Parsing the NoRight Subpaths provided.");
foreach (KeyValuePair<string, List<bool>> subPath in LoadNORight.subPaths)
{
Logger.Log("HandleLostEye", "Info", $"Proceed in path {subPath.Key}? result {subPath.Value[0]}.");
if (!subPath.Value[0])
{
continue;
}
Logger.Log("HandleLostEye", "Info", "Get and Load applicable NoRight.");
string fullPath2 = Path.GetFullPath(fullPath + "\\" + subPath.Key + "\\RESERVED-NoRight.png");
Image<Rgba32> image2 = Image.Load<Rgba32>(fullPath2);
Logger.Log("HandleLostEye", "Info", $"Checking if we inverse for {subPath.Key}, result {subPath.Value[1]}.");
if (subPath.Value[1])
{
Logger.Log("HandleLostEye", "Info", "Inverse portrait alpha");
basePortrait.ProcessPixelRows((PixelAccessorAction<Rgba32>)delegate(PixelAccessor<Rgba32> accessor)
{
for (int num = 0; num < accessor.Height; num++)
{
Span<Rgba32> rowSpan4 = accessor.GetRowSpan(num);
for (int num2 = 0; num2 < rowSpan4.Length; num2++)
{
ref Rgba32 reference4 = ref rowSpan4[num2];
reference4.A = (byte)(255 - reference4.A);
}
}
});
Logger.Log("HandleLostEye", "Info", "Paste in No Right");
ProcessingExtensions.Mutate<Rgba32>(basePortrait, (Action<IImageProcessingContext>)delegate(IImageProcessingContext img)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
DrawImageExtensions.DrawImage(img, (Image)(object)image2, new Point(0, 0), 1f);
});
Logger.Log("HandleLostEye", "Info", "Inverse portrait alpha");
basePortrait.ProcessPixelRows((PixelAccessorAction<Rgba32>)delegate(PixelAccessor<Rgba32> accessor)
{
for (int m = 0; m < accessor.Height; m++)
{
Span<Rgba32> rowSpan3 = accessor.GetRowSpan(m);
for (int n = 0; n < rowSpan3.Length; n++)
{
ref Rgba32 reference3 = ref rowSpan3[n];
reference3.A = (byte)(255 - reference3.A);
}
}
});
}
else if (!subPath.Value[1])
{
Logger.Log("HandleLostEye", "Info", "Paste in No Right");
ProcessingExtensions.Mutate<Rgba32>(basePortrait, (Action<IImageProcessingContext>)delegate(IImageProcessingContext img)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
DrawImageExtensions.DrawImage(img, (Image)(object)image2, new Point(0, 0), 1f);
});
}
}
Logger.Log("HandleLostEye", "Info", "Parsing the NoRight Subpaths provided.");
foreach (KeyValuePair<string, List<bool>> item in LoadNORight.subPathsEmissive)
{
Logger.Log("HandleLostEye", "Info", $"Proceed in path {item.Key}? result {item.Value[0]}.");
if (!item.Value[0])
{
continue;
}
Logger.Log("HandleLostEye", "Info", "Get and Load applicable NoRight.");
string fullPath3 = Path.GetFullPath(fullPath + "\\" + item.Key + "\\Emissive\\RESERVED-NoRight.png");
Image<Rgba32> image = Image.Load<Rgba32>(fullPath3);
Logger.Log("HandleLostEye", "Info", $"Checking if we inverse for {item.Key}, result {item.Value[1]}.");
if (item.Value[1])
{
Logger.Log("HandleLostEye", "Info", "Inverse portrait alpha");
baseEmission.ProcessPixelRows((PixelAccessorAction<Rgba32>)delegate(PixelAccessor<Rgba32> accessor)
{
for (int k = 0; k < accessor.Height; k++)
{
Span<Rgba32> rowSpan2 = accessor.GetRowSpan(k);
for (int l = 0; l < rowSpan2.Length; l++)
{
ref Rgba32 reference2 = ref rowSpan2[l];
reference2.R = (byte)(255 - reference2.R);
reference2.G = (byte)(255 - reference2.G);
reference2.B = (byte)(255 - reference2.B);
reference2.A = (byte)(255 - reference2.A);
}
}
});
Logger.Log("HandleLostEye", "Info", "Paste in No Right");
ProcessingExtensions.Mutate<Rgba32>(baseEmission, (Action<IImageProcessingContext>)delegate(IImageProcessingContext img)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
DrawImageExtensions.DrawImage(img, (Image)(object)image, new Point(0, 0), 1f);
});
Logger.Log("HandleLostEye", "Info", "Inverse portrait alpha");
baseEmission.ProcessPixelRows((PixelAccessorAction<Rgba32>)delegate(PixelAccessor<Rgba32> accessor)
{
for (int i = 0; i < accessor.Height; i++)
{
Span<Rgba32> rowSpan = accessor.GetRowSpan(i);
for (int j = 0; j < rowSpan.Length; j++)
{
ref Rgba32 reference = ref rowSpan[j];
reference.A = (byte)(255 - reference.A);
reference.R = (byte)(255 - reference.R);
reference.G = (byte)(255 - reference.G);
reference.B = (byte)(255 - reference.B);
}
}
});
}
else if (!item.Value[1])
{
Logger.Log("HandleLostEye", "Info", "Paste in No Right");
ProcessingExtensions.Mutate<Rgba32>(baseEmission, (Action<IImageProcessingContext>)delegate(IImageProcessingContext img)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
DrawImageExtensions.DrawImage(img, (Image)(object)image, new Point(0, 0), 1f);
});
}
}
return (basePortrait, baseEmission);
}
}
public class LoadNORight
{
public static Dictionary<string, List<bool>> subPaths = new Dictionary<string, List<bool>>();
public static Dictionary<string, List<bool>> subPathsEmissive = new Dictionary<string, List<bool>>();
public static void Load()
{
Information obj = Logging.StartWaitTime("List Clearence", "ms", "Texture Replacer");
subPaths.Clear();
subPathsEmissive.Clear();
Logging.StopWaitTime(obj);
string fullPath = Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value);
string text = "RESERVED-NORIGHT";
string fullPath2 = Path.GetFullPath(fullPath + "\\" + text);
Logger.Log("LoadNORIGHT", "Info", "Parsing the NoRight that was provided.");
string[] array = File.ReadAllLines(fullPath2);
foreach (string text2 in array)
{
List<bool> list = new List<bool>();
List<bool> list2 = new List<bool>();
if ((text2.StartsWith("/") || text2.StartsWith("\\") || text2.StartsWith("|") || string.IsNullOrWhiteSpace(text2)) && !text2.StartsWith("|->"))
{
continue;
}
List<string> list3 = text2.Split(new char[1] { '=' }).ToList();
if (list3[0].StartsWith("|->"))
{
Logger.Log("LoadNORIGHT", "Info", "Handling Emmissive.");
bool flag = bool.Parse(list3[0].Replace("|->", "").Trim());
bool item = false;
if (flag)
{
item = bool.Parse(list3[1].Trim());
}
list2.Add(flag);
list2.Add(item);
Logger.Log("LoadNORIGHT", "Info", string.Format("NoRight variables for Emissive in {0} set to {1} and {2}.", subPaths.Last().Key, bool.Parse(list3[0].Replace("|->", "").Trim()), bool.Parse(list3[1].Trim())));
subPathsEmissive.Add(subPaths.Last().Key, list2);
continue;
}
Logger.Log("LoadNORIGHT", "Info", "Handling Subfolder.");
string text3 = list3[0].Trim();
bool flag2 = bool.Parse(list3[1].Trim());
bool item2 = false;
if (flag2)
{
item2 = bool.Parse(list3[2].Trim());
}
list.Add(flag2);
list.Add(item2);
Logger.Log("LoadNORIGHT", "Info", string.Format("NoRight variables for {0} set to {1} and {2}.", text3, bool.Parse(list3[1].Replace("|->", "").Trim()), bool.Parse(list3[2].Trim())));
subPaths.Add(text3, list);
}
}
}
}
namespace TextureReplacer.Utility.CSVs
{
public class ParseCSVClass
{
public static List<T> ParseCSV<T>(string path)
{
//IL_0005: 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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
CsvConfiguration val = new CsvConfiguration(CultureInfo.InvariantCulture)
{
LineBreakInQuotedFieldIsBadData = true,
HasHeaderRecord = false
};
using StreamReader streamReader = new StreamReader(path);
CsvReader val2 = new CsvReader((TextReader)streamReader, (IReaderConfiguration)(object)val, false);
try
{
return new List<T>(val2.GetRecords<T>());
}
finally
{
((IDisposable)val2)?.Dispose();
}
}
}
}
namespace TextureReplacer.PATCHES.Deathcards
{
[HarmonyPatch]
public class DeathCardPortraitPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(DeathCardPortrait), "ApplyCardInfo")]
public static bool ApplyCardInfoPrepatch(ref CardInfo card, DeathCardPortrait __instance)
{
//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_0407: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
if (BasicConfiguration.enableDeathcardReplacement.Value)
{
CardModificationInfo val = card.Mods.Find((CardModificationInfo x) => x.deathCardInfo != null);
if (val == null)
{
Logger.Log("ApplyCardInfoPrepatch", "Error", "No card modification mods?!?!!? How did this occur?");
return false;
}
Sprite customImage = GetCustomImageClass.GetCustomImage("Empty", Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits"));
LoadPresets.presetNames.Contains(val.nameReplacement);
LoadSaves.savedNames.Contains(val.nameReplacement);
LoadPresets.conditionals.TryGetValue(val.nameReplacement, out var value);
LoadSaves.conditionals.TryGetValue(val.nameReplacement, out var value2);
if (value == null && value2 == null)
{
Logger.Log("ApplyCardInfoPrepatch", "Error", "No Conditions associated with " + val.nameReplacement + ".");
}
LoadPresets.presetals.TryGetValue(val.nameReplacement, out var value3);
LoadSaves.saveimagals.TryGetValue(val.nameReplacement, out var value4);
if (value4 != null && CheckConditions.Check(val.nameReplacement, value2, val))
{
Logger.Log("ApplyCardInfoPrepatch", "Info", "Saved image corralation found.");
LoadCustomTextureFromBase64Class.LoadCustomTextureFromBase64(value4.PortraitImage, "deathcardtemp");
LoadCustomTextureFromBase64Class.LoadCustomTextureFromBase64(value4.EmissionImage, "deathcardtemp_Emissive");
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting Head to Portrait.");
__instance.head.sprite = GetCustomImageClass.GetCustomImage("deathcardtemp", Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits"));
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting EyeEmission to Emission.");
__instance.eyesEmission.sprite = GetCustomImageClass.GetCustomImage("deathcardtemp_Emissive", Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits"));
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting Mouth to Empty (its in the portrait already).");
__instance.mouth.sprite = customImage;
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting mouth local position back to Vector2.zero");
((Component)__instance.mouth).transform.localPosition = Vector2.op_Implicit(Vector2.zero);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting Eyes to Empty (its in the portrait already).");
__instance.eyes.sprite = customImage;
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting eyes local position back to Vector2.zero");
((Component)__instance.eyes).transform.localPosition = Vector2.op_Implicit(Vector2.zero);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting EyeBlocker off (its in the portrait and emission already).");
__instance.eyeBlocker.SetActive(false);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Killing base game death card base.");
((Component)((Component)__instance.head).transform.parent.Find("Body")).gameObject.SetActive(false);
return false;
}
if (value3 != null && CheckConditions.Check(val.nameReplacement, value, val))
{
Logger.Log("ApplyCardInfoPrepatch", "Info", "Preset has been found, applying preset and saving the corralation.");
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting Head to Portrait.");
__instance.head.sprite = GetCustomImageClass.GetCustomImage(value3.PortraitName.Replace(".png", ""), value3.PortraitPath);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting EyeEmission to Emission.");
__instance.eyesEmission.sprite = GetCustomImageClass.GetCustomImage(value3.EmissionName.Replace(".png", ""), value3.EmissionPath);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting Mouth to Empty (its in the portrait already).");
__instance.mouth.sprite = customImage;
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting mouth local position back to Vector2.zero");
((Component)__instance.mouth).transform.localPosition = Vector2.op_Implicit(Vector2.zero);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting Eyes to Empty (its in the portrait already).");
__instance.eyes.sprite = customImage;
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting eyes local position back to Vector2.zero");
((Component)__instance.eyes).transform.localPosition = Vector2.op_Implicit(Vector2.zero);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Setting EyeBlocker off (its in the portrait and emission already).");
__instance.eyeBlocker.SetActive(false);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Killing base game death card base.");
((Component)((Component)__instance.head).transform.parent.Find("Body")).gameObject.SetActive(false);
WriteSaves.Write(val, ImageExtensions.ToBase64String((Image)(object)Image.Load<Rgba32>(ImageConversion.EncodeToPNG(__instance.head.sprite.texture)), (IImageFormat)(object)PngFormat.Instance) ?? "", ImageExtensions.ToBase64String((Image)(object)Image.Load<Rgba32>(ImageConversion.EncodeToPNG(__instance.eyesEmission.sprite.texture)), (IImageFormat)(object)PngFormat.Instance) ?? "");
LoadSaves.LoadLast();
return false;
}
Logger.Log("ApplyCardInfoPrepatch", "Info", "Creating Randomized Portrait and Saving since No Preset was Found.");
__instance.DisplayFace(val.deathCardInfo.headType, val.deathCardInfo.mouthIndex, val.deathCardInfo.eyesIndex, val.deathCardInfo.lostEye);
Logger.Log("ApplyCardInfoPrepatch", "Info", "Killing base game death card base.");
((Component)((Component)__instance.head).transform.parent.Find("Body")).gameObject.SetActive(false);
WriteSaves.Write(val, ImageExtensions.ToBase64String((Image)(object)Image.Load<Rgba32>(ImageConversion.EncodeToPNG(__instance.head.sprite.texture)), (IImageFormat)(object)PngFormat.Instance) ?? "", ImageExtensions.ToBase64String((Image)(object)Image.Load<Rgba32>(ImageConversion.EncodeToPNG(__instance.eyesEmission.sprite.texture)), (IImageFormat)(object)PngFormat.Instance) ?? "");
LoadSaves.LoadLast();
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DeathCardPortrait), "DisplayFace")]
public static bool DisplayFacePrepatch(ref FigurineType headType, ref int mouthIndex, ref int eyesIndex, ref bool lostEye, DeathCardPortrait __instance)
{
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
if (BasicConfiguration.enableDeathcardReplacement.Value)
{
Logger.Log("DisplayFacePrepatch", "Info", "Calling piece randomizer.");
(List<Image<Rgba32>>, List<Image<Rgba32>>) tuple = ChooseRandomPeices.PeiceSelection();
List<Image<Rgba32>> item = tuple.Item1;
List<Image<Rgba32>> item2 = tuple.Item2;
string text = "deathcardtemp";
Logger.Log("DisplayFacePrepatch", "Info", "Calling piece compiler.");
CompilePortrait.compile(item, item2, text, lostEye);
Logger.Log("DisplayFacePrepatch", "Info", "Turning our images into Unity Sprites.");
Sprite customImage = GetCustomImageClass.GetCustomImage(text, Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits"));
Sprite customImage2 = GetCustomImageClass.GetCustomImage(text + "_Emissive", Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits"));
Sprite customImage3 = GetCustomImageClass.GetCustomImage("Empty", Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\RESERVED-Portraits"));
Logger.Log("DisplayFacePrepatch", "Info", "Setting Head to Portrait.");
__instance.head.sprite = customImage;
Logger.Log("DisplayFacePrepatch", "Info", "Setting Mouth to Empty (its in the portrait already).");
__instance.mouth.sprite = customImage3;
Logger.Log("DisplayFacePrepatch", "Info", "Setting mouth local position back to Vector2.zero");
((Component)__instance.mouth).transform.localPosition = Vector2.op_Implicit(Vector2.zero);
Logger.Log("DisplayFacePrepatch", "Info", "Setting Eyes to Empty (its in the portrait already).");
__instance.eyes.sprite = customImage3;
Logger.Log("DisplayFacePrepatch", "Info", "Setting eyes local position back to Vector2.zero");
((Component)__instance.eyes).transform.localPosition = Vector2.op_Implicit(Vector2.zero);
Logger.Log("DisplayFacePrepatch", "Info", "Setting EyeEmission to Emission.");
__instance.eyesEmission.sprite = customImage2;
Logger.Log("DisplayFacePrepatch", "Info", "Setting EyeBlocker off (its in the portrait and emission already).");
__instance.eyeBlocker.SetActive(false);
return false;
}
return true;
}
}
public class SaveFilePatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(GameProgressConfig), "SetPhase")]
public static void PostfixSetPhase(GamePhase phase)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
if (BasicConfiguration.enableDeathcardReplacement.Value && ((int)phase == 0 || (int)phase == 3 || (int)phase == 9))
{
string fullPath = Path.GetFullPath(Path.GetFullPath(TextureReplacer.ConfigPath + "\\Deathcards\\" + BasicConfiguration.deathcardSystem.Value) + "\\RESERVED-Saves.csv");
if (File.Exists(fullPath))
{
Logger.Log("PostfixInitializeStarterDeckAndItems", "Info", "Wiping saved deathcard portraits");
File.Delete(fullPath);
StreamWriter streamWriter = new StreamWriter(fullPath, append: false);
streamWriter.WriteLine("name,attack,health,abilities[],blood,bones,statIcon,specialAbilities[],lostEye,portrait,emission");
streamWriter.Close();
LoadSaves.Load();
}
}
}
}
}
namespace TextureReplacer.Configuration
{
public static class BasicConfiguration
{
public static ConfigFile Config;
public static ConfigEntry<bool> enableDeathcardReplacement;
public static ConfigEntry<string> deathcardSystem;
public static void Init()
{
enableDeathcardReplacement = Config.Bind<bool>("Modules", "Deathcards Module", true, "Should the deathcards module be enabled. This should be changeable within the game.");
deathcardSystem = Config.Bind<string>("Deathcards", "Portrait System", "Base-Game", "Set the mode for Texture Replacer to use for handling portraits. For options check Config/TextureReplacer/Deathcards and choose a folder name anything prefixed with RESERVED may not be used. This should be changeable within the game.");
ReloadClass.Initialize(ReloadDeathcardsClass.ReloadDeathcards, new ConfigEntry<string>[1] { deathcardSystem });
ReloadClass.Initialize(ReloadDeathcardsClass.ReloadDeathcards, new ConfigEntry<bool>[1] { enableDeathcardReplacement });
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}