using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using ModdingTales;
using Newtonsoft.Json;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RingColorPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RingColorPlugin")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("RingColorPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("2.1.0.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.ringcolor", "Ring Color Plug-In", "2.1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RingColorPlugin : BaseUnityPlugin
{
public static class Utility
{
public static void PostOnMainPage(BaseUnityPlugin plugin)
{
string text = "Lord Ashes" + ("Lord Ashes".ToUpper().EndsWith("S") ? "'" : "'s");
ModdingUtils.AddPluginToMenuList(plugin, text);
}
}
public class RingRequest
{
public object creature { get; set; } = null;
public string ring { get; set; } = null;
}
public const string Name = "Ring Color Plug-In";
public const string Guid = "org.lordashes.plugins.ringcolor";
public const string Version = "2.1.0.0";
public const string Author = "Lord Ashes";
private static Dictionary<string, string> colors = new Dictionary<string, string>();
public static Type _RadialUIPlugin = Reflection.Type("RadialUIPlugin", (string[])null, (string[])null, 0);
public static Type _RadialSubmenu = Reflection.Type("RadialSubmenu", (string[])null, (string[])null, 0);
public static Type _CreaturePresenter = Reflection.Type("CreaturePresenter", (string[])null, (string[])null, 0);
public const int enumCharacter = 1;
private void Awake()
{
//IL_0018: 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_0038: Unknown result type (might be due to invalid IL or missing references)
LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
LoggingPlugin.LogInfo(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")");
LoggingPlugin.LogInfo("Using Radial UI: " + Reflection.Field(_RadialUIPlugin, "Guid", (string)null).GetValue(null)?.ToString() + " Version " + Reflection.Field(_RadialUIPlugin, "Version", (string)null).GetValue(null));
try
{
LoggingPlugin.LogInfo("Setting Colors");
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 01 Name", "Red", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 01 Value", "FF0000", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 02 Name", "Green", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 02 Value", "00FF00", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 03 Name", "Blue", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 03 Value", "0000FF", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 04 Name", "Yellow", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 04 Value", "FFFF00", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 05 Name", "Cyan", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 05 Value", "00FFFF", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 06 Name", "Magenta", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 06 Value", "FF00FF", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 07 Name", "Orange", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 07 Value", "FF8C00", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 08 Name", "Brown", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 08 Value", "644117", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 09 Name", "White", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 09 Value", "FFFFFF", (ConfigDescription)null).Value);
colors.Add(((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 10 Name", "Black", (ConfigDescription)null).Value, ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "Color 10 Value", "000000", (ConfigDescription)null).Value);
LoggingPlugin.LogInfo("Ensuring Top Menu");
Sprite val = Image.LoadSprite("RingColor.png", (CacheType)999);
LoggingPlugin.LogDebug("Invoking EnsureMainMenuItem Method");
Reflection.Execute(Reflection.Method(_RadialSubmenu, "EnsureMainMenuItem", new string[4] { "System.String", "RadialUI.RadialSubmenu+MenuType", "System.String", "UnityEngine.Sprite" }), (object)null, new object[4] { "org.lordashes.plugins.ringcolor", 1, "Ring Color", val }, 0);
LoggingPlugin.LogInfo("Adding Menu Items");
foreach (KeyValuePair<string, string> entry in colors)
{
LoggingPlugin.LogDebug("Registering Color '" + entry.Key + "' With Value '" + entry.Value + "'");
Sprite val2 = val;
if (File.Exists("Ring" + entry.Key + ".png"))
{
val2 = Image.LoadSprite("Ring" + entry.Key + ".png", (CacheType)999);
}
MethodInfo methodInfo = Reflection.Method(_RadialSubmenu, "CreateSubMenuItem", new string[6] { "System.String", "System.String", "UnityEngine.Sprite", "System.Action`3[CreatureGuid,System.String,MapMenuItem]", "System.Boolean", "System.Func`1[System.Boolean]" });
Reflection.Execute(methodInfo, (object)null, new object[6]
{
"org.lordashes.plugins.ringcolor",
entry.Key,
val2,
(Action<object[]>)delegate
{
Callback(entry.Key);
},
true,
null
}, 0);
}
}
catch (Exception ex)
{
LoggingPlugin.LogError("Error Setting Up Menu: " + ex.Message);
}
try
{
LoggingPlugin.LogInfo("Subscribing");
AssetDataPlugin.Subscribe("org.lordashes.plugins.ringcolor", (Action<DatumChange>)delegate(DatumChange request)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
LoggingPlugin.LogDebug("Asset Data Subscription Callback");
if ((int)request.action != 1)
{
LoggingPlugin.LogInfo(JsonConvert.SerializeObject((object)request));
Type type = Reflection.Type("CreatureGuid", (string[])null, (string[])null, 0);
object obj = null;
try
{
obj = Reflection.New(type, new object[1] { request.source.ToString() });
}
catch (Exception ex3)
{
LoggingPlugin.LogError("Exception Creating New CreatureGuid");
Reflection.CatchFullError(ex3);
}
try
{
LoggingPlugin.LogDebug("Obtained CreatureGuid");
object[] array = new object[2] { obj, null };
object obj2 = Reflection.Execute(Reflection.Method(_CreaturePresenter, "TryGetAsset", (string[])null), (object)null, array, 2);
if (obj2 != null)
{
Color val3 = default(Color);
ColorUtility.TryParseHtmlString("#" + request.value, ref val3);
LoggingPlugin.LogDebug("Switching To Ring Color '" + ((object)(Color)(ref val3)).ToString() + "' For '" + Reflection.Property(obj2.GetType(), "Name", (string)null).GetValue(obj2));
Reflection.Execute(Reflection.Method(obj2.GetType(), "SetFactionColor", (string[])null), obj2, new object[1] { val3 }, 0);
Reflection.Execute(Reflection.Method(obj2.GetType(), "Deselect", (string[])null), obj2, new object[0], 0);
Reflection.Execute(Reflection.Method(obj2.GetType(), "Select", (string[])null), obj2, new object[0], 0);
}
}
catch (Exception ex4)
{
LoggingPlugin.LogError("Exception Getting Ring Asset");
Reflection.CatchFullError(ex4);
}
}
});
}
catch (Exception ex2)
{
LoggingPlugin.LogError("Error Subscribing: " + ex2.Message);
Reflection.CatchFullError(ex2);
}
Utility.PostOnMainPage((BaseUnityPlugin)(object)this);
}
private void Callback(string selection)
{
LoggingPlugin.LogDebug("Radial Menu Callback");
try
{
object obj = Reflection.Execute(Reflection.Method(_RadialUIPlugin, "GetLastRadialTargetCreature", (string[])null), (object)null, new object[0], 0);
if (obj == null)
{
return;
}
try
{
LoggingPlugin.LogDebug("Requesting Ring Color '" + selection + "' (" + colors[selection] + ")");
AssetDataPlugin.ClearInfo(obj.ToString(), "org.lordashes.plugins.ringcolor", false);
AssetDataPlugin.SetInfo(obj.ToString(), "org.lordashes.plugins.ringcolor", colors[selection], false);
}
catch (Exception innerException)
{
LoggingPlugin.LogError("Exception Getting Radial Target Asset");
LoggingPlugin.LogError(innerException.Message);
while (innerException.InnerException != null)
{
innerException = innerException.InnerException;
LoggingPlugin.LogError(innerException.Message);
}
}
}
catch (Exception innerException2)
{
LoggingPlugin.LogError("Exception Getting Radial Target");
LoggingPlugin.LogError(innerException2.Message);
while (innerException2.InnerException != null)
{
innerException2 = innerException2.InnerException;
LoggingPlugin.LogError(innerException2.Message);
}
}
}
}