using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SimpleInjector;
using TrainworksReloaded.Base;
using TrainworksReloaded.Core;
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("Retouched-MT1-Clan-Logos")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+51d0c561b4b8923bf8f0ea693f30eecde378a0f4")]
[assembly: AssemblyProduct("Retouched-MT1-Clan-Logos")]
[assembly: AssemblyTitle("Retouched-MT1-Clan-Logos")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace Retouched_MT1_Clan_Logos
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "RetouchedMT1ClanLogos.Plugin";
public const string PLUGIN_NAME = "RetouchedMT1ClanLogos.Plugin";
public const string PLUGIN_VERSION = "1.0.1";
}
[BepInPlugin("RetouchedMT1ClanLogos.Plugin", "RetouchedMT1ClanLogos.Plugin", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
internal readonly string[] resources = new string[4] { "small", "medium", "large", "silhouette" };
private Dictionary<string, Texture2D>? _iconTextures;
private void Awake()
{
Railend.ConfigurePostAction((Action<Container>)delegate(Container c)
{
SaveManager val = default(SaveManager);
if (c.GetInstance<GameDataClient>().TryGetProvider<SaveManager>(ref val))
{
BalanceData balanceData = val.GetAllGameData().GetBalanceData();
FieldInfo fieldInfo = AccessTools.Field(typeof(ClassData), "icons");
{
foreach (ClassData classData in balanceData.GetClassDatas())
{
object icon = GetIcon(classData);
if (icon != null)
{
fieldInfo.SetValue(classData, icon);
}
}
return;
}
}
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get SaveManager instance");
});
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RetouchedMT1ClanLogos.Plugin is loaded!");
}
private object? GetIcon(ClassData classData)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
ClassCardStyle cardStyle = classData.GetCardStyle();
if (cardStyle - 1 > 5)
{
return null;
}
if (_iconTextures == null)
{
_iconTextures = LoadIconTextures();
}
object value = AccessTools.Field(typeof(ClassData), "icons").GetValue(classData);
Type iconSetType = AccessTools.Inner(typeof(ClassData), "IconSet");
Dictionary<string, FieldInfo> dictionary = resources.ToDictionary((string key) => key, (string text) => AccessTools.Field(iconSetType, text));
object obj = Activator.CreateInstance(iconSetType);
foreach (KeyValuePair<string, FieldInfo> item in dictionary)
{
object? value2 = item.Value.GetValue(value);
Sprite val = (Sprite)((value2 is Sprite) ? value2 : null);
if (val != null && _iconTextures.TryGetValue(item.Key, out Texture2D value3))
{
try
{
Sprite val2 = Sprite.Create(value3, val.rect, new Vector2(0.5f, 0.5f));
((Object)val2).name = $"Retouched {cardStyle} {item.Key}";
item.Value.SetValue(obj, val2);
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to create icon for [{cardStyle}: {item.Key}]");
((BaseUnityPlugin)this).Logger.LogError((object)ex);
}
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to get texture for [{cardStyle}: {item.Key}]");
}
}
return obj;
}
[Obsolete]
private Dictionary<string, object> GetIcons()
{
//IL_00fa: 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)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, object> dictionary = new Dictionary<string, object>();
Type iconSetType = AccessTools.Inner(typeof(ClassData), "IconSet");
Dictionary<string, FieldInfo> dictionary2 = resources.ToDictionary((string key) => key, (string value) => AccessTools.Field(iconSetType, value));
Dictionary<string, Texture2D> dictionary3 = LoadIconTextures();
(ClassCardStyle, string)[] array = new(ClassCardStyle, string)[5]
{
((ClassCardStyle)1, "ClassHellhorned"),
((ClassCardStyle)2, "ClassAwoken"),
((ClassCardStyle)3, "ClassRemnant"),
((ClassCardStyle)4, "ClassStygian"),
((ClassCardStyle)5, "ClassUmbra")
};
for (int num = 0; num < array.Length; num++)
{
object obj = Activator.CreateInstance(iconSetType);
dictionary.Add(array[num].Item2, obj);
ClassCardStyle item = array[num].Item1;
foreach (KeyValuePair<string, FieldInfo> item2 in dictionary2)
{
Rect val = default(Rect);
switch (item2.Key)
{
case "small":
((Rect)(ref val))..ctor((float)(48 * num), 48f, 48f, 48f);
break;
case "medium":
((Rect)(ref val))..ctor((float)(128 * num), 128f, 128f, 128f);
break;
case "large":
((Rect)(ref val))..ctor((float)(92 * num), 92f, 92f, 92f);
break;
case "silhouette":
((Rect)(ref val))..ctor(73.1429f * (float)num, 73f, 73.1429f, 73f);
break;
}
Sprite val2 = Sprite.Create(dictionary3[item2.Key], val, new Vector2(0.5f, 0.5f));
((Object)val2).name = $"Retouched {item} {item2.Key}";
item2.Value.SetValue(obj, val2);
}
}
return dictionary;
}
private Dictionary<string, Texture2D> LoadIconTextures()
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
Dictionary<string, Texture2D> dictionary = new Dictionary<string, Texture2D>();
for (int i = 0; i < resources.Length; i++)
{
string text = resources[i];
byte[] array = null;
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using (MemoryStream memoryStream = new MemoryStream())
{
executingAssembly.GetManifestResourceStream("Retouched_MT1_Clan_Logos.Resources." + text + ".png").CopyTo(memoryStream);
array = memoryStream.ToArray();
}
Texture2D val = new Texture2D(4, 4, (TextureFormat)((text == "medium") ? 12 : 4), false);
ImageConversion.LoadImage(val, array);
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).wrapModeU = (TextureWrapMode)1;
((Texture)val).wrapModeV = (TextureWrapMode)1;
((Texture)val).wrapModeW = (TextureWrapMode)1;
((Texture)val).filterMode = (FilterMode)1;
val.Apply(true, true);
((Object)val).name = "Retouched " + text;
dictionary.Add(text, val);
}
return dictionary;
}
}
}