using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq.Expressions;
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 Dolso;
using HG.GeneralSerializer;
using HG.Reflection;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PingChat")]
[assembly: AssemblyConfiguration("Release")]
[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 Dolso
{
internal static class log
{
private static ManualLogSource logger;
internal static void start(ManualLogSource logSource)
{
logger = logSource;
}
internal static void start(string name)
{
logger = Logger.CreateLogSource(name);
}
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)string.Format($"ILCursor failure: {data}\n{c}"));
}
internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "")
{
logger.LogError((object)string.Format($"ILCursor failure in {callerName}: {data}\n{c}"));
}
}
internal static class HookManager
{
internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private static readonly List<IDetour> hooks = new List<IDetour>();
private static ILHookConfig ilHookConfig = new ILHookConfig
{
ManualApply = true
};
private static HookConfig onHookConfig = new HookConfig
{
ManualApply = true
};
internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
try
{
ILHook val = new ILHook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), ilHook, ref ilHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make ILHook {typeFrom}.{methodFrom} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}");
}
}
internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
try
{
ILHook val = new ILHook(methodFrom, ilHook, ref ilHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make ILHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}");
}
}
internal static void Hook(Delegate from, Manipulator ilHook)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
try
{
ILHook val = new ILHook((MethodBase)from.Method, ilHook, ref ilHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make ILHook {from.Method.DeclaringType}.{from.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}");
}
}
internal static void Hook<T>(Expression<Action<T>> from, Manipulator ilHook)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
MethodInfo method = ((MethodCallExpression)from.Body).Method;
try
{
ILHook val = new ILHook((MethodBase)method, ilHook, ref ilHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make ILHook: {method.DeclaringType}.{method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}");
}
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
try
{
Hook val = new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex2}");
}
}
internal static void Hook(MethodInfo methodFrom, MethodInfo onHook)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
try
{
Hook val = new Hook((MethodBase)methodFrom, onHook, ref onHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {val.Target.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex2}");
}
}
internal static void Hook(MethodBase methodFrom, Delegate onHook)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
try
{
Hook val = new Hook(methodFrom, onHook, ref onHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Method.Name}\n{ex2}");
}
}
internal static void Hook(Delegate from, Delegate onHook)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
try
{
Hook val = new Hook((MethodBase)from.Method, onHook, ref onHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make onHook {from.Method.DeclaringType}.{from.Method.Name} - {onHook.Method.Name}\n{ex2}");
}
}
internal static void Hook<T>(Expression<Action<T>> from, Delegate onto)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
try
{
Hook val = new Hook((MethodBase)((MethodCallExpression)from.Body).Method, onto, ref onHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onto.Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make onHook {((MethodCallExpression)from.Body).Method.DeclaringType}.{((MethodCallExpression)from.Body).Method.Name} - {onto.Method.Name}\n{ex2}");
}
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
try
{
Hook val = new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook.Method, instance, ref onHookConfig);
try
{
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}");
}
}
catch (Exception ex2)
{
log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex2}");
}
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, Type typeFrom, string methodFrom, Manipulator ilHook)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
try
{
configEntry.AddHookConfig<T>(enabled, (IDetour)new ILHook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), ilHook, ref ilHookConfig));
}
catch (Exception ex)
{
log.error($"Failed to ILHook {typeFrom}.{methodFrom} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Manipulator ilHook)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
try
{
configEntry.AddHookConfig<T>(enabled, (IDetour)new ILHook(methodFrom, ilHook, ref ilHookConfig));
}
catch (Exception ex)
{
log.error($"Failed to ILHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, Type typeFrom, string methodFrom, Delegate onHook)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
try
{
configEntry.AddHookConfig<T>(enabled, (IDetour)new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig));
}
catch (Exception ex)
{
log.error($"Failed to onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}");
}
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Delegate onHook)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
try
{
configEntry.AddHookConfig<T>(enabled, (IDetour)new Hook(methodFrom, onHook, ref onHookConfig));
}
catch (Exception ex)
{
log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Method.Name}\n{ex}");
}
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook)
{
configEntry.HookConfig<bool>(() => configEntry.Value, typeFrom, methodFrom, ilHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook)
{
configEntry.HookConfig<bool>(() => configEntry.Value, methodFrom, ilHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook)
{
configEntry.HookConfig<bool>(() => configEntry.Value, typeFrom, methodFrom, onHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook)
{
configEntry.HookConfig<bool>(() => configEntry.Value, methodFrom, onHook);
}
private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, IDetour detour)
{
hooks.Add(detour);
configEntry.SettingChanged += delegate
{
UpdateHook(detour, enabled());
};
if (enabled())
{
detour.Apply();
}
}
private static void UpdateHook(IDetour hook, bool enabled)
{
if (enabled)
{
if (!hook.IsApplied)
{
hook.Apply();
}
}
else if (hook.IsApplied)
{
hook.Undo();
}
}
internal static void PriorityFirst()
{
ilHookConfig.Before = new string[1] { "*" };
onHookConfig.Before = new string[1] { "*" };
}
internal static void PriorityLast()
{
ilHookConfig.After = new string[1] { "*" };
onHookConfig.After = new string[1] { "*" };
}
internal static void PriorityNormal()
{
ilHookConfig.Before = null;
onHookConfig.Before = null;
ilHookConfig.After = null;
onHookConfig.After = null;
}
internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate onHook)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
try
{
return (IDetour)new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig);
}
catch (Exception ex)
{
log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}");
}
return null;
}
}
internal static class Utilities
{
private static GameObject _prefabParent;
internal static GameObject CreatePrefab(GameObject gameObject)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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);
}
return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
}
internal static GameObject CreatePrefab(GameObject gameObject, string name)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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);
}
return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
}
internal static MethodInfo GetGenericMethod<T>(this Type type, string methodName, params Type[] parameters)
{
return type.GetMethod(methodName, parameters).MakeGenericMethod(typeof(T));
}
internal static AssetBundle LoadAssetBundle(string bundlePathName)
{
AssetBundle result = null;
try
{
result = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), bundlePathName));
}
catch (Exception ex)
{
log.error("Failed to load assetbundle\n" + ex);
}
return result;
}
internal static Obj GetAddressable<Obj>(string addressable) where Obj : Object
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<Obj>((object)addressable).WaitForCompletion();
}
internal static GameObject GetAddressable(string addressable)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<GameObject>((object)addressable).WaitForCompletion();
}
internal static void GetAddressable<Obj>(string addressable, Action<AsyncOperationHandle<Obj>> callback) where Obj : Object
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable);
val.Completed += callback;
}
internal static void GetAddressable(string addressable, Action<AsyncOperationHandle<GameObject>> callback)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += callback;
}
internal static void AddressableAddComp<Comp>(string addressable) where Comp : Component
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
a.Result.AddComponent<Comp>();
};
}
internal static void AddressableAddCompSingle<Comp>(string addressable) where Comp : Component
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
if (!Object.op_Implicit((Object)(object)a.Result.GetComponent<Comp>()))
{
a.Result.AddComponent<Comp>();
}
};
}
internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, string newValue)
{
ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
for (int i = 0; i < serializedFields.Length; i++)
{
if (serializedFields[i].fieldName == fieldName)
{
serializedFields[i].fieldValue.stringValue = newValue;
return;
}
}
log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
}
internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, Object newValue)
{
ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
for (int i = 0; i < serializedFields.Length; i++)
{
if (serializedFields[i].fieldName == fieldName)
{
serializedFields[i].fieldValue.objectValue = newValue;
return;
}
}
log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
}
}
}
namespace PingChat
{
internal static class Config
{
internal static ConfigFile configFile;
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<EliteIndex, ConfigEntry<Color>> eliteColors = new Dictionary<EliteIndex, ConfigEntry<Color>>();
internal static ConfigEntry<Color> itemIconColor;
internal static ConfigEntry<Color> interactableIconColor;
internal static void DoConfigs(ConfigFile bepConfigFile)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: 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_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Unknown result type (might be due to invalid IL or missing references)
//IL_0461: Unknown result type (might be due to invalid IL or missing references)
//IL_0493: Unknown result type (might be due to invalid IL or missing references)
configFile = bepConfigFile;
chatKey = configFile.Bind<KeyboardShortcut>("Misc", "Key", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), "The key for sending a custom chat message");
itemScale = configFile.Bind<float>("Misc", "Item icon scale", 0.67f, "Scale of item icon in pings");
moveDuration = configFile.Bind<float>("Durations", "Move ping duration", 6f, "Duration of move here ping");
interactDuration = configFile.Bind<float>("Durations", "Interactives ping duration", 30f, "Duration of interactives ping. Includes chests, shops, printers, teleporter, etc");
itemDuration = configFile.Bind<float>("Durations", "Item ping duration", 60f, "Duration of item ping. Includes scrappers and potentials");
enemyDuration = configFile.Bind<float>("Durations", "Enemy ping duration", 8f, "Duration of attack enemy ping");
chatToggle = configFile.Bind<bool>("Toggles", "Chat coloring toggle", true, "Toggles the coloring of chat");
enemyIconToggle = configFile.Bind<bool>("Toggles", "Enemy icon toggle", true, "Toggles changing the ping icons for enemies to their logbook icons");
enemyIconColorToggle = configFile.Bind<bool>("Toggles", "Elite enemy icon coloring toggle", true, "Toggles the coloring of elite enemy ping icons. If false, but icons are on, will use color of 'None'");
itemIconToggle = configFile.Bind<bool>("Toggles", "Item icon toggle", true, "Toggles changing the ping icons for items to their logbook icons");
shopItemIconToggle = configFile.Bind<bool>("Toggles", "Item icon toggle for multishops and printers", true, "Toggles changing the ping icons for items in multishops and printers");
eliteColors.Add((EliteIndex)0, configFile.Bind<Color>("Elite colors", "Blazing", new Color(0.8f, 0.21f, 0.15f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)1, eliteColors[(EliteIndex)0]);
eliteColors.Add((EliteIndex)2, configFile.Bind<Color>("Elite colors", "Celestine", new Color(0.55f, 0.79f, 0.8f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)3, configFile.Bind<Color>("Elite colors", "Glacial", new Color(0.84f, 0.96f, 0.97f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)4, eliteColors[(EliteIndex)3]);
eliteColors.Add((EliteIndex)5, configFile.Bind<Color>("Elite colors", "Overloading", new Color(0.3f, 0.45f, 1f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)6, eliteColors[(EliteIndex)5]);
eliteColors.Add((EliteIndex)7, configFile.Bind<Color>("Elite colors", "Perfected", new Color(0.34f, 0.45f, 0.58f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)8, configFile.Bind<Color>("Elite colors", "Malachite", new Color(0.58f, 0.86f, 0.61f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)10, configFile.Bind<Color>("Elite colors", "Mending", new Color(0.63f, 0.91f, 0.31f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)11, eliteColors[(EliteIndex)10]);
eliteColors.Add((EliteIndex)13, configFile.Bind<Color>("Elite colors", "Voidtouched", new Color(0.86f, 0.44f, 0.93f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)14, configFile.Bind<Color>("Elite colors", "Gilded", new Color(1f, 0.8f, 0.06f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)15, configFile.Bind<Color>("Elite colors", "Twisted", new Color(0.52f, 0.8f, 1f), "Color hex: (Red, Green, Blue, Alpha)"));
eliteColors.Add((EliteIndex)(-1), configFile.Bind<Color>("Elite colors", "None", new Color(1f, 1f, 1f), "Color hex: (Red, Green, Blue, Alpha)"));
itemIconColor = configFile.Bind<Color>("IColor", "Item icon color", new Color(1f, 1f, 1f), "Color of pinged item icons");
interactableIconColor = configFile.Bind<Color>("IColor", "Pinged interactable color", new Color(0.89f, 0.87f, 0.17f), "Color of pinged nteractables");
}
}
internal static class Messages
{
private static bool keyDown;
private static bool keySpent;
internal static void CheckInput()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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)
KeyboardShortcut value = Config.chatKey.Value;
if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
{
keyDown = true;
}
value = Config.chatKey.Value;
if (Input.GetKeyUp(((KeyboardShortcut)(ref value)).MainKey))
{
keyDown = false;
keySpent = false;
}
}
internal static void On_CheckPinging_CheckMessageKey(Action<PlayerCharacterMasterController> orig, PlayerCharacterMasterController self)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Invalid comparison between Unknown and I4
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Invalid comparison between Unknown and I4
//IL_012f: 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("attack " + 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("pickup " + displayName);
}
else if (Object.op_Implicit((Object)(object)val.GetComponent<SceneExitController>()))
{
SendChatMessage("hit the " + displayName);
}
else if (Object.op_Implicit((Object)(object)val.GetComponent<PickupIndexNetworker>()) && Object.op_Implicit((Object)(object)val.GetComponent<PickupPickerController>()))
{
SendChatMessage("open this " + 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.CurrentPickupIndex())?.nameToken ?? PickupCatalog.invalidPickupToken), provider: CultureInfo.InvariantCulture, format: "{0} ({1}) here", arg0: displayName));
}
else
{
SendChatMessage(displayName + " here");
}
}
keySpent = true;
}
private static void SendChatMessage(string message)
{
Console.instance.SubmitCmd(NetworkUser.readOnlyLocalPlayersList[0], "say \"" + message + "\"", false);
}
}
[BepInPlugin("dolso.pingchat", "ColoredPingChat", "1.2.2")]
public class PingChat : BaseUnityPlugin
{
private static EliteIndex currentEliteIndex = (EliteIndex)(-1);
private static PickupDef currentPickupDef = null;
private static Shader defaultSpriteShader;
private static Shader itemIconShader;
private void Awake()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
log.start(((BaseUnityPlugin)this).Logger);
Config.DoConfigs(((BaseUnityPlugin)this).Config);
LoadShader();
HookManager.Hook(typeof(PingIndicator), "RebuildPing", (Delegate)new Action<Action<PingIndicator>, PingIndicator>(On_PingIndicator_RebuildPing_Icons));
HookManager.Hook(typeof(PingIndicator), "RebuildPing", new Manipulator(IL_PingIndicator_RebuildPing_Text));
HookManager.Hook(typeof(PlayerCharacterMasterController), "CheckPinging", (Delegate)new Action<Action<PlayerCharacterMasterController>, PlayerCharacterMasterController>(Messages.On_CheckPinging_CheckMessageKey));
log.info("PingChat loaded");
}
private void Update()
{
Messages.CheckInput();
}
private void On_PingIndicator_RebuildPing_Icons(Action<PingIndicator> orig, PingIndicator self)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Invalid comparison between Unknown and I4
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Invalid comparison between Unknown and I4
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: 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;
if ((Object)(object)defaultSpriteShader == (Object)null)
{
defaultSpriteShader = ((Renderer)self.interactablePingGameObjects[0].GetComponent<SpriteRenderer>()).material.shader;
}
else
{
SpriteRenderer component = self.interactablePingGameObjects[0].GetComponent<SpriteRenderer>();
((Renderer)component).material.shader = defaultSpriteShader;
((Component)component).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
}
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);
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height);
component2.sprite = Sprite.Create(val, val2, new Vector2(0.5f, 0.5f));
if (Config.enemyIconColorToggle.Value)
{
component2.color = Config.eliteColors[currentEliteIndex].Value;
}
else
{
component2.color = Config.eliteColors[(EliteIndex)(-1)].Value;
}
currentEliteIndex = (EliteIndex)(-1);
}
else if ((int)self.pingType == 2 && currentPickupDef != null && Config.itemIconToggle.Value)
{
SpriteRenderer component4 = self.interactablePingGameObjects[0].GetComponent<SpriteRenderer>();
if (!Object.op_Implicit((Object)(object)component4))
{
Debug.LogWarning((object)"no sprite");
return;
}
component4.sprite = currentPickupDef.iconSprite;
((Component)component4).transform.localScale = new Vector3(Config.itemScale.Value * 0.1f, Config.itemScale.Value * 0.1f, 0.1f);
currentPickupDef = null;
}
}
private void IL_PingIndicator_RebuildPing_Text(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Unknown result type (might be due to invalid IL or missing references)
//IL_045b: Unknown result type (might be due to invalid IL or missing references)
//IL_0467: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_040a: Unknown result type (might be due to invalid IL or missing references)
//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0532: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int textIndex = 4;
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.LogError("failed to find text");
}
if (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>)delegate(string text, PingIndicator self)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: 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)
CharacterBody component4 = self.pingTarget.GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component4) && component4.isElite)
{
BuffIndex[] eliteBuffIndices = BuffCatalog.eliteBuffIndices;
foreach (BuffIndex val2 in eliteBuffIndices)
{
if (component4.HasBuff(val2))
{
EliteDef eliteDef = BuffCatalog.GetBuffDef(val2).eliteDef;
if (Config.eliteColors.ContainsKey(eliteDef.eliteIndex))
{
currentEliteIndex = eliteDef.eliteIndex;
if (Config.chatToggle.Value)
{
string text2 = Language.GetStringFormatted(eliteDef.modifierToken, new object[1] { "" }).Trim();
return text.Replace(text2, Util.GenerateColoredString(text2, Color32.op_Implicit(Config.eliteColors[currentEliteIndex].Value)));
}
}
}
}
}
return text;
});
}
else
{
val.LogError("failed to find enemy ping");
}
int interactableIconIndex = 8;
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.LogError("failed to find interactableIcon");
}
int spriteRendererIndex = 9;
if (!val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, (MethodBase)typeof(GameObject).GetGenericMethod<SpriteRenderer>("GetComponent", Array.Empty<Type>()))
}) || !val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref spriteRendererIndex)
}))
{
val.LogError("failed to find spriteRenderer");
}
int pickupIndexIndex = 17;
if (!val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<ShopTerminalBehavior>(a, "CurrentPickupIndex")
}) || !val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref pickupIndexIndex)
}))
{
log.error("failed to find pickupIndex");
}
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(PickupCatalog), "GetPickupDef")
}))
{
val.Emit(OpCodes.Dup);
val.Emit(OpCodes.Ldloc, interactableIconIndex);
val.Emit(OpCodes.Ldloc, spriteRendererIndex);
val.EmitDelegate<Func<PickupDef, Sprite, SpriteRenderer, Sprite>>((Func<PickupDef, Sprite, SpriteRenderer, Sprite>)delegate(PickupDef pickupDef, Sprite sprite, SpriteRenderer spriteRenderer)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (Config.shopItemIconToggle.Value && pickupDef != null && (Object)(object)pickupDef.iconSprite != (Object)null)
{
sprite = pickupDef.iconSprite;
((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;
});
val.Emit(OpCodes.Stloc, interactableIconIndex);
}
else
{
val.LogError("Failed shop icon replacement");
}
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<Language>(a, "GetString")
}))
{
val.Emit(OpCodes.Ldloc, pickupIndexIndex);
val.EmitDelegate<Func<string, PickupIndex, string>>((Func<string, PickupIndex, string>)((string name, PickupIndex pickupindex) => Config.chatToggle.Value ? Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(pickupindex).baseColor)) : name));
}
else
{
val.LogError("Failed shop item name coloring");
}
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "?")
}))
{
val.Emit(OpCodes.Ldloc, pickupIndexIndex);
val.EmitDelegate<Func<string, PickupIndex, string>>((Func<string, PickupIndex, string>)((string name, PickupIndex pickupindex) => Config.chatToggle.Value ? Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(pickupindex).baseColor)) : name));
}
else
{
val.LogError("Failed to find ? item");
}
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.LogError("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>)delegate(string name, GameObject target)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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)
//IL_0062: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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.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.pickupIndex).baseColor));
}
PickupDropletController component3 = target.GetComponent<PickupDropletController>();
if (Object.op_Implicit((Object)(object)component3))
{
Debug.Log((object)"PICKUPDROPLETCONTROLLER");
return Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(component3.pickupIndex).baseColor));
}
return name;
});
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>)(() => (Config.itemIconToggle.Value && currentPickupDef != null) ? Config.itemIconColor.Value : Config.interactableIconColor.Value));
val.Emit(OpCodes.Callvirt, (MethodBase)typeof(SpriteRenderer).GetMethod("set_color"));
}
private static void LoadShader()
{
AssetBundle obj = Utilities.LoadAssetBundle("itemicon");
itemIconShader = obj.LoadAsset<Shader>("ItemIcon.shader");
obj.Unload(false);
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCReloadConfig(ConCommandArgs args)
{
Config.configFile.Reload();
}
}
}