Decompiled source of Arab Viking v2.0.0

plugins/ArabViking.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
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("ArabViking")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+2241dc7d89e7104b02ee82435e9efbb197752e7b")]
[assembly: AssemblyProduct("ArabViking")]
[assembly: AssemblyTitle("ArabViking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 ArabViking
{
	[BepInPlugin("ArabViking_ArabViking", "ArabViking", "2.0.0")]
	public class Main : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(FejdStartup), "SetupGui")]
		public static class MainMenuPatch
		{
			public static void Postfix()
			{
				if (hideTextureButtons.Value)
				{
					try
					{
						((Component)((Component)FejdStartup.instance).transform.Find("Menu/TopRight/StartGui_MerchButton")).gameObject.SetActive(false);
						((Component)((Component)FejdStartup.instance).transform.Find("Menu/TopRight/StartGui_BoardgameButton")).gameObject.SetActive(false);
						((Component)((Component)FejdStartup.instance).transform.Find("Menu/Canvas Changelog/ChangeLog")).gameObject.SetActive(false);
					}
					catch (Exception ex)
					{
						log.LogError((object)ex);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateBuild")]
		public static class BuildHudPatch
		{
			public static void Postfix(Player player, bool forceUpdateAllBuildStatuses)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					Hud instance = Hud.instance;
					if (!((Character)player).InPlaceMode())
					{
						return;
					}
					Piece val = default(Piece);
					Vector2Int val2 = default(Vector2Int);
					int num = default(int);
					PieceCategory val3 = default(PieceCategory);
					PieceTable val4 = default(PieceTable);
					player.GetBuildSelection(ref val, ref val2, ref num, ref val3, ref val4);
					if (!instance.m_pieceSelectionWindow.activeSelf)
					{
						return;
					}
					instance.UpdatePieceList(player, val2, val3, forceUpdateAllBuildStatuses);
					instance.m_pieceCategoryRoot.SetActive(val4.m_categories.Count > 0);
					if (val4.m_categories.Count > 0)
					{
						for (int i = 0; i < instance.m_pieceCategoryTabs.Length; i++)
						{
							GameObject val5 = instance.m_pieceCategoryTabs[i];
							Transform val6 = val5.transform.Find("Selected");
							bool flag = i < val4.m_categories.Count;
							val5.SetActive(flag);
							if (flag)
							{
								string text = $"{val4.m_categoryLabels[i]} [<color=yellow>{player.GetAvailableBuildPiecesInCategory(val4.m_categories[i])}</color>]";
								if (val4.m_categories[i] == val3)
								{
									((Component)val6).gameObject.SetActive(true);
									((TMP_Text)((Component)val6).GetComponentInChildren<TextMeshProUGUI>()).overflowMode = (TextOverflowModes)0;
									((TMP_Text)((Component)val6).GetComponentInChildren<TextMeshProUGUI>()).text = text;
								}
								else
								{
									((Component)val6).gameObject.SetActive(false);
									((TMP_Text)val5.GetComponentInChildren<TextMeshProUGUI>()).overflowMode = (TextOverflowModes)0;
									((TMP_Text)val5.GetComponentInChildren<TextMeshProUGUI>()).text = text;
								}
							}
						}
					}
					Localization.instance.Localize(instance.m_buildHud.transform);
				}
				catch (Exception ex)
				{
					log.LogError((object)ex);
				}
			}
		}

		public const string MODNAME = "ArabViking";

		public const string AUTHOR = "ArabViking";

		public const string GUID = "ArabViking_ArabViking";

		public const string VERSION = "2.0.0";

		internal static ManualLogSource log;

		internal static Harmony harmony;

		internal static Assembly assembly;

		internal static ConfigEntry<bool> hideTextureButtons;

		public void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			harmony = new Harmony("ArabViking_ArabViking");
			assembly = Assembly.GetExecutingAssembly();
			log = ((BaseUnityPlugin)this).Logger;
		}

		public void Start()
		{
			harmony.PatchAll(assembly);
			log.LogInfo((object)" بيرعتلا ةادأ ليمحت مت ");
			log.LogInfo((object)" رادصإ : 2.0.0");
			hideTextureButtons = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Hide Texture Buttons", true, "Toggle whether to use custom huds or not.");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ArabViking";

		public const string PLUGIN_NAME = "ArabViking";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}