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 BepInEx.Logging;
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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShowFollowerJobTitles")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod that displays a follower's current job with its respective icon.")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+73c7de6809ae80f45719317fcf784dc68e37464c")]
[assembly: AssemblyProduct("ShowFollowerJobTitles")]
[assembly: AssemblyTitle("ShowFollowerJobTitles")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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.1.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource StaticLogger;
private readonly Harmony _harmony = new Harmony("com.f4iTh.COTL.ShowFollowerJobTitles");
private void Awake()
{
StaticLogger = ((BaseUnityPlugin)this).Logger;
}
private void OnEnable()
{
_harmony.PatchAll();
foreach (MethodBase patchedMethod in _harmony.GetPatchedMethods())
{
StaticLogger.LogInfo((object)("patched " + patchedMethod.ReflectedType?.Name + "::" + patchedMethod.Name));
}
}
private void OnDisable()
{
_harmony.UnpatchSelf();
}
}
}
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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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) && (int)((FollowerSelectItem)__instance).FollowerInfo.CursedState != 392)
{
FollowerBrain followBrain = __instance.followBrain;
string iconForRole = ((followBrain != null) ? followBrain.Info.FollowerRole : ((FollowerSelectItem)__instance).FollowerInfo.FollowerRole).GetIconForRole();
if (!string.IsNullOrWhiteSpace(iconForRole))
{
TextMeshProUGUI followerRole = __instance.FollowerRole;
((TMP_Text)followerRole).text = ((TMP_Text)followerRole).text + " | " + iconForRole;
}
}
}
}
[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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Invalid comparison between Unknown and I4
//IL_0098: 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);
if ((int)(NotificationType)field3.GetValue(__instance) == 46 && !((Object)(object)val2 == (Object)null))
{
string iconForRole = val.FollowerRole.GetIconForRole();
if (!string.IsNullOrWhiteSpace(iconForRole))
{
((TMP_Text)val2).text = ((TMP_Text)val2).text + " (" + iconForRole + ")";
}
}
}
}
[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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0066: 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_0097: Invalid comparison between Unknown and I4
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Invalid comparison between Unknown and I4
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 iconForRole = val2.Brain.Info.FollowerRole.GetIconForRole();
int num = val.text.IndexOf(iconForRole, StringComparison.Ordinal);
if ((int)val2.Brain.Info.CursedState == 146 || val2.Brain.HasThought((Thought)146) || (int)val2.Brain.Info.CursedState == 392)
{
if (num > 0)
{
val.text = val.text.Remove(num, iconForRole.Length - 1);
}
}
else if (!string.IsNullOrWhiteSpace(iconForRole) && num <= 0)
{
val.text = val.text + " (" + iconForRole + ")";
}
}
}
[HarmonyPatch]
public class UIFollowerWheelInteractionItemPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(UIFollowerWheelInteractionItem), "Configure", new Type[]
{
typeof(Follower),
typeof(CommandItem)
})]
public static void Configure(UIFollowerWheelInteractionItem __instance, ref Follower follower, ref CommandItem commandItem)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: 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_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Invalid comparison between Unknown and I4
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Invalid comparison between Unknown and I4
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Invalid comparison between Unknown and I4
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
//IL_000a: 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: Invalid comparison between Unknown and I4
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Invalid comparison between Unknown and I4
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Invalid comparison between Unknown and I4
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Invalid comparison between Unknown and I4
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Invalid comparison between Unknown and I4
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Invalid comparison between Unknown and I4
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Invalid comparison between Unknown and I4
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Invalid comparison between Unknown and I4
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
if ((int)followerCommand <= 58)
{
if ((int)followerCommand <= 28)
{
if (followerCommand - 14 <= 1 || (int)followerCommand == 17 || followerCommand - 27 <= 1)
{
goto IL_007e;
}
}
else if ((int)followerCommand <= 42)
{
if ((int)followerCommand == 30 || (int)followerCommand == 42)
{
goto IL_007e;
}
}
else if ((int)followerCommand == 47 || (int)followerCommand == 58)
{
goto IL_007e;
}
}
else if ((int)followerCommand <= 113)
{
if ((int)followerCommand <= 81)
{
if ((int)followerCommand == 64 || (int)followerCommand == 81)
{
goto IL_007e;
}
}
else if ((int)followerCommand == 88 || (int)followerCommand == 113)
{
goto IL_007e;
}
}
else if ((int)followerCommand <= 124)
{
if (followerCommand - 116 <= 1 || (int)followerCommand == 124)
{
goto IL_007e;
}
}
else if ((int)followerCommand == 126 || (int)followerCommand == 175)
{
goto IL_007e;
}
return false;
IL_007e:
return true;
}
public static FollowerRole FollowerCommandToRole(this FollowerCommands followerCommand)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Invalid comparison between Unknown and I4
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
//IL_000a: 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_0023: Expected I4, but got Unknown
//IL_00e1: 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_0090: Invalid comparison between Unknown and I4
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Invalid comparison between Unknown and I4
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Invalid comparison between Unknown and I4
//IL_00a1: 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)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected I4, but got Unknown
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Invalid comparison between Unknown and I4
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected I4, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Invalid comparison between Unknown and I4
//IL_009d: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Invalid comparison between Unknown and I4
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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)
if ((int)followerCommand <= 64)
{
if ((int)followerCommand <= 42)
{
switch (followerCommand - 14)
{
default:
switch (followerCommand - 27)
{
default:
if ((int)followerCommand != 42)
{
break;
}
return (FollowerRole)4;
case 0:
return (FollowerRole)0;
case 1:
return (FollowerRole)6;
case 3:
return (FollowerRole)8;
case 2:
break;
}
break;
case 0:
return (FollowerRole)2;
case 3:
return (FollowerRole)5;
case 1:
return (FollowerRole)7;
case 2:
break;
}
}
else
{
if ((int)followerCommand == 47)
{
return (FollowerRole)3;
}
if ((int)followerCommand == 58)
{
return (FollowerRole)9;
}
if ((int)followerCommand == 64)
{
return (FollowerRole)10;
}
}
}
else if ((int)followerCommand <= 117)
{
if ((int)followerCommand == 81)
{
return (FollowerRole)12;
}
if ((int)followerCommand == 88)
{
return (FollowerRole)13;
}
switch (followerCommand - 113)
{
case 0:
return (FollowerRole)14;
case 3:
return (FollowerRole)15;
case 4:
return (FollowerRole)16;
}
}
else
{
if ((int)followerCommand == 124)
{
return (FollowerRole)17;
}
if ((int)followerCommand == 126)
{
return (FollowerRole)18;
}
if ((int)followerCommand == 175)
{
return (FollowerRole)19;
}
}
throw new ArgumentOutOfRangeException("followerCommand", followerCommand, "Given follower command does not return a valid FollowerRole");
}
}
public static class FollowerRoleExtensions
{
public static FollowerCommands FollowerRoleToCommand(this FollowerRole followerRole)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected I4, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//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_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_00a0: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
return (FollowerCommands)((int)followerRole switch
{
0 => 27,
2 => 14,
3 => 47,
4 => 42,
5 => 17,
6 => 28,
7 => 15,
8 => 30,
9 => 58,
10 => 64,
12 => 81,
13 => 88,
14 => 113,
15 => 116,
16 => 117,
17 => 124,
18 => 126,
19 => 175,
_ => throw new ArgumentOutOfRangeException("followerRole", followerRole, "Given follower role does not return a valid FollowerCommands"),
});
}
}
public static class FontImageNamesExtensions
{
public static string GetIconForRole(this FollowerRole followerRole)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (((int)followerRole == 1 || (int)followerRole == 11) ? true : false)
{
return "";
}
string text = FontImageNames.IconForRole(followerRole);
if (!string.IsNullOrWhiteSpace(text))
{
return text;
}
return FontImageNames.IconForCommand(followerRole.FollowerRoleToCommand()) ?? "";
}
}
}