Decompiled source of ShowFollowerJobTitles v1.0.0

plugins/ShowFollowerJobTitles.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Lamb.UI.FollowerInteractionWheel;
using Microsoft.CodeAnalysis;
using ShowFollowerJobTitles.Common.Extensions;
using TMPro;
using UnityEngine;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ShowFollowerJobTitles")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e8041537feffb919582e71c73954819793677447")]
[assembly: AssemblyProduct("ShowFollowerJobTitles")]
[assembly: AssemblyTitle("ShowFollowerJobTitles")]
[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 ShowFollowerJobTitles
{
	[BepInPlugin("com.f4iTh.COTL.ShowFollowerJobTitles", "Show Follower Job Titles", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.f4iTh.COTL.ShowFollowerJobTitles");

		private void Awake()
		{
		}

		private void OnEnable()
		{
			_harmony.PatchAll();
		}

		private void OnDisable()
		{
			_harmony.UnpatchSelf();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ShowFollowerJobTitles";

		public const string PLUGIN_NAME = "ShowFollowerJobTitles";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ShowFollowerJobTitles.Common.Patches
{
	[HarmonyPatch]
	public class FollowerInformationBoxPatches
	{
		private static MethodBase TargetMethod()
		{
			return typeof(FollowerInformationBox).GetMethod("ConfigureImpl", BindingFlags.Instance | BindingFlags.NonPublic);
		}

		[HarmonyPostfix]
		public static void ConfigureImpl(FollowerInformationBox __instance)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance.FollowerRole == (Object)null) && !((FollowerSelectItem)__instance).FollowerInfo.OldAge && !((FollowerSelectItem)__instance).FollowerInfo.HasThought((Thought)146))
			{
				string text = FontImageNames.IconForRole(__instance.followBrain.Info.FollowerRole);
				if (!string.IsNullOrWhiteSpace(text))
				{
					TextMeshProUGUI followerRole = __instance.FollowerRole;
					((TMP_Text)followerRole).text = ((TMP_Text)followerRole).text + " | " + text;
				}
			}
		}
	}
	[HarmonyPatch]
	public class NotificationFollowerPatches
	{
		private static MethodBase TargetMethod()
		{
			return typeof(NotificationFollower).GetMethod("Localize", BindingFlags.Instance | BindingFlags.NonPublic);
		}

		[HarmonyPostfix]
		public static void Localize(NotificationFollower __instance)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Invalid comparison between Unknown and I4
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			FieldInfo field = typeof(NotificationFollower).GetField("_description", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = typeof(NotificationFollower).GetField("_followerInfo", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field3 = typeof(NotificationFollower).GetField("_type", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null || field2 == null || field3 == null)
			{
				return;
			}
			FollowerInfo val = (FollowerInfo)field2.GetValue(__instance);
			TextMeshProUGUI val2 = (TextMeshProUGUI)field.GetValue(__instance);
			NotificationType val3 = (NotificationType)field3.GetValue(__instance);
			if ((int)val3 == 46 && !((Object)(object)val2 == (Object)null))
			{
				string text = FontImageNames.IconForRole(val.FollowerRole);
				if (!string.IsNullOrWhiteSpace(text))
				{
					((TMP_Text)val2).text = ((TMP_Text)val2).text + " (" + text + ")";
				}
			}
		}
	}
	[HarmonyPatch]
	public class UIFollowerNamePatches
	{
		private static MethodBase TargetMethod()
		{
			return typeof(UIFollowerName).GetMethod("SetText", BindingFlags.Instance | BindingFlags.NonPublic);
		}

		[HarmonyPostfix]
		public static void SetText(UIFollowerName __instance)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			FieldInfo field = typeof(UIFollowerName).GetField("nameText", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = typeof(UIFollowerName).GetField("follower", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null || field2 == null)
			{
				return;
			}
			TMP_Text val = (TMP_Text)field.GetValue(__instance);
			Follower val2 = (Follower)field2.GetValue(__instance);
			string text = FontImageNames.IconForRole(val2.Brain.Info.FollowerRole);
			int num = val.text.IndexOf(text, StringComparison.Ordinal);
			if (val2.Brain.Info.OldAge || val2.Brain.HasThought((Thought)146))
			{
				if (num > 0)
				{
					val.text = val.text.Remove(num, text.Length - 1);
				}
			}
			else if (!string.IsNullOrWhiteSpace(text) && num <= 0)
			{
				val.text = val.text + " (" + text + ")";
			}
		}
	}
	[HarmonyPatch]
	public class UIFollowerWheelInteractionItemPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIFollowerWheelInteractionItem), "Configure")]
		public static void Configure(UIFollowerWheelInteractionItem __instance, ref Follower follower, ref CommandItem commandItem)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Invalid comparison between Unknown and I4
			if (commandItem == null || !commandItem.Command.IsFollowerRoleCommand())
			{
				return;
			}
			FieldInfo field = typeof(UIFollowerWheelInteractionItem).GetField("_title", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = typeof(UIFollowerWheelInteractionItem).GetField("_text", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null || field2 == null)
			{
				return;
			}
			FollowerRole followerRole = commandItem.Command.FollowerCommandToRole();
			int num = DataManager.Instance.Followers.Count((FollowerInfo followerInfo) => followerInfo.FollowerRole == followerRole);
			string arg = (string)field.GetValue(__instance);
			TextMeshProUGUI val = (TextMeshProUGUI)field2.GetValue(__instance);
			if (followerRole == follower.Brain.Info.FollowerRole)
			{
				if (commandItem.IsAvailable(follower))
				{
					((TMP_Text)val).text = "<color=yellow>" + ((TMP_Text)val).text + "</color>";
				}
				field.SetValue(__instance, $"<color=yellow>{arg} ({num})</color>");
			}
			else if (!commandItem.IsAvailable(follower))
			{
				field.SetValue(__instance, string.Format("{0} ({1}{2})", arg, num, ((int)followerRole == 6) ? "" : " + 1"));
			}
			else
			{
				field.SetValue(__instance, $"{arg} ({num} + 1)");
			}
		}
	}
}
namespace ShowFollowerJobTitles.Common.Extensions
{
	public static class FollowerCommandsExtensions
	{
		public static bool IsFollowerRoleCommand(this FollowerCommands followerCommand)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			if ((int)followerCommand <= 42)
			{
				if ((int)followerCommand <= 17)
				{
					if (followerCommand - 14 <= 1 || (int)followerCommand == 17)
					{
						goto IL_005a;
					}
				}
				else if (followerCommand - 27 <= 1 || (int)followerCommand == 30 || (int)followerCommand == 42)
				{
					goto IL_005a;
				}
			}
			else if ((int)followerCommand <= 58)
			{
				if ((int)followerCommand == 47 || (int)followerCommand == 58)
				{
					goto IL_005a;
				}
			}
			else if ((int)followerCommand == 64 || (int)followerCommand == 81 || (int)followerCommand == 88)
			{
				goto IL_005a;
			}
			return false;
			IL_005a:
			return true;
		}

		public static FollowerRole FollowerCommandToRole(this FollowerCommands followerCommand)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Invalid comparison between Unknown and I4
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected I4, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected I4, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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)
			if (1 == 0)
			{
			}
			FollowerRole result;
			if ((int)followerCommand <= 47)
			{
				if ((int)followerCommand <= 30)
				{
					switch (followerCommand - 14)
					{
					case 0:
						goto IL_0078;
					case 3:
						goto IL_0084;
					case 1:
						goto IL_008c;
					case 2:
						goto IL_00a8;
					}
					switch (followerCommand - 27)
					{
					case 0:
						break;
					case 1:
						goto IL_0088;
					case 3:
						goto IL_0090;
					default:
						goto IL_00a8;
					}
					result = (FollowerRole)0;
				}
				else if ((int)followerCommand != 42)
				{
					if ((int)followerCommand != 47)
					{
						goto IL_00a8;
					}
					result = (FollowerRole)3;
				}
				else
				{
					result = (FollowerRole)4;
				}
			}
			else if ((int)followerCommand <= 64)
			{
				if ((int)followerCommand != 58)
				{
					if ((int)followerCommand != 64)
					{
						goto IL_00a8;
					}
					result = (FollowerRole)10;
				}
				else
				{
					result = (FollowerRole)9;
				}
			}
			else if ((int)followerCommand != 81)
			{
				if ((int)followerCommand != 88)
				{
					goto IL_00a8;
				}
				result = (FollowerRole)13;
			}
			else
			{
				result = (FollowerRole)12;
			}
			goto IL_00ac;
			IL_0084:
			result = (FollowerRole)5;
			goto IL_00ac;
			IL_008c:
			result = (FollowerRole)7;
			goto IL_00ac;
			IL_0078:
			result = (FollowerRole)2;
			goto IL_00ac;
			IL_00ac:
			if (1 == 0)
			{
			}
			return result;
			IL_0090:
			result = (FollowerRole)8;
			goto IL_00ac;
			IL_0088:
			result = (FollowerRole)6;
			goto IL_00ac;
			IL_00a8:
			result = (FollowerRole)1;
			goto IL_00ac;
		}
	}
}