Decompiled source of StartWithAspect v1.0.4

plugins/startWithAspects/StartWithAspect.dll

Decompiled a day ago
using System;
using System.Collections;
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 System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StartWithAspect")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1753192522cf8fad27e3ff43ebbb30f80c2610c6")]
[assembly: AssemblyProduct("StartWithAspect")]
[assembly: AssemblyTitle("StartWithAspect")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 StartWithAspect
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("virgile.StartWithAspect", "StartWithAspect", "1.0.4")]
	public class ExamplePlugin : BaseUnityPlugin
	{
		public class SetAspectMessage : INetMessage, ISerializableObject
		{
			private NetworkInstanceId userNetId;

			private string aspectName;

			public SetAspectMessage()
			{
			}

			public SetAspectMessage(NetworkInstanceId id, string name)
			{
				//IL_0009: 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)
				userNetId = id;
				aspectName = name ?? "";
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(userNetId);
				writer.Write(aspectName ?? "");
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				userNetId = reader.ReadNetworkId();
				aspectName = reader.ReadString();
			}

			public void OnReceived()
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active)
				{
					aspectByUser[userNetId] = aspectName ?? "";
				}
			}
		}

		public const string PluginGUID = "virgile.StartWithAspect";

		public const string PluginAuthor = "virgile";

		public const string PluginName = "StartWithAspect";

		public const string PluginVersion = "1.0.4";

		private static ConfigEntry<string> chosenAspect;

		private static readonly HashSet<CharacterMaster> grantedThisRun = new HashSet<CharacterMaster>();

		private static readonly Dictionary<NetworkInstanceId, string> aspectByUser = new Dictionary<NetworkInstanceId, string>();

		private static readonly Dictionary<string, ConfigEntry<bool>> aspectEnabled = new Dictionary<string, ConfigEntry<bool>>();

		private static bool zetChecked;

		private static Type zetCatalogType;

		private static readonly HashSet<string> excludedAspects = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "EliteSecretSpeedEquipment" };

		private static readonly List<KeyValuePair<GameObject, string>> aspectButtons = new List<KeyValuePair<GameObject, string>>();

		private static GameObject cachedRowTemplate;

		public void Awake()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			chosenAspect = ((BaseUnityPlugin)this).Config.Bind<string>("Aspect", "Aspect de depart", "", "Nom interne de l'aspect a donner au debut de la partie (ex: EliteFireEquipment). Laisse vide pour n'en donner aucun. La liste exacte des noms valides est affichee dans la console BepInEx au lancement d'une partie.");
			Run.onRunStartGlobal += OnRunStart;
			CharacterMaster.OnBodyStart += new hook_OnBodyStart(OnBodyStart);
			LoadoutPanelController.Rebuild += new hook_Rebuild(OnLoadoutRebuild);
			NetworkingAPI.RegisterMessageType<SetAspectMessage>();
			CharacterSelectController.Awake += new hook_Awake(OnCharacterSelectAwake);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(InitAspectToggles));
			Log.Info("StartWithAspect v1.0.4 charge !", "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 89);
		}

		private void OnRunStart(Run run)
		{
			grantedThisRun.Clear();
			LogAvailableAspects();
		}

		private void OnBodyStart(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, body);
			if (!NetworkServer.active || (Object)(object)self == (Object)null || (Object)(object)self.playerCharacterMasterController == (Object)null || grantedThisRun.Contains(self))
			{
				return;
			}
			string choiceForMaster = GetChoiceForMaster(self);
			EquipmentIndex val = FindAspectByName(choiceForMaster);
			if ((int)val != -1 && (Object)(object)self.inventory != (Object)null)
			{
				if (TryGetZetAspectItem(val, out var item))
				{
					self.inventory.GiveItem(item, 1);
					Log.Info("Aspect '" + choiceForMaster + "' donne en objet (ZetAspects).", "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 131);
				}
				else
				{
					self.inventory.SetEquipmentIndex(val);
					Log.Info("Aspect '" + choiceForMaster + "' donne en equipement.", "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 136);
				}
				grantedThisRun.Add(self);
			}
		}

		private static bool TryGetZetAspectItem(EquipmentIndex equip, out ItemIndex item)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected I4, but got Unknown
			item = (ItemIndex)(-1);
			if (!zetChecked)
			{
				zetChecked = true;
				zetCatalogType = FindType("TPDespair.ZetAspects.Catalog");
				if (zetCatalogType != null)
				{
					Log.Info("ZetAspects detecte : les aspects seront donnes en objets.", "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 159);
				}
			}
			if (zetCatalogType == null)
			{
				return false;
			}
			FieldInfo field = zetCatalogType.GetField("equipToItem", BindingFlags.Static | BindingFlags.Public);
			if (field == null)
			{
				return false;
			}
			if (!(field.GetValue(null) is IDictionary dictionary) || !dictionary.Contains(equip))
			{
				return false;
			}
			item = (ItemIndex)(int)(ItemIndex)dictionary[equip];
			return (int)item != -1;
		}

		private static Type FindType(string fullName)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				Type type = assembly.GetType(fullName);
				if (type != null)
				{
					return type;
				}
			}
			return null;
		}

		private static NetworkUser GetNetworkUser(CharacterMaster master)
		{
			if ((Object)(object)master == (Object)null)
			{
				return null;
			}
			foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
			{
				if ((Object)(object)readOnlyInstances != (Object)null && (Object)(object)readOnlyInstances.master == (Object)(object)master)
				{
					return readOnlyInstances;
				}
			}
			return null;
		}

		private static string GetChoiceForMaster(CharacterMaster master)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			NetworkUser networkUser = GetNetworkUser(master);
			if ((Object)(object)networkUser != (Object)null && aspectByUser.TryGetValue(((NetworkBehaviour)networkUser).netId, out var value) && !string.IsNullOrEmpty(value))
			{
				return value;
			}
			if ((Object)(object)networkUser != (Object)null && ((NetworkBehaviour)networkUser).isLocalPlayer)
			{
				return chosenAspect.Value;
			}
			return "";
		}

		private static IEnumerable<EquipmentDef> GetAllAspectsRaw()
		{
			for (int i = 0; i < EquipmentCatalog.equipmentCount; i++)
			{
				EquipmentDef def = EquipmentCatalog.GetEquipmentDef((EquipmentIndex)i);
				if ((Object)(object)def != (Object)null && (Object)(object)def.passiveBuffDef != (Object)null && def.passiveBuffDef.isElite && !excludedAspects.Contains(((Object)def).name))
				{
					yield return def;
				}
			}
		}

		private static IEnumerable<EquipmentDef> GetAllAspects()
		{
			foreach (EquipmentDef def in GetAllAspectsRaw())
			{
				if (IsAspectEnabled(((Object)def).name))
				{
					yield return def;
				}
			}
		}

		private static bool IsAspectEnabled(string internalName)
		{
			ConfigEntry<bool> value;
			return !aspectEnabled.TryGetValue(internalName, out value) || value.Value;
		}

		private void InitAspectToggles()
		{
			foreach (EquipmentDef item in GetAllAspectsRaw())
			{
				if (!((Object)(object)item == (Object)null) && !aspectEnabled.ContainsKey(((Object)item).name))
				{
					string text = Language.GetString(item.nameToken);
					if (string.IsNullOrEmpty(text) || text == item.nameToken)
					{
						text = ((Object)item).name;
					}
					string text2 = SanitizeConfigKey(text);
					ConfigEntry<bool> value = ((BaseUnityPlugin)this).Config.Bind<bool>("Aspects", text2, true, "Show '" + text + "' in the aspect selector. Uncheck to hide it.");
					aspectEnabled[((Object)item).name] = value;
				}
			}
			SetupRiskOfOptions();
			Log.Info($"{aspectEnabled.Count} aspect toggle(s) created.", "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 275);
		}

		private void SetupRiskOfOptions()
		{
			try
			{
				Type type = FindType("RiskOfOptions.Options.CheckBoxOption");
				Type type2 = FindType("RiskOfOptions.ModSettingsManager");
				if (type == null || type2 == null)
				{
					return;
				}
				ConstructorInfo constructor = type.GetConstructor(new Type[1] { typeof(ConfigEntry<bool>) });
				MethodInfo methodInfo = type2.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "AddOption" && m.GetParameters().Length == 1);
				if (constructor == null || methodInfo == null)
				{
					Log.Warning("Risk of Options: expected API not found.", "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 294);
					return;
				}
				foreach (ConfigEntry<bool> value in aspectEnabled.Values)
				{
					object obj = constructor.Invoke(new object[1] { value });
					methodInfo.Invoke(null, new object[1] { obj });
				}
				Log.Info("Risk of Options: aspect toggles added to the menu.", "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 304);
			}
			catch (Exception ex)
			{
				Log.Warning("Risk of Options: integration failed: " + ex, "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 308);
			}
		}

		private static string SanitizeConfigKey(string s)
		{
			char[] array = new char[8] { '=', '\n', '\t', '\\', '"', '\'', '[', ']' };
			foreach (char c in array)
			{
				s = s.Replace(c.ToString(), "");
			}
			return s.Trim();
		}

		private static EquipmentIndex FindAspectByName(string wanted)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			wanted = wanted?.Trim();
			if (string.IsNullOrEmpty(wanted))
			{
				return (EquipmentIndex)(-1);
			}
			foreach (EquipmentDef allAspect in GetAllAspects())
			{
				string text = ((Object)allAspect).name ?? "";
				string text2 = Language.GetString(allAspect.nameToken) ?? "";
				if (text.Equals(wanted, StringComparison.OrdinalIgnoreCase) || text2.Equals(wanted, StringComparison.OrdinalIgnoreCase))
				{
					return allAspect.equipmentIndex;
				}
			}
			Log.Warning("Aspect '" + wanted + "' introuvable. Verifie l'orthographe (liste dans la console).", "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 339);
			return (EquipmentIndex)(-1);
		}

		private void OnCharacterSelectAwake(orig_Awake orig, CharacterSelectController self)
		{
			orig.Invoke(self);
			((MonoBehaviour)this).StartCoroutine(SendMyChoiceWhenReady());
		}

		private IEnumerator SendMyChoiceWhenReady()
		{
			float t = 0f;
			while (t < 5f)
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				NetworkUser nu = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
				if ((Object)(object)nu != (Object)null)
				{
					break;
				}
				t += Time.deltaTime;
				yield return null;
			}
			SendMyChoice();
		}

		private static void SendMyChoice()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
				if (!((Object)(object)val == (Object)null))
				{
					NetMessageExtensions.Send((INetMessage)(object)new SetAspectMessage(((NetworkBehaviour)val).netId, chosenAspect.Value ?? ""), (NetworkDestination)2);
				}
			}
			catch (Exception ex)
			{
				Log.Warning("Envoi du choix d'aspect echoue : " + ex, "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 385);
			}
		}

		private void OnLoadoutRebuild(orig_Rebuild orig, LoadoutPanelController self)
		{
			orig.Invoke(self);
			try
			{
				AddAspectRow(self);
			}
			catch (Exception ex)
			{
				Log.Warning("Ajout de la ligne Aspect echoue : " + ex, "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 451);
			}
		}

		private void AddAspectRow(LoadoutPanelController self)
		{
			//IL_01a7: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			if ((Object)(object)self == (Object)null)
			{
				return;
			}
			Transform val = ((Component)self).transform.Find("AspectRow");
			while ((Object)(object)val != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
				val = ((Component)self).transform.Find("AspectRow");
			}
			if ((Object)(object)cachedRowTemplate == (Object)null)
			{
				Transform val2 = null;
				foreach (Transform item in ((Component)self).transform)
				{
					Transform val3 = item;
					if (((Object)val3).name.StartsWith("Row") && ((Component)val3).gameObject.activeInHierarchy)
					{
						val2 = val3;
						break;
					}
				}
				if ((Object)(object)val2 == (Object)null)
				{
					return;
				}
				cachedRowTemplate = Object.Instantiate<GameObject>(((Component)val2).gameObject);
				((Object)cachedRowTemplate).name = "AspectRowTemplate";
				cachedRowTemplate.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)cachedRowTemplate);
			}
			GameObject val4 = Object.Instantiate<GameObject>(cachedRowTemplate, ((Component)self).transform);
			val4.SetActive(true);
			((Object)val4).name = "AspectRow";
			val4.transform.SetAsLastSibling();
			LayoutElement val5 = val4.GetComponent<LayoutElement>();
			if ((Object)(object)val5 == (Object)null)
			{
				val5 = val4.AddComponent<LayoutElement>();
			}
			val5.minHeight = 80f;
			val5.preferredHeight = 80f;
			val5.flexibleHeight = 0f;
			val5.ignoreLayout = false;
			RectTransform component = val4.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(component.sizeDelta.x, 80f);
			Canvas[] componentsInChildren = val4.GetComponentsInChildren<Canvas>(true);
			foreach (Canvas val6 in componentsInChildren)
			{
				val6.overrideSorting = false;
			}
			RefreshCanvasDrawOrder[] componentsInChildren2 = val4.GetComponentsInChildren<RefreshCanvasDrawOrder>(true);
			foreach (RefreshCanvasDrawOrder val7 in componentsInChildren2)
			{
				((Behaviour)val7).enabled = false;
			}
			Transform val8 = val4.transform.Find("SlotLabel");
			if ((Object)(object)val8 != (Object)null)
			{
				LanguageTextMeshController component2 = ((Component)val8).GetComponent<LanguageTextMeshController>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Behaviour)component2).enabled = false;
				}
				HGTextMeshProUGUI component3 = ((Component)val8).GetComponent<HGTextMeshProUGUI>();
				if ((Object)(object)component3 != (Object)null)
				{
					((TMP_Text)component3).text = "ASPECT";
					((Graphic)component3).color = Color.white;
				}
			}
			Transform val9 = val4.transform.Find("ButtonContainer");
			if ((Object)(object)val9 == (Object)null)
			{
				return;
			}
			Transform val10 = val9.Find("Spacer");
			List<Transform> list = new List<Transform>();
			foreach (Transform item2 in val9)
			{
				Transform val11 = item2;
				if (((Object)val11).name.Contains("LoadoutButton"))
				{
					list.Add(val11);
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			Transform template = list[0];
			aspectButtons.Clear();
			CreateAspectButton(val9, template, null);
			foreach (EquipmentDef allAspect in GetAllAspects())
			{
				CreateAspectButton(val9, template, allAspect);
			}
			foreach (Transform item3 in list)
			{
				Object.Destroy((Object)(object)((Component)item3).gameObject);
			}
			if ((Object)(object)val10 != (Object)null)
			{
				val10.SetAsLastSibling();
			}
			ApplyHighlight();
			Transform transform = ((Component)self).transform;
			LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((transform is RectTransform) ? transform : null));
		}

		private void CreateAspectButton(Transform container, Transform template, EquipmentDef aspect)
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, container);
			((Object)val).name = "AspectBtn";
			val.SetActive(true);
			LayoutElement component = val.GetComponent<LayoutElement>();
			if ((Object)(object)component != (Object)null)
			{
				component.preferredWidth = 48f;
				component.preferredHeight = 48f;
				component.minWidth = 48f;
				component.minHeight = 48f;
			}
			string key = (((Object)(object)aspect == (Object)null) ? "" : ((Object)aspect).name);
			Image component2 = val.GetComponent<Image>();
			if ((Object)(object)component2 != (Object)null)
			{
				if ((Object)(object)aspect != (Object)null)
				{
					component2.sprite = aspect.pickupIconSprite;
					((Graphic)component2).color = Color.white;
				}
				else
				{
					component2.sprite = null;
					((Graphic)component2).color = new Color(0.12f, 0.12f, 0.12f, 1f);
				}
			}
			TooltipProvider component3 = val.GetComponent<TooltipProvider>();
			if ((Object)(object)component3 != (Object)null)
			{
				string text;
				string value;
				string value2;
				string value3;
				if ((Object)(object)aspect != (Object)null)
				{
					text = aspect.nameToken;
					value = aspect.pickupToken;
					value2 = Language.GetString(text);
					value3 = ResolveFirst(aspect.pickupToken, aspect.descriptionToken);
					if (string.IsNullOrEmpty(value3))
					{
						value3 = "Aspect d'elite.";
					}
				}
				else
				{
					text = (value = "");
					value2 = "Aucun aspect";
					value3 = "Commencer la partie sans aspect.";
				}
				SetStringField(component3, "titleToken", text);
				SetStringField(component3, "bodyToken", value);
				SetStringField(component3, "overrideTitleText", value2);
				SetStringField(component3, "overrideBodyText", value3);
			}
			HGButton component4 = val.GetComponent<HGButton>();
			if ((Object)(object)component4 != (Object)null)
			{
				((Button)component4).onClick = new ButtonClickedEvent();
				((UnityEvent)((Button)component4).onClick).AddListener((UnityAction)delegate
				{
					chosenAspect.Value = key;
					ApplyHighlight();
					SendMyChoice();
				});
			}
			aspectButtons.Add(new KeyValuePair<GameObject, string>(val, key));
		}

		private static string ResolveFirst(params string[] tokens)
		{
			foreach (string text in tokens)
			{
				if (!string.IsNullOrEmpty(text))
				{
					string text2 = Language.GetString(text);
					if (!string.IsNullOrEmpty(text2) && text2 != "???" && text2 != text)
					{
						return text2;
					}
				}
			}
			return "";
		}

		private static void SetStringField(object obj, string fieldName, string value)
		{
			FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public);
			if (field != null && field.FieldType == typeof(string))
			{
				field.SetValue(obj, value);
			}
		}

		private void ApplyHighlight()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			string text = (chosenAspect.Value ?? "").Trim();
			foreach (KeyValuePair<GameObject, string> aspectButton in aspectButtons)
			{
				if (!((Object)(object)aspectButton.Key == (Object)null))
				{
					bool flag = string.Equals(aspectButton.Value, text, StringComparison.OrdinalIgnoreCase) || (string.IsNullOrEmpty(text) && string.IsNullOrEmpty(aspectButton.Value));
					Image component = aspectButton.Key.GetComponent<Image>();
					if ((Object)(object)component != (Object)null)
					{
						Color color = ((Graphic)component).color;
						color.a = (flag ? 1f : 0.4f);
						((Graphic)component).color = color;
					}
					aspectButton.Key.transform.localScale = (flag ? (Vector3.one * 1.1f) : Vector3.one);
				}
			}
		}

		private static void LogAvailableAspects()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("=== Aspects disponibles (recopie un de ces noms dans la config) ===");
			foreach (EquipmentDef allAspect in GetAllAspects())
			{
				string text = Language.GetString(allAspect.nameToken);
				stringBuilder.AppendLine("  - " + ((Object)allAspect).name + "    (" + text + ")");
			}
			Log.Info(stringBuilder.ToString(), "C:\\modRiskRain\\startWithAspect\\ExamplePlugin\\ExamplePlugin.cs", 722);
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
}