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.Reflection;
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.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 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);
private 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 (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 ConfigEnabled<bool> boolConfigEnabled = BoolEnabled;
private static ILHookConfig ilHookConfig = new ILHookConfig
{
ManualApply = true
};
private static HookConfig onHookConfig = new HookConfig
{
ManualApply = true
};
internal static void Hook(Type typeFrom, string fromMethod, Manipulator ilHook)
{
Hook(GetMethod(typeFrom, fromMethod), ilHook);
}
internal static void Hook(Delegate fromMethod, Manipulator ilHook)
{
Hook(fromMethod.Method, ilHook);
}
internal static void Hook(MethodBase fromMethod, Manipulator ilHook)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
try
{
new ILHook(fromMethod, ilHook, ref ilHookConfig).Apply();
}
catch (Exception e)
{
e.LogHookError(fromMethod, ((Delegate)(object)ilHook).Method);
}
}
internal static void Hook(Type typeFrom, string fromMethod, Delegate onHook)
{
Hook(GetMethod(typeFrom, fromMethod), onHook.Method, onHook.Target);
}
internal static void Hook(Delegate fromMethod, Delegate onHook)
{
Hook(fromMethod.Method, onHook.Method, onHook.Target);
}
internal static void Hook(MethodBase fromMethod, Delegate onHook)
{
Hook(fromMethod, onHook.Method, onHook.Target);
}
internal static void Hook(MethodBase fromMethod, MethodInfo onHook, object target = null)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
try
{
new Hook(fromMethod, onHook, target, ref onHookConfig).Apply();
}
catch (Exception e)
{
e.LogHookError(fromMethod, onHook);
}
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string fromMethod, Delegate hook)
{
configEntry.HookConfig(boolConfigEnabled, GetMethod(typeFrom, fromMethod), hook.Method, hook.Target);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase fromMethod, Delegate hook)
{
configEntry.HookConfig(boolConfigEnabled, fromMethod, hook.Method, hook.Target);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase fromMethod, MethodInfo hook)
{
configEntry.HookConfig(boolConfigEnabled, fromMethod, hook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string fromMethod, Delegate hook)
{
configEntry.HookConfig(enabled, GetMethod(typeFrom, fromMethod), hook.Method, hook.Target);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase fromMethod, Delegate hook)
{
configEntry.HookConfig(enabled, fromMethod, hook.Method, hook.Target);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase fromMethod, MethodInfo hook, object target = null)
{
try
{
new HookedConfig<T>(configEntry, enabled, ManualDetour(fromMethod, hook, target));
}
catch (Exception e)
{
e.LogHookError(fromMethod, hook);
}
}
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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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 i = 0; i < array2.Length; i++)
{
text = text + "\n" + array2[i];
}
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;
}
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 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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_005b: 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)
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_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Expected O, but got Unknown
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_0090: 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_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)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_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)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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)
//IL_0031: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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);
}
}
}
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<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_016b: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
Config.configFile = configFile;
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");
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 interactables");
not_elite_color = configFile.Bind<Color>("Elite colors", "None", new Color(1f, 1f, 1f), "Color hex: (Red, Green, Blue, Alpha)");
attack_message = configFile.Bind<string>("Messages", "Body", "attack {0}", "Enemies and allies. {0} is body name");
pickup_message = configFile.Bind<string>("Messages", "Pickup", "pickup {0}", "Items and other pickups. {0} is pickup name");
teleporter_message = configFile.Bind<string>("Messages", "Teleporter", "hit the {0}", "Teleporter and portals. {0} is the porter name");
potential_message = configFile.Bind<string>("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 = configFile.Bind<string>("Messages", "Shop", "{0} [{1}] here", "Tri-shops and printers. {0} is the building name, {1} is the item name");
other_message = configFile.Bind<string>("Messages", "Other", "{0} here", "For anything else. {0} is the display name");
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetupEliteColors));
if (RiskofOptions.enabled)
{
DoRoO();
}
}
private static void SetupEliteColors()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
elite_colors.Add(Elites.Fire, configFile.Bind<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, configFile.Bind<Color>("Elite colors", "Celestine", new Color(0.55f, 0.79f, 0.8f), "Color hex: (Red, Green, Blue, Alpha)"));
elite_colors.Add(Elites.Ice, configFile.Bind<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, configFile.Bind<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, configFile.Bind<Color>("Elite colors", "Perfected", new Color(0.34f, 0.45f, 0.58f), "Color hex: (Red, Green, Blue, Alpha)"));
elite_colors.Add(Elites.Poison, configFile.Bind<Color>("Elite colors", "Malachite", new Color(0.58f, 0.86f, 0.61f), "Color hex: (Red, Green, Blue, Alpha)"));
elite_colors.Add(Elites.Earth, configFile.Bind<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, configFile.Bind<Color>("Elite colors", "Voidtouched", new Color(0.86f, 0.44f, 0.93f), "Color hex: (Red, Green, Blue, Alpha)"));
elite_colors.Add(Elites.Aurelionite, configFile.Bind<Color>("Elite colors", "Gilded", new Color(1f, 0.8f, 0.06f), "Color hex: (Red, Green, Blue, Alpha)"));
elite_colors.Add(Elites.Bead, configFile.Bind<Color>("Elite colors", "Twisted", new Color(0.52f, 0.8f, 1f), "Color hex: (Red, Green, Blue, Alpha)"));
elite_colors.Add(Elites.Collective, configFile.Bind<Color>("Elite colors", "Twisted", new Color(0.49f, 0.96f, 1f), "Color hex: (Red, Green, Blue, Alpha)"));
if (RiskofOptions.enabled)
{
DoRoOColors();
}
}
private static void DoRoO()
{
RiskofOptions.SetSpriteDefaultIcon();
RiskofOptions.AddOption((ConfigEntryBase)(object)chatToggle);
RiskofOptions.AddOption((ConfigEntryBase)(object)itemIconToggle);
RiskofOptions.AddOption((ConfigEntryBase)(object)shopItemIconToggle);
RiskofOptions.AddOption((ConfigEntryBase)(object)enemyIconToggle);
RiskofOptions.AddOption((ConfigEntryBase)(object)enemyIconColorToggle);
RiskofOptions.AddOption((ConfigEntryBase)(object)moveDuration);
RiskofOptions.AddOption((ConfigEntryBase)(object)interactDuration);
RiskofOptions.AddOption((ConfigEntryBase)(object)itemDuration);
RiskofOptions.AddOption((ConfigEntryBase)(object)enemyDuration);
RiskofOptions.AddOption((ConfigEntryBase)(object)itemIconColor);
RiskofOptions.AddOption((ConfigEntryBase)(object)interactableIconColor);
RiskofOptions.AddOption((ConfigEntryBase)(object)attack_message);
RiskofOptions.AddOption((ConfigEntryBase)(object)pickup_message);
RiskofOptions.AddOption((ConfigEntryBase)(object)teleporter_message);
RiskofOptions.AddOption((ConfigEntryBase)(object)potential_message);
RiskofOptions.AddOption((ConfigEntryBase)(object)shop_message);
RiskofOptions.AddOption((ConfigEntryBase)(object)other_message);
}
private static void DoRoOColors()
{
foreach (ConfigEntry<Color> item in elite_colors.Values.Distinct())
{
RiskofOptions.AddOption((ConfigEntryBase)(object)item);
}
}
}
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 CheckMessageKey_On_CheckPinging(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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Invalid comparison between Unknown and I4
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: 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;
}
private static void SendChatMessage(string message)
{
Console.instance.SubmitCmd(NetworkUser.readOnlyLocalPlayersList[0], "say \"" + message + "\"", false);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("dolso.pingchat", "ColoredPingChat", "1.2.5")]
public class PingChat : BaseUnityPlugin
{
private static EliteDef current_elite;
private static PickupDef currentPickupDef;
private static Shader defaultSpriteShader;
private static Shader itemIconShader;
private void Awake()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
Config.DoConfigs(((BaseUnityPlugin)this).Config);
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_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_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: 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_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: 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 && 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)
{
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 Text_IL_PingIndicator_RebuildPing(ILContext il)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: 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_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: 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);
}
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);
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>)delegate(string name, GameObject target)
{
//IL_0010: 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_0036: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
GenericPickupController component2 = target.GetComponent<GenericPickupController>();
if (Object.op_Implicit((Object)(object)component2))
{
currentPickupDef = PickupCatalog.GetPickupDef(component2.pickup.pickupIndex);
if (Config.chatToggle.Value)
{
return Util.GenerateColoredString(name, Color32.op_Implicit(currentPickupDef.baseColor));
}
return name;
}
if (!Config.chatToggle.Value)
{
return name;
}
PickupIndexNetworker component3 = target.GetComponent<PickupIndexNetworker>();
if (Object.op_Implicit((Object)(object)component3))
{
return Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(component3.pickupState.pickupIndex).baseColor));
}
PickupDropletController component4 = target.GetComponent<PickupDropletController>();
if (Object.op_Implicit((Object)(object)component4))
{
Debug.Log((object)"PICKUPDROPLETCONTROLLER");
return Util.GenerateColoredString(name, Color32.op_Implicit(PickupCatalog.GetPickupDef(component4.pickupState.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>)get_icon_color);
val.Emit(OpCodes.Callvirt, (MethodBase)typeof(SpriteRenderer).GetMethod("set_color"));
static string func(string text, PingIndicator self)
{
//IL_002f: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
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 Sprite func(PickupIndex pickupIndex, Sprite sprite, SpriteRenderer spriteRenderer)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
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;
}
static Color get_icon_color()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
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_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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 obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "itemicon"));
itemIconShader = obj.LoadAsset<Shader>("ItemIcon.shader");
obj.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();
}
}
}