using System; using System.Collections.Generic; 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Sirenix.Utilities; 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.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("BLOKBUSTR")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+aa1d60ef6ed02906929edce4a11949a750eabcba")] [assembly: AssemblyProduct("Nickname")] [assembly: AssemblyTitle("Nickname")] [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.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] [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; } } [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 Nickname { [BepInPlugin("BLOKBUSTR.Nickname", "Nickname", "1.0.0")] public class Nickname : BaseUnityPlugin { internal static List enemyList = null; public static readonly Dictionary> configEnemyNames = new Dictionary>(); public static ConfigEntry configForceUppercase; public static ConfigEntry configPurgeOrphanedEntries; internal static ConfigEntry configEnableDebug; internal static Nickname Instance { get; private set; } = null; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void RegisterConfig() { foreach (string enemy in enemyList) { if (enemy != null) { configEnemyNames.TryAdd(enemy, ((BaseUnityPlugin)this).Config.Bind("Enemies", enemy, enemy, "The name for " + enemy + ".")); } } configForceUppercase = ((BaseUnityPlugin)this).Config.Bind("Settings", "ForceUppercase", true, "Whether the enemy name UI should always display UPPERCASE characters, regardless of the case of your custom names. Vanilla behavior is true."); configPurgeOrphanedEntries = ((BaseUnityPlugin)this).Config.Bind("Settings", "PurgeOrphanedEntries", false, "Whether to purge orphaned config entries on the next launch of R.E.P.O. This may include entries for modded enemies that have been disabled; vanilla enemies are never affected."); configEnableDebug = ((BaseUnityPlugin)this).Config.Bind("Debug", "EnableDebug", false, "Whether to enable debug logging. Keep this disabled for normal gameplay."); if (configPurgeOrphanedEntries.Value) { Dictionary dictionary = (Dictionary)((object)((BaseUnityPlugin)this).Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(((BaseUnityPlugin)this).Config, null); if (dictionary != null) { string text = string.Empty; bool flag = false; foreach (KeyValuePair item in dictionary) { text += $"\n{item.Key} > {item.Value}"; flag = true; } if (flag) { Logger.LogDebug((object)("Found and removed orphaned ConfigEntries:" + text)); dictionary.Clear(); } } configPurgeOrphanedEntries.Value = false; } ((BaseUnityPlugin)this).Config.Save(); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal static void Debug(string message, Object? obj = null) { if (configEnableDebug.Value) { Logger.LogDebug((object)(Object.op_Implicit(obj) ? $"{obj} ({obj.GetInstanceID()}): {message}" : message)); } } } } namespace Nickname.Patches { [HarmonyPatch(typeof(EnemyDirector))] internal static class EnemyDirectorPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix() { if (!LinqExtensions.IsNullOrEmpty((IList)Nickname.enemyList)) { return; } Nickname.enemyList = new List((from prefabRef in (from prefabRef in EnemyDirector.instance.enemiesDifficulty1.Concat(EnemyDirector.instance.enemiesDifficulty2).Concat(EnemyDirector.instance.enemiesDifficulty3).SelectMany((EnemySetup enemySetup) => enemySetup.spawnObjects) group prefabRef by ((Object)((PrefabRef)(object)prefabRef).Prefab).GetInstanceID() into prefabRefs select prefabRefs.First() into prefabRef where (Object)(object)((PrefabRef)(object)prefabRef).Prefab.GetComponent() != (Object)null select prefabRef).SkipWhile((PrefabRef prefabRef) => ((PrefabRef)(object)prefabRef).Prefab.GetComponent().enemyName.Equals("Peeper", StringComparison.InvariantCultureIgnoreCase)) select ((PrefabRef)(object)prefabRef).Prefab.GetComponent().enemyName).ToList()); Nickname.Instance.RegisterConfig(); if (!Nickname.configEnableDebug.Value) { return; } try { string text = "Registered Enemies:"; foreach (string enemy in Nickname.enemyList) { if (enemy != null) { text = text + "\n" + enemy; } } Nickname.Logger.LogDebug((object)text); } catch (Exception arg) { Nickname.Logger.LogWarning((object)$"Caught Exception while trying to print enemyList:\n{arg}\nThe list itself is not affected."); } } } [HarmonyPatch(typeof(ItemInfoUI))] internal static class ItemInfoUIPatch { private static string newMessage = string.Empty; [HarmonyPrefix] [HarmonyPatch("ItemInfoText")] private static void ItemInfoUIPrefix(ref string message, bool enemy) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_007f: 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_0064: Unknown result type (might be due to invalid IL or missing references) if (!enemy) { TextMeshProUGUI text = ItemInfoUI.instance.Text; ((TMP_Text)text).fontStyle = (FontStyles)(((TMP_Text)text).fontStyle | 0x10); return; } if (ItemInfoUI.instance.messageTimer <= 0f) { if (Nickname.configForceUppercase.Value) { TextMeshProUGUI text2 = ItemInfoUI.instance.Text; ((TMP_Text)text2).fontStyle = (FontStyles)(((TMP_Text)text2).fontStyle | 0x10); } else { TextMeshProUGUI text3 = ItemInfoUI.instance.Text; ((TMP_Text)text3).fontStyle = (FontStyles)(((TMP_Text)text3).fontStyle & -17); } if (Nickname.configEnemyNames.TryGetValue(message, out ConfigEntry value)) { newMessage = value.Value; Nickname.Debug("\nmessage: " + message + "\nnewMessage: " + newMessage, (Object?)(object)ItemInfoUI.instance); } else { Nickname.Logger.LogWarning((object)("Failed to find entry for \"" + message + "\".")); } } message = newMessage; } } }