Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ColoredPingChat v1.2.7
plugins/PingChat.dll
Decompiled 3 weeks ago#define DEBUG using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; 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 BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dolso; using HG.GeneralSerializer; using HG.Reflection; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.UI; 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: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PingChat")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PingChat")] [assembly: AssemblyTitle("PingChat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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; } } } namespace Dolso { internal static class log { private static readonly ManualLogSource logger = Logger.CreateLogSource(Assembly.GetExecutingAssembly().GetName().Name); [Conditional("DEBUG")] internal static void debug(object data) { logger.LogDebug(data); } internal static void info(object data) { logger.LogInfo(data); } internal static void message(object data) { logger.LogMessage(data); } internal static void warning(object data) { logger.LogWarning(data); } internal static void error(object data) { logger.LogError(data); } internal static void fatal(object data) { logger.LogFatal(data); } internal static void LogError(this ILCursor c, object data) { logger.LogError((object)$"ILCursor failure, skipping: {data}\n{c}"); } internal static void LogErrorCaller(this ILCursor c, object data) { logger.LogError((object)$"ILCursor failed in {new StackFrame(1).GetMethod().Name}, skipping: {data}\n{c}"); } } internal static class HookManager { internal delegate bool ConfigEnabled<T>(T configValue); internal class HookedConfig<T> { private readonly ConfigEnabled<T> enabled; private readonly IDetour detour; internal HookedConfig(ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, IDetour detour) { this.enabled = enabled; this.detour = detour; if (configEntry != null) { configEntry.SettingChanged += ConfigChanged; ConfigChanged(configEntry, null); } else { detour.Apply(); } } private void ConfigChanged(object sender, EventArgs args) { if (!detour.IsValid) { return; } if (enabled(((ConfigEntry<T>)sender).Value)) { if (!detour.IsApplied) { detour.Apply(); } } else if (detour.IsApplied) { detour.Undo(); } } } internal const BindingFlags allFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly List<IDisposable> detours = new List<IDisposable>(); private static readonly ConfigEnabled<bool> boolConfigEnabled = BoolEnabled; private static ILHookConfig ilHookConfig = new ILHookConfig { ManualApply = true }; private static HookConfig onHookConfig = new HookConfig { ManualApply = true }; internal static int Hook(Type typeFrom, string fromMethod, Manipulator ilHook) { return Hook(GetMethod(typeFrom, fromMethod), ilHook); } internal static int Hook(Delegate fromMethod, Manipulator ilHook) { return Hook(fromMethod.Method, ilHook); } internal static int Hook(MethodBase fromMethod, Manipulator ilHook) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown try { ILHook val = new ILHook(fromMethod, ilHook, ref ilHookConfig); detours.Add((IDisposable)val); val.Apply(); } catch (Exception e) { e.LogHookError(fromMethod, ((Delegate)(object)ilHook).Method); return 8; } return 0; } internal static int Hook(Type typeFrom, string fromMethod, Delegate onHook) { return Hook(GetMethod(typeFrom, fromMethod), onHook.Method, onHook.Target); } internal static int Hook(Delegate fromMethod, Delegate onHook) { return Hook(fromMethod.Method, onHook.Method, onHook.Target); } internal static int Hook(MethodBase fromMethod, Delegate onHook) { return Hook(fromMethod, onHook.Method, onHook.Target); } internal static int Hook(MethodBase fromMethod, MethodInfo onHook, object target = null) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown try { Hook val = new Hook(fromMethod, onHook, target, ref onHookConfig); detours.Add((IDisposable)val); val.Apply(); } catch (Exception e) { e.LogHookError(fromMethod, onHook); return 8; } return 0; } internal static int HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string fromMethod, Delegate hook) { return configEntry.HookConfig(boolConfigEnabled, GetMethod(typeFrom, fromMethod), hook.Method, hook.Target); } internal static int HookConfig(this ConfigEntry<bool> configEntry, MethodBase fromMethod, Delegate hook) { return configEntry.HookConfig(boolConfigEnabled, fromMethod, hook.Method, hook.Target); } internal static int HookConfig(this ConfigEntry<bool> configEntry, MethodBase fromMethod, MethodInfo hook) { return configEntry.HookConfig(boolConfigEnabled, fromMethod, hook); } internal static int HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string fromMethod, Delegate hook) { return configEntry.HookConfig(enabled, GetMethod(typeFrom, fromMethod), hook.Method, hook.Target); } internal static int HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase fromMethod, Delegate hook) { return configEntry.HookConfig(enabled, fromMethod, hook.Method, hook.Target); } internal static int HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase fromMethod, MethodInfo hook, object target = null) { try { IDetour val = ManualDetour(fromMethod, hook, target); if (val == null) { return 8; } new HookedConfig<T>(configEntry, enabled, val); return 0; } catch (Exception e) { e.LogHookError(fromMethod, hook); return 8; } } internal static IDetour ManualDetour(Type typeFrom, string fromMethod, Delegate hook) { return ManualDetour(GetMethod(typeFrom, fromMethod), hook.Method, hook.Target); } internal static IDetour ManualDetour(MethodBase fromMethod, Delegate hook) { return ManualDetour(fromMethod, hook.Method, hook.Target); } internal static IDetour ManualDetour(MethodBase fromMethod, MethodInfo hook, object target = null) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown try { ParameterInfo[] parameters = hook.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ILContext)) { return (IDetour)new ILHook(fromMethod, (Manipulator)hook.CreateDelegate(typeof(Manipulator)), ref ilHookConfig); } return (IDetour)new Hook(fromMethod, hook, target, ref onHookConfig); } catch (Exception e) { e.LogHookError(fromMethod, hook); return null; } } internal static MethodInfo GetMethod(Type typeFrom, string methodName) { if (typeFrom == null || methodName == null) { log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}"); return null; } MethodInfo[] array = (from a in typeFrom.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where a.Name == methodName select a).ToArray(); switch (array.Length) { case 1: return array[0]; case 0: log.error($"Failed to find method: {typeFrom}::{methodName}"); return null; default: { string text = $"{array.Length} ambiguous matches found for {typeFrom}::{methodName}, may be incorrect"; MethodInfo[] array2 = array; for (int num = 0; num < array2.Length; num++) { text = text + "\n" + array2[num]; } log.warning(text); return array[0]; } } } internal static MethodInfo GetMethod(Type typeFrom, string methodName, params Type[] parameters) { if (typeFrom == null || methodName == null) { log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}"); return null; } MethodInfo method = typeFrom.GetMethod(methodName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null); if (method == null) { log.error($"Failed to find method: {typeFrom}::{methodName}_{parameters.Length}"); } return method; } internal static void SetPriority(string[] before_il = null, string[] before_on = null, string[] after_il = null, string[] after_on = null) { ilHookConfig.Before = before_il; onHookConfig.Before = before_on; ilHookConfig.After = after_il; onHookConfig.After = after_on; log.debug($"SetPriority({before_il}, {before_on}, {after_il}, {after_on})"); } internal static void DisposeAll() { for (int num = detours.Count - 1; num >= 0; num--) { try { IDisposable disposable = detours[num]; detours.RemoveAt(num); disposable.Dispose(); } catch (Exception) { } } } internal static void LogHookError(this Exception e, MethodBase fromMethod, MethodInfo hook) { log.error((fromMethod == null) ? $"null from-method for hook: {hook.Name}\n{e}" : $"Failed to hook: {fromMethod.DeclaringType}::{fromMethod.Name} - {hook.Name}\n{e}"); } private static bool BoolEnabled(bool configValue) { return configValue; } } internal static class Utilities { private static GameObject _prefabParent; internal static GameObject CreatePrefab(GameObject gameObject, string name = null) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_prefabParent)) { _prefabParent = new GameObject("DolsoPrefabs"); Object.DontDestroyOnLoad((Object)(object)_prefabParent); ((Object)_prefabParent).hideFlags = (HideFlags)61; _prefabParent.SetActive(false); } GameObject val = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform); if (name != null) { ((Object)val).name = name; } return val; } internal static void ModifyStateConfig(this EntityStateConfiguration stateConfig, string fieldName, object newValue) { SerializedField[] serializedFields = stateConfig.serializedFieldsCollection.serializedFields; for (int i = 0; i < serializedFields.Length; i++) { if (serializedFields[i].fieldName == fieldName) { Object val = (Object)((newValue is Object) ? newValue : null); if (val != null) { serializedFields[i].fieldValue.objectValue = val; } else if (newValue != null && StringSerializer.CanSerializeType(newValue.GetType())) { serializedFields[i].fieldValue.stringValue = StringSerializer.Serialize(newValue.GetType(), newValue); } else { log.error("Invalid value for SerializedField: " + newValue); } return; } } log.error("Failed to find " + fieldName + " for " + ((Object)stateConfig).name); } internal static bool IsKeyDown(this KeyboardShortcut key, bool onlyJustPressed) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (onlyJustPressed) { if (!Input.GetKeyDown(((KeyboardShortcut)(ref key)).MainKey)) { return false; } } else if (!Input.GetKey(((KeyboardShortcut)(ref key)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref key)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } } internal static class RiskofOptions { internal const string RooGuid = "com.rune580.riskofoptions"; internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); [MethodImpl(MethodImplOptions.NoInlining)] internal static void SetSprite(Sprite sprite) { ModSettingsManager.SetModIcon(sprite); } internal static void SetSpriteDefaultIcon() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_005f: 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) try { string fullName = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName; Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(fullName, "icon.png")))) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f))); } else { log.error("Failed to load icon.png"); } } catch (Exception ex) { log.error("Failed to load icon.png\n" + ex); } } internal static void AddOption(ConfigEntryBase entry) { AddOption(entry, string.Empty, string.Empty); } [MethodImpl(MethodImplOptions.NoInlining)] internal static void AddOption(ConfigEntryBase entry, string categoryName = "", string name = "", bool restartRequired = false) { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00d6: 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_00c9: Expected O, but got Unknown //IL_00c4: 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_00b7: Expected O, but got Unknown //IL_00b2: 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_00a5: Expected O, but got Unknown //IL_00a0: 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_0093: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) Type settingType = entry.SettingType; object obj; if (!(settingType == typeof(float))) { obj = ((!(settingType == typeof(string))) ? ((!(settingType == typeof(bool))) ? ((!(settingType == typeof(int))) ? ((!(settingType == typeof(Color))) ? ((!(settingType == typeof(KeyboardShortcut))) ? ((object)((!settingType.IsEnum) ? ((ChoiceOption)null) : new ChoiceOption(entry, new ChoiceConfig()))) : ((object)new KeyBindOption((ConfigEntry<KeyboardShortcut>)(object)entry, new KeyBindConfig()))) : ((object)new ColorOption((ConfigEntry<Color>)(object)entry, new ColorOptionConfig()))) : ((object)new IntFieldOption((ConfigEntry<int>)(object)entry, new IntFieldConfig()))) : ((object)new CheckBoxOption((ConfigEntry<bool>)(object)entry, new CheckBoxConfig()))) : ((object)new StringInputFieldOption((ConfigEntry<string>)(object)entry, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0 }))); } else if (entry.Description.AcceptableValues is AcceptableValueRange<float>) { obj = (object)new SliderOption((ConfigEntry<float>)(object)entry, new SliderConfig { min = ((AcceptableValueRange<float>)(object)entry.Description.AcceptableValues).MinValue, max = ((AcceptableValueRange<float>)(object)entry.Description.AcceptableValues).MaxValue, FormatString = "{0:f2}", description = entry.DescWithDefault("{0:f2}") }); } else { ConfigEntry<float> obj2 = (ConfigEntry<float>)(object)entry; FloatFieldConfig val = new FloatFieldConfig(); ((NumericFieldConfig<float>)val).FormatString = "{0:f2}"; ((BaseOptionConfig)val).description = entry.DescWithDefault("{0:f2}"); obj = (object)new FloatFieldOption(obj2, val); } BaseOption val2 = (BaseOption)obj; if (val2 == null) { return; } BaseOptionConfig config = val2.GetConfig(); config.category = categoryName; config.name = name; config.restartRequired = restartRequired; if (config.description == "") { config.description = entry.DescWithDefault(); } try { ModSettingsManager.AddOption(val2); } catch (Exception arg) { log.error($"AddOption {entry.Definition} failed\n{arg}"); } } [MethodImpl(MethodImplOptions.NoInlining)] internal static void AddOption(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}", string categoryName = "") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig { min = min, max = max, FormatString = format, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault(format) })); } [MethodImpl(MethodImplOptions.NoInlining)] internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max, string categoryName = "") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_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_0032: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig { min = min, max = max, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } private static string DescWithDefault(this ConfigEntryBase entry, string format = "{0}") { return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description); } } [MeansImplicitUse] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] internal class HookAttribute : Attribute { private readonly Type? target_type; private readonly string? target_method; private readonly Type[]? parameters; internal byte flags = 0; internal HookAttribute(Type target_type, string target_method) { this.target_type = target_type; this.target_method = target_method; } internal HookAttribute(Type target_type, string target_method, params Type[] parameters) { this.target_type = target_type; this.target_method = target_method; this.parameters = parameters; } internal HookAttribute() { } internal static int ScanAndApply() { Type[] array = null; try { array = Assembly.GetCallingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { array = ex.Types.Where((Type t) => t != null).ToArray(); log.warning("Failed to load certain types: " + ex); } return ScanAndApply(array.Where((Type a) => a.GetCustomAttribute<HookAttribute>() != null).ToArray()); } internal static int ScanAndApply(params Type[] types) { int num = 0; foreach (Type type in types) { MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { HookAttribute[] array = (HookAttribute[])Attribute.GetCustomAttributes(methodInfo, typeof(HookAttribute), inherit: false); foreach (HookAttribute hookAttribute in array) { num |= hookAttribute.ApplyHook(methodInfo); } } } return num; } internal int ApplyHook(MethodInfo member) { if (!member.IsStatic) { log.error("HookAttribute cannot be applied on instance methods"); return 0; } if (member.IsPublic) { log.error("HookAttribute cannot be applied on public methods"); return 0; } MethodInfo methodInfo = null; try { methodInfo = get_target(); if (methodInfo != null) { return Hook(methodInfo, member); } if (member.GetParameters().Length == 0 && GetType() == typeof(HookAttribute)) { member.Invoke(null, null); return 0; } log.error("null target method for hook " + member.Name); return 4; } catch (Exception e) { e.LogHookError(methodInfo, member); return 64; } } protected virtual int Hook(MethodInfo target, MethodInfo member) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown ParameterInfo[] array = member.GetParameters(); if (array.Length == 1 && array[0].ParameterType == typeof(ILContext)) { StateMachineAttribute customAttribute; if ((flags & 1) == 0 && (customAttribute = target.GetCustomAttribute<StateMachineAttribute>()) != null) { target = customAttribute.StateMachineType.GetMethod("MoveNext", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } return HookManager.Hook(target, (Manipulator)member.CreateDelegate(typeof(Manipulator))); } return HookManager.Hook(target, member); } protected MethodInfo? get_target() { return ((object)target_type == null) ? null : ((parameters == null) ? HookManager.GetMethod(target_type, target_method) : HookManager.GetMethod(target_type, target_method, parameters)); } } } namespace PingChat { internal static class Config { internal static ConfigFile configFile; internal static bool? doroo; internal static ConfigEntry<KeyboardShortcut> chatKey; internal static ConfigEntry<float> itemScale; internal static ConfigEntry<float> moveDuration; internal static ConfigEntry<float> interactDuration; internal static ConfigEntry<float> itemDuration; internal static ConfigEntry<float> enemyDuration; internal static ConfigEntry<bool> chatToggle; internal static ConfigEntry<bool> itemIconToggle; internal static ConfigEntry<bool> shopItemIconToggle; internal static ConfigEntry<bool> enemyIconToggle; internal static ConfigEntry<bool> enemyIconColorToggle; internal static Dictionary<EliteDef, ConfigEntry<Color>> elite_colors = new Dictionary<EliteDef, ConfigEntry<Color>>(); internal static ConfigEntry<Color> not_elite_color; internal static ConfigEntry<Color> itemIconColor; internal static ConfigEntry<Color> interactableIconColor; internal static ConfigEntry<string> attack_message; internal static ConfigEntry<string> pickup_message; internal static ConfigEntry<string> teleporter_message; internal static ConfigEntry<string> potential_message; internal static ConfigEntry<string> shop_message; internal static ConfigEntry<string> other_message; internal static void DoConfigs(ConfigFile configFile) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) Config.configFile = configFile; chatKey = CreateEntry<KeyboardShortcut>("Misc", "Key", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), "The key for sending a custom chat message"); itemScale = CreateEntry("Misc", "Item icon scale", 0.67f, "Scale of item icon in pings"); chatToggle = CreateEntry("Toggles", "Chat coloring toggle", default_value: true, "Toggles the coloring of chat"); enemyIconToggle = CreateEntry("Toggles", "Enemy icon toggle", default_value: true, "Toggles changing the ping icons for enemies to their logbook icons"); enemyIconColorToggle = CreateEntry("Toggles", "Elite enemy icon coloring toggle", default_value: true, "Toggles the coloring of elite enemy ping icons. If false, but icons are on, will use color of 'None'"); itemIconToggle = CreateEntry("Toggles", "Item icon toggle", default_value: true, "Toggles changing the ping icons for items to their logbook icons"); shopItemIconToggle = CreateEntry("Toggles", "Item icon toggle for multishops and printers", default_value: true, "Toggles changing the ping icons for items in multishops and printers"); moveDuration = CreateEntry("Durations", "Move ping duration", 6f, "Duration of move here ping"); interactDuration = CreateEntry("Durations", "Interactives ping duration", 30f, "Duration of interactives ping. Includes chests, shops, printers, teleporter, etc"); itemDuration = CreateEntry("Durations", "Item ping duration", 60f, "Duration of item ping. Includes scrappers and potentials"); enemyDuration = CreateEntry("Durations", "Enemy ping duration", 8f, "Duration of attack enemy ping"); itemIconColor = CreateEntry<Color>("IColor", "Item icon color", new Color(1f, 1f, 1f), "Color of pinged item icons"); interactableIconColor = CreateEntry<Color>("IColor", "Pinged interactable color", new Color(0.89f, 0.87f, 0.17f), "Color of pinged interactables"); not_elite_color = CreateEntry<Color>("Elite colors", "None", new Color(1f, 1f, 1f), "Color hex: (Red, Green, Blue, Alpha)"); attack_message = CreateEntry("Messages", "Body", "attack {0}", "Enemies and allies. {0} is body name"); pickup_message = CreateEntry("Messages", "Pickup", "pickup {0}", "Items and other pickups. {0} is pickup name"); teleporter_message = CreateEntry("Messages", "Teleporter", "hit the {0}", "Teleporter and portals. {0} is the porter name"); potential_message = CreateEntry("Messages", "Potential", "open this {0}", "Potentials, which are the sphere drops from void areas, with 3 item options inside. {0} is the potential name"); shop_message = CreateEntry("Messages", "Shop", "{0} [{1}] here", "Tri-shops and printers. {0} is the building name, {1} is the item name"); other_message = CreateEntry("Messages", "Other", "{0} here", "For anything else. {0} is the display name"); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetupEliteColors)); } private static void SetupEliteColors() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) elite_colors.Add(Elites.Fire, CreateEntry<Color>("Elite colors", "Blazing", new Color(0.8f, 0.21f, 0.15f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.FireHonor, elite_colors[Elites.Fire]); elite_colors.Add(Elites.Haunted, CreateEntry<Color>("Elite colors", "Celestine", new Color(0.55f, 0.79f, 0.8f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.Ice, CreateEntry<Color>("Elite colors", "Glacial", new Color(0.84f, 0.96f, 0.97f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.IceHonor, elite_colors[Elites.Ice]); elite_colors.Add(Elites.Lightning, CreateEntry<Color>("Elite colors", "Overloading", new Color(0.3f, 0.45f, 1f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.LightningHonor, elite_colors[Elites.Lightning]); elite_colors.Add(Elites.Lunar, CreateEntry<Color>("Elite colors", "Perfected", new Color(0.34f, 0.45f, 0.58f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.Poison, CreateEntry<Color>("Elite colors", "Malachite", new Color(0.58f, 0.86f, 0.61f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.Earth, CreateEntry<Color>("Elite colors", "Mending", new Color(0.63f, 0.91f, 0.31f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.EarthHonor, elite_colors[Elites.Earth]); elite_colors.Add(Elites.Void, CreateEntry<Color>("Elite colors", "Voidtouched", new Color(0.86f, 0.44f, 0.93f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.Aurelionite, CreateEntry<Color>("Elite colors", "Gilded", new Color(1f, 0.8f, 0.06f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.Bead, CreateEntry<Color>("Elite colors", "Twisted", new Color(0.52f, 0.8f, 1f), "Color hex: (Red, Green, Blue, Alpha)")); elite_colors.Add(Elites.Collective, CreateEntry<Color>("Elite colors", "Collective", new Color(0.49f, 0.96f, 1f), "Color hex: (Red, Green, Blue, Alpha)")); } private static ConfigEntry<T> CreateEntry<T>(string section, string key, T default_value, string description) { ConfigEntry<T> val = configFile.Bind<T>(section, key, default_value, description); if (!doroo.HasValue) { doroo = RiskofOptions.enabled; if (doroo == true) { RiskofOptions.SetSpriteDefaultIcon(); } } if (doroo == true) { RiskofOptions.AddOption((ConfigEntryBase)(object)val); } return val; } } internal static class Messages { private static bool keyDown; private static bool keySpent; internal static void CheckInput() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_002c: Unknown result type (might be due to invalid IL or missing references) if (Config.chatKey.Value.IsKeyDown(onlyJustPressed: true)) { keyDown = true; return; } KeyboardShortcut value = Config.chatKey.Value; if (Input.GetKeyUp(((KeyboardShortcut)(ref value)).MainKey)) { keyDown = false; keySpent = false; } } internal static void CheckMessageKey_On_CheckPinging(Action<PlayerCharacterMasterController> orig, PlayerCharacterMasterController self) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between Unknown and I4 //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Invalid comparison between Unknown and I4 //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) orig(self); if (!keyDown || keySpent) { return; } PingIndicator pingIndicator = self.pingerController.pingIndicator; GameObject val = ((pingIndicator != null) ? pingIndicator.pingTarget : null); if (!Object.op_Implicit((Object)(object)val)) { return; } if ((int)pingIndicator.pingType == 1) { string bestBodyName = Util.GetBestBodyName(val); SendChatMessage(string.Format(CultureInfo.InvariantCulture, Config.attack_message.Value, bestBodyName)); } else { if ((int)pingIndicator.pingType != 2) { return; } IDisplayNameProvider componentInParent = val.GetComponentInParent<IDisplayNameProvider>(); if (componentInParent == null) { log.error("null displayNameProvider"); return; } string displayName = componentInParent.GetDisplayName(); if (Object.op_Implicit((Object)(object)val.GetComponent<GenericPickupController>())) { SendChatMessage(string.Format(CultureInfo.InvariantCulture, Config.pickup_message.Value, displayName)); } else if (Object.op_Implicit((Object)(object)val.GetComponent<SceneExitController>())) { SendChatMessage(string.Format(CultureInfo.InvariantCulture, Config.teleporter_message.Value, displayName)); } else if (Object.op_Implicit((Object)(object)val.GetComponent<PickupIndexNetworker>()) && Object.op_Implicit((Object)(object)val.GetComponent<PickupPickerController>())) { SendChatMessage(string.Format(CultureInfo.InvariantCulture, Config.potential_message.Value, displayName)); } else if (Object.op_Implicit((Object)(object)val.GetComponent<ShopTerminalBehavior>())) { ShopTerminalBehavior component = val.GetComponent<ShopTerminalBehavior>(); SendChatMessage(string.Format(arg1: (component.pickupIndexIsHidden || !Object.op_Implicit((Object)(object)component.pickupDisplay)) ? "?" : Language.GetString(PickupCatalog.GetPickupDef(component.CurrentPickup().pickupIndex)?.nameToken ?? PickupCatalog.invalidPickupToken), provider: CultureInfo.InvariantCulture, format: Config.shop_message.Value, arg0: displayName)); } else { SendChatMessage(string.Format(CultureInfo.InvariantCulture, Config.other_message.Value, displayName)); } } keySpent = true; void SendChatMessage(string message) { Console.instance.SubmitCmd(self.networkUser, "say \"" + message + "\"", false); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("dolso.pingchat", "ColoredPingChat", "1.2.7")] [Hook] public class PingChat : BaseUnityPlugin { private static EliteDef current_elite; private static PickupDef currentPickupDef; private static Shader defaultSpriteShader; private static Shader itemIconShader; private static Vector3 default_inter_spriter_scale; internal static PluginInfo pluginInfo; private void Awake() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown Config.DoConfigs(((BaseUnityPlugin)this).Config); pluginInfo = ((BaseUnityPlugin)this).Info; LoadShader(); HookManager.SetPriority(null, null, null, new string[1] { "*" }); HookManager.Hook(typeof(PingIndicator), "RebuildPing", (Delegate)new Action<Action<PingIndicator>, PingIndicator>(Icons_On_PingIndicator_RebuildPing)); HookManager.Hook(typeof(PingIndicator), "RebuildPing", new Manipulator(Text_IL_PingIndicator_RebuildPing)); HookManager.Hook(typeof(PingIndicator), "GetFormattedTargetString", new Manipulator(ModifyNameColor_IL_PingIndicator_GetFormattedTargetString)); HookManager.Hook(typeof(PlayerCharacterMasterController), "CheckPinging", (Delegate)new Action<Action<PlayerCharacterMasterController>, PlayerCharacterMasterController>(Messages.CheckMessageKey_On_CheckPinging)); } private void Update() { Messages.CheckInput(); } private void Icons_On_PingIndicator_RebuildPing(Action<PingIndicator> orig, PingIndicator self) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Invalid comparison between Unknown and I4 //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Invalid comparison between Unknown and I4 //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) self.defaultPingDuration = Config.moveDuration.Value; self.interactablePingDuration = Config.interactDuration.Value; self.enemyPingDuration = Config.enemyDuration.Value; SpriteRenderer component = self.interactablePingGameObjects[0].GetComponent<SpriteRenderer>(); if ((Object)(object)defaultSpriteShader == (Object)null) { defaultSpriteShader = ((Renderer)component).material.shader; default_inter_spriter_scale = ((Component)component).transform.localScale; } else { ((Renderer)component).material.shader = defaultSpriteShader; ((Component)component).transform.localScale = default_inter_spriter_scale; } orig(self); if ((int)self.pingType == 1 && Config.enemyIconToggle.Value) { SpriteRenderer component2 = self.enemyPingGameObjects[0].GetComponent<SpriteRenderer>(); if (!Object.op_Implicit((Object)(object)component2)) { log.warning("no enemy sprite"); return; } CharacterBody component3 = self.pingTarget.GetComponent<CharacterBody>(); if (!Object.op_Implicit((Object)(object)component3)) { log.warning("no enemy body"); return; } Texture portraitIcon = component3.portraitIcon; Texture2D val = (Texture2D)(object)((portraitIcon is Texture2D) ? portraitIcon : null); if (val == null) { log.warning(((Object)component3).name + " does not have a Texture2D potrait"); return; } Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, 0f, 128f * (float)((Texture)val).width / (float)((Texture)val).height, 128f * (float)((Texture)val).height / (float)((Texture)val).width); component2.sprite = Sprite.Create(val, val2, new Vector2(0.5f, 0.5f)); if (Config.enemyIconColorToggle.Value && current_elite != null) { component2.color = Config.elite_colors[current_elite].Value; } else { component2.color = Config.not_elite_color.Value; } current_elite = null; } else if ((int)self.pingType == 2 && currentPickupDef != null && Config.itemIconToggle.Value) { component = self.interactablePingGameObjects[0].GetComponent<SpriteRenderer>(); if (!Object.op_Implicit((Object)(object)component)) { log.warning("no icon spriter"); return; } Sprite val3 = (component.sprite = get_pickup_icon_sprite(currentPickupDef)); Rect rect = val3.rect; ((Component)component).transform.localScale = new Vector3(128f / ((Rect)(ref rect)).width * Config.itemScale.Value * default_inter_spriter_scale.x, 128f / ((Rect)(ref rect)).height * Config.itemScale.Value * default_inter_spriter_scale.y, default_inter_spriter_scale.z); currentPickupDef = null; } } [Hook(typeof(PingIndicator), "RebuildPing")] private static void Text_IL_PingIndicator_RebuildPing(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int textIndex = -1; if (!val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(Util), "GetBestBodyName") }) || !val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref textIndex) })) { val.LogErrorCaller("failed to find text"); } if (textIndex != -1 && val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "PLAYER_PING_ENEMY") }) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, textIndex) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<string, PingIndicator, string>>((Func<string, PingIndicator, string>)func_enemy); } else { val.LogErrorCaller("failed to find enemy ping"); } int interactableIconIndex = -1; if (!val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<PingIndicator>(a, "GetInteractableIcon") }) || !val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref interactableIconIndex) })) { val.LogErrorCaller("failed to find interactableIcon"); } int spriteRendererIndex = -1; if (!val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)typeof(GameObject).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(SpriteRenderer))) }) || !val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref spriteRendererIndex) })) { val.LogErrorCaller("failed to find spriteRenderer"); } if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<ShopTerminalBehavior>(a, "CurrentPickup"), (Instruction a) => ILPatternMatchingExt.MatchLdfld<UniquePickup>(a, "pickupIndex") })) { val.LogErrorCaller("failed to find shop/printer pickupIndex for shader replacement"); } else { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldloc, interactableIconIndex); val.Emit(OpCodes.Ldloc, spriteRendererIndex); val.EmitDelegate<Func<PickupIndex, Sprite, SpriteRenderer, Sprite>>((Func<PickupIndex, Sprite, SpriteRenderer, Sprite>)func_sprite); val.Emit(OpCodes.Stloc, interactableIconIndex); } if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchLdstr(a, "Shrine") }) && val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchStfld(a, typeof(PingIndicator), "pingDuration") })) { val.Emit(OpCodes.Pop); val.EmitDelegate<Func<float>>((Func<float>)(() => Config.itemDuration.Value)); } else { val.LogErrorCaller("failed to properly set pingDuration"); } val.Emit(OpCodes.Ldloc, textIndex); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Call, (MethodBase)typeof(PingIndicator).GetMethod("get_pingTarget")); val.EmitDelegate<Func<string, GameObject, string>>((Func<string, GameObject, string>)func_pickup); val.Emit(OpCodes.Stloc, textIndex); if (!val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchLdfld(a, typeof(PingIndicator), "interactablePingGameObjects") })) { val.LogError("failed to properly go to icon coloring"); } val.Emit(OpCodes.Ldloc, spriteRendererIndex); val.EmitDelegate<Func<Color>>((Func<Color>)get_icon_color); val.Emit(OpCodes.Callvirt, (MethodBase)typeof(SpriteRenderer).GetMethod("set_color")); static string func_enemy(string text, PingIndicator self) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) CharacterBody component = self.pingTarget.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component) && component.isElite) { BuffIndex[] eliteBuffIndices = BuffCatalog.eliteBuffIndices; foreach (BuffIndex val2 in eliteBuffIndices) { if (component.HasBuff(val2)) { EliteDef eliteDef = BuffCatalog.GetBuffDef(val2).eliteDef; if (Config.elite_colors.TryGetValue(eliteDef, out var value)) { current_elite = eliteDef; if (Config.chatToggle.Value) { string text2 = Language.GetStringFormatted(eliteDef.modifierToken, new object[1] { "" }).Trim(); return text.Replace(text2, Util.GenerateColoredString(text2, Color32.op_Implicit(value.Value))); } } } } } return text; } static string func_pickup(string name, GameObject target) { //IL_0014: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) GenericPickupController component = target.GetComponent<GenericPickupController>(); if (Object.op_Implicit((Object)(object)component)) { currentPickupDef = PickupCatalog.GetPickupDef(component.pickup.pickupIndex); if (Config.chatToggle.Value) { return Util.GenerateColoredString(name, Color32.op_Implicit(currentPickupDef.baseColor)); } return name; } if (!Config.chatToggle.Value) { return name; } PickupIndexNetworker component2 = target.GetComponent<PickupIndexNetworker>(); if (Object.op_Implicit((Object)(object)component2)) { return Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(component2.pickupState.pickupIndex).baseColor)); } PickupDropletController component3 = target.GetComponent<PickupDropletController>(); if (Object.op_Implicit((Object)(object)component3)) { log.info("PICKUPDROPLETCONTROLLER"); return Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(component3.pickupState.pickupIndex).baseColor)); } return name; } static Sprite func_sprite(PickupIndex pickupIndex, Sprite sprite, SpriteRenderer spriteRenderer) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (Config.shopItemIconToggle.Value && pickupDef != null) { Sprite val2 = get_pickup_icon_sprite(pickupDef); if ((Object)(object)val2 != (Object)null) { sprite = val2; ((Renderer)spriteRenderer).material.shader = itemIconShader; ((Component)spriteRenderer).transform.localScale = new Vector3(Config.itemScale.Value * 0.1f, Config.itemScale.Value * 0.1f, 0.1f); } } return sprite; } static Color get_icon_color() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0036: Unknown result type (might be due to invalid IL or missing references) if (Config.itemIconToggle.Value && currentPickupDef != null) { return Config.itemIconColor.Value; } return Config.interactableIconColor.Value; } } private static void ModifyNameColor_IL_PingIndicator_GetFormattedTargetString(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<Language>(a, "GetString") })) { val.Emit(OpCodes.Ldarg_1); val.EmitDelegate<Func<string, PickupIndex, string>>((Func<string, PickupIndex, string>)color_pickup_string); } else { val.LogErrorCaller("shop name"); } if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "?") })) { val.Emit(OpCodes.Ldarg_1); val.EmitDelegate<Func<string, PickupIndex, string>>((Func<string, PickupIndex, string>)color_pickup_string); } else { val.LogErrorCaller("Failed to find ? item"); } static string color_pickup_string(string name, PickupIndex pickupindex) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (Config.chatToggle.Value) { return Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(pickupindex).baseColor)); } return name; } } private static void LoadShader() { try { AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(typeof(PingChat).Assembly.Location), "itemicon")); itemIconShader = val.LoadAsset<Shader>("ItemIcon.shader"); val.Unload(false); } catch (Exception ex) { log.error("Failed to load assetbundle\n" + ex); } } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCReloadConfig(ConCommandArgs args) { Config.configFile.Reload(); } private static Sprite get_pickup_icon_sprite(PickupDef pickup) { if ((Object)(object)pickup.iconSprite != (Object)null) { return pickup.iconSprite; } if (pickup.iconSpriteReference != null) { return pickup.GetIconAODR(true, (Action<Sprite>)null, (Action<Sprite>)null).WaitForCompletion(); } return null; } } }