Decompiled source of Retouched MT1 Clan Logos v1.0.0

Retouched-MT1-Clan-Logos.dll

Decompiled a week ago
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+8ee37f8ac74de4260aac2244d1d7187713a324ca")]
[assembly: AssemblyProduct("Retouched-MT1-Clan-Logos")]
[assembly: AssemblyTitle("Retouched-MT1-Clan-Logos")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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.0";
	}
	[BepInPlugin("RetouchedMT1ClanLogos.Plugin", "RetouchedMT1ClanLogos.Plugin", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal readonly string[] resources = new string[4] { "small", "medium", "large", "silhouette" };

		private void Awake()
		{
			Dictionary<string, object> iconDict = GetIcons();
			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");
					Dictionary<string, object> dictionary = iconDict;
					{
						foreach (ClassData classData in balanceData.GetClassDatas())
						{
							if (dictionary.TryGetValue(((Object)classData).name, out var value))
							{
								fieldInfo.SetValue(classData, value);
							}
						}
						return;
					}
				}
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get SaveManager instance");
			});
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RetouchedMT1ClanLogos.Plugin is loaded!");
		}

		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 i = 0; i < array.Length; i++)
			{
				object obj = Activator.CreateInstance(iconSetType);
				dictionary.Add(array[i].Item2, obj);
				ClassCardStyle item = array[i].Item1;
				foreach (KeyValuePair<string, FieldInfo> item2 in dictionary2)
				{
					Rect val = default(Rect);
					switch (item2.Key)
					{
					case "small":
						((Rect)(ref val))..ctor((float)(48 * i), 48f, 48f, 48f);
						break;
					case "medium":
						((Rect)(ref val))..ctor((float)(128 * i), 128f, 128f, 128f);
						break;
					case "large":
						((Rect)(ref val))..ctor((float)(92 * i), 92f, 92f, 92f);
						break;
					case "silhouette":
						((Rect)(ref val))..ctor(73.1429f * (float)i, 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;
		}
	}
}