using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using Gumatos.RealmApi.Skills;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("RealmApi.Hooks")]
[assembly: InternalsVisibleTo("RealmApi.Smoke")]
[assembly: InternalsVisibleTo("RealmApi")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("RealmApi.Core")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("RealmApi.Core")]
[assembly: AssemblyTitle("RealmApi.Core")]
[assembly: AssemblyVersion("0.1.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace Gumatos.RealmApi
{
public static class ApiIdentity
{
public const string Guid = "com.gumatos.realmapi";
public const string Name = "RealmApi";
public const string Version = "0.1.0";
public const int SteamAppId = 1330000;
public const string GameVersion = "1.3.1";
public const string SteamBuildId = "25240684";
public const string AssemblySha256 = "8bb4a7c512da20770a81dfac0347e9a68a8c0eff736f4566c52a66923b37855a";
public static bool Matches(string version, string sha256)
{
if (string.Equals(version, "1.3.1", StringComparison.Ordinal))
{
return string.Equals(sha256, "8bb4a7c512da20770a81dfac0347e9a68a8c0eff736f4566c52a66923b37855a", StringComparison.OrdinalIgnoreCase);
}
return false;
}
}
public sealed class HookDescriptor
{
public string Id { get; }
public string TypeName { get; }
public string MethodName { get; }
public bool IsStatic { get; }
public string ReturnType { get; }
public IReadOnlyList<string> ParameterTypes { get; }
public HookDescriptor(string id, string typeName, string methodName, bool isStatic, string returnType, params string[] parameters)
{
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentException("Hook ID vazio", "id");
}
Id = id;
TypeName = typeName;
MethodName = methodName;
IsStatic = isStatic;
ReturnType = returnType;
ParameterTypes = Array.AsReadOnly((string[])parameters.Clone());
}
public MethodInfo Resolve(Assembly assembly)
{
MethodInfo[] array = (from m in (assembly.GetType(TypeName, throwOnError: false, ignoreCase: false) ?? throw new MissingMemberException(TypeName)).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where m.Name == MethodName && m.IsStatic == IsStatic && m.ReturnType.FullName == ReturnType && (from p in m.GetParameters()
select p.ParameterType.FullName).SequenceEqual<string>(ParameterTypes)
select m).ToArray();
if (array.Length != 1)
{
throw new MissingMethodException($"{Id}: esperado 1 alvo, encontrados {array.Length}");
}
return array[0];
}
}
public static class HookCatalog
{
public static IReadOnlyList<HookDescriptor> All { get; } = Array.AsReadOnly(new HookDescriptor[4]
{
new HookDescriptor("game.awake", "Burst2Flame.Game", "Awake", false, "System.Void"),
new HookDescriptor("ui.skill-tree.updated", "SkillTreeManager", "UpdateSkillTreeItems", false, "System.Void"),
new HookDescriptor("ui.localized", "OptionsManager", "Localize", true, "System.String", "System.String", "LanguageGender", "Gender"),
new HookDescriptor("combat.turn-started", "GameLogic", "StartNewTurn", false, "System.Void")
});
}
public sealed class HookNotification
{
public string HookId { get; }
public object? Instance { get; }
public IReadOnlyList<object?> Arguments { get; }
public object? Result { get; }
internal HookNotification(string id, object? instance, object?[] arguments, object? result)
{
HookId = id;
Instance = instance;
Arguments = Array.AsReadOnly((object[])arguments.Clone());
Result = result;
}
}
public sealed class Signal<T>
{
private sealed class Subscription : IDisposable
{
private Action? remove;
public Subscription(Action remove)
{
this.remove = remove;
}
public void Dispose()
{
Interlocked.Exchange(ref remove, null)?.Invoke();
}
}
private readonly object gate = new object();
private readonly Dictionary<long, Action<T>> listeners = new Dictionary<long, Action<T>>();
private long next;
public IDisposable Subscribe(Action<T> handler)
{
if (handler == null)
{
throw new ArgumentNullException("handler");
}
long id;
lock (gate)
{
id = ++next;
listeners.Add(id, handler);
}
return new Subscription(delegate
{
lock (gate)
{
listeners.Remove(id);
}
});
}
internal void Publish(T value, Action<Exception>? report = null)
{
Action<T>[] array;
lock (gate)
{
array = listeners.Values.ToArray();
}
Action<T>[] array2 = array;
foreach (Action<T> action in array2)
{
try
{
action(value);
}
catch (Exception obj)
{
try
{
report?.Invoke(obj);
}
catch
{
}
}
}
}
}
public static class RealmHooks
{
public static Signal<HookNotification> Observed { get; } = new Signal<HookNotification>();
internal static void Emit(string id, object? instance, object?[] arguments, object? result, Action<Exception>? report)
{
Observed.Publish(new HookNotification(id, instance, arguments, result), report);
}
}
public static class RealmAccess
{
public static object? ReadProperty(Assembly assembly, string typeName, string propertyName, object? instance = null)
{
Type type = assembly.GetType(typeName, throwOnError: false, ignoreCase: false) ?? throw new MissingMemberException(typeName);
PropertyInfo? obj = type.GetProperty(propertyName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public) ?? throw new MissingMemberException(typeName, propertyName);
MethodInfo methodInfo = obj.GetGetMethod() ?? throw new MissingMethodException(typeName, propertyName);
if (obj.GetIndexParameters().Length != 0)
{
throw new ArgumentException("Indexer não suportado");
}
if (!methodInfo.IsStatic && (instance == null || !type.IsInstanceOfType(instance)))
{
throw new ArgumentException("Instância incompatível");
}
return obj.GetValue(methodInfo.IsStatic ? null : instance);
}
}
public enum UiMemberKind
{
Host,
Method,
Property,
Field
}
public sealed class UiRequirement
{
public string Id { get; }
public string FamilyType { get; }
public UiMemberKind Kind { get; }
public string TypeName { get; }
public string MemberName { get; }
public bool IsStatic { get; }
public string ReturnType { get; }
public IReadOnlyList<string> ParameterTypes { get; }
public string HostSelector { get; }
public UiRequirement(string id, string familyType, string typeName, string memberName, UiMemberKind kind, bool isStatic, string returnType, params string[] parameters)
{
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentException("Requisito sem ID", "id");
}
if (string.IsNullOrWhiteSpace(familyType))
{
throw new ArgumentException("Requisito sem familia", "familyType");
}
if (string.IsNullOrWhiteSpace(typeName))
{
throw new ArgumentException("Requisito sem tipo", "typeName");
}
if (kind != UiMemberKind.Host && string.IsNullOrWhiteSpace(memberName))
{
throw new ArgumentException("Requisito de membro sem nome", "memberName");
}
Id = id;
FamilyType = familyType;
Kind = kind;
TypeName = typeName;
MemberName = memberName;
IsStatic = isStatic;
ReturnType = returnType;
ParameterTypes = Array.AsReadOnly((string[])parameters.Clone());
HostSelector = string.Empty;
}
private UiRequirement(string id, string familyType, string typeName, string hostSelector)
{
Id = id;
FamilyType = familyType;
Kind = UiMemberKind.Host;
TypeName = typeName;
MemberName = string.Empty;
IsStatic = false;
ReturnType = string.Empty;
ParameterTypes = Array.AsReadOnly(Array.Empty<string>());
HostSelector = hostSelector;
}
public static UiRequirement Host(string id, string familyType, string typeName, string hostSelector)
{
return new UiRequirement(id, familyType, typeName, hostSelector);
}
public Type ResolveType(Assembly assembly)
{
if (assembly == null)
{
throw new ArgumentNullException("assembly");
}
return assembly.GetType(TypeName, throwOnError: false, ignoreCase: false) ?? throw new MissingMemberException(TypeName);
}
public MemberInfo Resolve(Assembly assembly)
{
Type type = ResolveType(assembly);
if (Kind == UiMemberKind.Host)
{
throw new InvalidOperationException("Requisito de hospedeiro nao resolve membro: " + Id);
}
MemberInfo[] array = Kind switch
{
UiMemberKind.Method => (from m in type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where m.Name == MemberName && m.IsStatic == IsStatic && m.ReturnType.FullName == ReturnType && (from p in m.GetParameters()
select p.ParameterType.FullName).SequenceEqual<string>(ParameterTypes)
select m).Cast<MemberInfo>().ToArray(),
UiMemberKind.Property => (from p in type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where p.Name == MemberName && p.GetIndexParameters().Length == 0 && p.PropertyType.FullName == ReturnType && (p.GetGetMethod(nonPublic: true)?.IsStatic == IsStatic || p.GetSetMethod(nonPublic: true)?.IsStatic == IsStatic)
select p).Cast<MemberInfo>().ToArray(),
UiMemberKind.Field => (from f in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where f.Name == MemberName && f.IsStatic == IsStatic && f.FieldType.FullName == ReturnType
select f).Cast<MemberInfo>().ToArray(),
_ => throw new InvalidOperationException("Natureza desconhecida: " + Kind),
};
if (array.Length != 1)
{
throw new MissingMethodException($"{Id}: esperado 1 alvo, encontrados {array.Length}");
}
return array[0];
}
}
public sealed class UiHosts
{
public object? GuiManager { get; set; }
public object? CurrentCharacterUi { get; set; }
public object? SkillTreeManager { get; set; }
public object? MenuTabManager { get; set; }
public static UiHosts Empty { get; } = new UiHosts();
}
public static class UiRequirements
{
public const string FamilyFactory = "Gumatos.RealmApi.UI.UIFactory";
public const string FamilyActionBar = "Gumatos.RealmApi.UI.ActionBarUI";
public const string FamilySkillTree = "Gumatos.RealmApi.UI.SkillTreeUI";
public const string FamilyMenu = "Gumatos.RealmApi.UI.MenuUI";
public const string FamilyTooltip = "Gumatos.RealmApi.UI.TooltipHelper";
public static IReadOnlyList<UiRequirement> All { get; } = Array.AsReadOnly(new UiRequirement[16]
{
UiRequirement.Host("ui.factory.host", "Gumatos.RealmApi.UI.UIFactory", "GUIManager", "GuiManager"),
new UiRequirement("ui.factory.instance", "Gumatos.RealmApi.UI.UIFactory", "GUIManager", "instance", UiMemberKind.Property, true, "GUIManager"),
UiRequirement.Host("ui.action-bar.host", "Gumatos.RealmApi.UI.ActionBarUI", "CurrentCharacterUI", "CurrentCharacterUi"),
new UiRequirement("ui.action-bar.instance", "Gumatos.RealmApi.UI.ActionBarUI", "CurrentCharacterUI", "Instance", UiMemberKind.Property, true, "CurrentCharacterUI"),
new UiRequirement("ui.action-bar.skillbar", "Gumatos.RealmApi.UI.ActionBarUI", "CurrentCharacterUI", "ActiveSkillbar", UiMemberKind.Property, false, "Skillbar"),
new UiRequirement("ui.action-bar.probe", "Gumatos.RealmApi.UI.ActionBarUI", "Skillbar", "HasAvailableSlot", UiMemberKind.Method, false, "System.Boolean"),
new UiRequirement("ui.action-bar.refresh", "Gumatos.RealmApi.UI.ActionBarUI", "Skillbar", "RefreshSkillBar", UiMemberKind.Method, false, "System.Void"),
UiRequirement.Host("ui.skill-tree.host", "Gumatos.RealmApi.UI.SkillTreeUI", "SkillTreeManager", "SkillTreeManager"),
new UiRequirement("ui.skill-tree.probe", "Gumatos.RealmApi.UI.SkillTreeUI", "SkillTreeManager", "IsNotNullAndIsActive", UiMemberKind.Property, true, "System.Boolean"),
new UiRequirement("ui.skill-tree.refresh", "Gumatos.RealmApi.UI.SkillTreeUI", "SkillTreeManager", "UpdateSkillTreeItems", UiMemberKind.Method, false, "System.Void"),
UiRequirement.Host("ui.menu.host", "Gumatos.RealmApi.UI.MenuUI", "MenuTabManager", "MenuTabManager"),
new UiRequirement("ui.menu.instance", "Gumatos.RealmApi.UI.MenuUI", "MenuTabManager", "RefreshSelected", UiMemberKind.Method, false, "System.Void"),
UiRequirement.Host("ui.tooltip.host", "Gumatos.RealmApi.UI.TooltipHelper", "GUIManager", "GuiManager"),
new UiRequirement("ui.tooltip.instance", "Gumatos.RealmApi.UI.TooltipHelper", "GUIManager", "instance", UiMemberKind.Property, true, "GUIManager"),
new UiRequirement("ui.tooltip.link", "Gumatos.RealmApi.UI.TooltipHelper", "GUIManager", "tooltip", UiMemberKind.Field, false, "Tooltip"),
new UiRequirement("ui.tooltip.hide", "Gumatos.RealmApi.UI.TooltipHelper", "Tooltip", "HideTooltip", UiMemberKind.Method, false, "System.Void")
});
public static IReadOnlyList<UiRequirement> ForFamily(string familyType)
{
if (string.IsNullOrWhiteSpace(familyType))
{
throw new ArgumentException("Familia vazia", "familyType");
}
return Array.AsReadOnly(All.Where((UiRequirement r) => r.FamilyType == familyType).ToArray());
}
}
public static class UiFamily
{
private static readonly object gate = new object();
private static Dictionary<string, MemberInfo> members = new Dictionary<string, MemberInfo>();
private static Dictionary<string, object?> hosts = new Dictionary<string, object>();
private static int threadId;
private static bool mutation;
public static bool IsBound { get; private set; }
public static bool MutationEnabled
{
get
{
lock (gate)
{
return mutation;
}
}
}
public static int BoundThreadId
{
get
{
lock (gate)
{
return threadId;
}
}
}
public static IReadOnlyCollection<string> BoundRequirementIds
{
get
{
lock (gate)
{
return (IReadOnlyCollection<string>)(object)members.Keys.Concat(hosts.Keys).OrderBy<string, string>((string x) => x, StringComparer.Ordinal).ToArray();
}
}
}
public static void Bind(Assembly gameAssembly, UiHosts hosts, bool allowMutation = false)
{
if (gameAssembly == null)
{
throw new ArgumentNullException("gameAssembly");
}
if (hosts == null)
{
throw new ArgumentNullException("hosts");
}
Dictionary<string, MemberInfo> dictionary = new Dictionary<string, MemberInfo>();
Dictionary<string, object> dictionary2 = new Dictionary<string, object>();
foreach (UiRequirement item in UiRequirements.All)
{
if (item.Kind == UiMemberKind.Host)
{
item.ResolveType(gameAssembly);
object value = (typeof(UiHosts).GetProperty(item.HostSelector) ?? throw new InvalidOperationException("Seletor de hospedeiro desconhecido: " + item.HostSelector)).GetValue(hosts);
if (value != null && value.GetType().FullName != item.TypeName)
{
throw new ArgumentException("Hospedeiro divergente em " + item.Id + ": " + value.GetType().FullName + " != " + item.TypeName);
}
dictionary2.Add(item.Id, value);
}
else
{
dictionary.Add(item.Id, item.Resolve(gameAssembly));
}
}
lock (gate)
{
members = dictionary;
UiFamily.hosts = dictionary2;
threadId = Thread.CurrentThread.ManagedThreadId;
mutation = allowMutation;
IsBound = true;
}
UiOperations.Reset();
}
public static void Unbind()
{
lock (gate)
{
members = new Dictionary<string, MemberInfo>();
hosts = new Dictionary<string, object>();
mutation = false;
IsBound = false;
}
UiOperations.Reset();
}
internal static void Require(string familyType, bool mutates)
{
if (!IsBound)
{
throw new InvalidOperationException("Familia " + familyType + " exige UiFamily.Bind(assembly, hosts) antes de qualquer chamada");
}
if (mutates && !MutationEnabled)
{
throw new InvalidOperationException("Familia " + familyType + " muta UI: o vinculo precisa de allowMutation:true");
}
if (threadId != Thread.CurrentThread.ManagedThreadId)
{
throw new InvalidOperationException($"Familia {familyType} so pode ser usada no thread do vinculo (main thread do Unity); vinculada em {threadId}");
}
}
internal static object Host(string requirementId)
{
if (!hosts.TryGetValue(requirementId, out object value) || value == null)
{
throw new InvalidOperationException("Hospedeiro ausente: " + requirementId + " (nada foi assumido nem ignorado)");
}
return value;
}
internal static bool HasHost(string requirementId)
{
if (hosts.TryGetValue(requirementId, out object value))
{
return value != null;
}
return false;
}
private static MemberInfo Member(string requirementId)
{
if (!members.TryGetValue(requirementId, out MemberInfo value))
{
throw new InvalidOperationException("Requisito nao resolvido: " + requirementId);
}
return value;
}
internal static object? Read(string requirementId, object? instance = null)
{
MemberInfo memberInfo = Member(requirementId);
if (!(memberInfo is MethodInfo methodInfo))
{
if (!(memberInfo is PropertyInfo propertyInfo))
{
if (memberInfo is FieldInfo fieldInfo)
{
if (!fieldInfo.IsStatic && instance == null)
{
throw new InvalidOperationException("Alvo de instancia sem hospedeiro: " + requirementId);
}
return fieldInfo.GetValue(fieldInfo.IsStatic ? null : instance);
}
throw new InvalidOperationException("Requisito sem membro: " + requirementId);
}
MethodInfo methodInfo2 = propertyInfo.GetGetMethod(nonPublic: true) ?? throw new MissingMethodException(requirementId + ": sem getter");
if (!methodInfo2.IsStatic && instance == null)
{
throw new InvalidOperationException("Alvo de instancia sem hospedeiro: " + requirementId);
}
return propertyInfo.GetValue(methodInfo2.IsStatic ? null : instance);
}
if (!methodInfo.IsStatic && instance == null)
{
throw new InvalidOperationException("Alvo de instancia sem hospedeiro: " + requirementId);
}
if (methodInfo.GetParameters().Length != 0)
{
throw new InvalidOperationException("Leitura sem argumentos exige metodo sem parametros: " + requirementId);
}
return methodInfo.Invoke(methodInfo.IsStatic ? null : instance, null);
}
internal static object? Static(string requirementId)
{
return Read(requirementId);
}
}
internal static class UiOperations
{
internal sealed class ActionBarEntry
{
internal readonly object? Icon;
internal readonly Action? OnClick;
internal ActionBarEntry(object? icon, Action? onClick)
{
Icon = icon;
OnClick = onClick;
}
}
internal sealed class MenuEntry
{
internal readonly object? Builder;
internal readonly Action? OnClick;
internal MenuEntry(object? builder, Action? onClick)
{
Builder = builder;
OnClick = onClick;
}
}
internal sealed class TooltipRequest
{
internal readonly string Title;
internal readonly string Subtitle;
internal readonly object? Icon;
internal TooltipRequest(string title, string subtitle, object? icon)
{
Title = title;
Subtitle = subtitle;
Icon = icon;
}
}
private static readonly Dictionary<string, ActionBarEntry> actionBarButtons = new Dictionary<string, ActionBarEntry>(StringComparer.Ordinal);
private static readonly Dictionary<SkillTree, string> skillTreeTabs = new Dictionary<SkillTree, string>();
private static readonly Dictionary<string, MenuEntry> menuTabs = new Dictionary<string, MenuEntry>(StringComparer.Ordinal);
private static TooltipRequest? tooltipRequest;
internal static int ActionBarCount => actionBarButtons.Count;
internal static int SkillTreeTabCount => skillTreeTabs.Count;
internal static int MenuTabCount => menuTabs.Count;
internal static TooltipRequest? TooltipRequested => tooltipRequest;
internal static bool ActionBarHas(string id)
{
return actionBarButtons.ContainsKey(id);
}
internal static bool MenuHas(string id)
{
return menuTabs.ContainsKey(id);
}
internal static void Reset()
{
actionBarButtons.Clear();
skillTreeTabs.Clear();
menuTabs.Clear();
tooltipRequest = null;
}
internal static object FactoryHost()
{
UiFamily.Require("Gumatos.RealmApi.UI.UIFactory", mutates: false);
return UiFamily.Host("ui.factory.host");
}
private static object ActiveSkillbar()
{
object instance = UiFamily.Host("ui.action-bar.host");
return UiFamily.Read("ui.action-bar.skillbar", instance) ?? throw new InvalidOperationException("Barra de acao indisponivel: CurrentCharacterUI.ActiveSkillbar devolveu null");
}
internal static object ActionBarAdd(string id, object? icon, Action? onClick)
{
UiFamily.Require("Gumatos.RealmApi.UI.ActionBarUI", mutates: true);
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentException("Id do botao vazio", "id");
}
if (actionBarButtons.ContainsKey(id))
{
throw new ArgumentException("Botao ja registrado: " + id, "id");
}
object obj = ActiveSkillbar();
object obj2 = UiFamily.Read("ui.action-bar.probe", obj);
if (!(obj2 is bool) || !(bool)obj2)
{
throw new InvalidOperationException("Sem slot disponivel na barra de acao: Skillbar.HasAvailableSlot() = false");
}
actionBarButtons.Add(id, new ActionBarEntry(icon, onClick));
UiFamily.Read("ui.action-bar.refresh", obj);
return obj;
}
internal static object ActionBarRemove(string id)
{
UiFamily.Require("Gumatos.RealmApi.UI.ActionBarUI", mutates: true);
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentException("Id do botao vazio", "id");
}
object obj = ActiveSkillbar();
if (!actionBarButtons.Remove(id))
{
throw new InvalidOperationException("Botao nao registrado: " + id);
}
UiFamily.Read("ui.action-bar.refresh", obj);
return obj;
}
internal static object ActionBarUpdateIcon(string id, object? icon)
{
UiFamily.Require("Gumatos.RealmApi.UI.ActionBarUI", mutates: true);
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentException("Id do botao vazio", "id");
}
object obj = ActiveSkillbar();
if (!actionBarButtons.TryGetValue(id, out ActionBarEntry value))
{
throw new InvalidOperationException("Botao nao registrado: " + id);
}
actionBarButtons[id] = new ActionBarEntry(icon, value.OnClick);
UiFamily.Read("ui.action-bar.refresh", obj);
return obj;
}
internal static object SkillTreeAdd(string name, SkillTree tree)
{
UiFamily.Require("Gumatos.RealmApi.UI.SkillTreeUI", mutates: true);
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException("Nome da aba vazio", "name");
}
if (!Enum.IsDefined(typeof(SkillTree), tree))
{
throw new ArgumentOutOfRangeException("tree", tree, "Arvore fora do contrato");
}
if (skillTreeTabs.ContainsKey(tree))
{
throw new ArgumentException("Aba ja registrada: " + tree, "tree");
}
object obj = UiFamily.Host("ui.skill-tree.host");
object obj2 = UiFamily.Static("ui.skill-tree.probe");
if (!(obj2 is bool) || !(bool)obj2)
{
throw new InvalidOperationException("Arvore de habilidades indisponivel: SkillTreeManager.IsNotNullAndIsActive = false");
}
skillTreeTabs.Add(tree, name);
UiFamily.Read("ui.skill-tree.refresh", obj);
return obj;
}
internal static object SkillTreeRemove(SkillTree tree)
{
UiFamily.Require("Gumatos.RealmApi.UI.SkillTreeUI", mutates: true);
if (!Enum.IsDefined(typeof(SkillTree), tree))
{
throw new ArgumentOutOfRangeException("tree", tree, "Arvore fora do contrato");
}
object obj = UiFamily.Host("ui.skill-tree.host");
if (!skillTreeTabs.Remove(tree))
{
throw new InvalidOperationException("Aba nao registrada: " + tree);
}
UiFamily.Read("ui.skill-tree.refresh", obj);
return obj;
}
internal static bool SkillTreeHas(SkillTree tree)
{
UiFamily.Require("Gumatos.RealmApi.UI.SkillTreeUI", mutates: false);
if (!Enum.IsDefined(typeof(SkillTree), tree))
{
throw new ArgumentOutOfRangeException("tree", tree, "Arvore fora do contrato");
}
return skillTreeTabs.ContainsKey(tree);
}
internal static object MenuAdd(string name, object? builder, Action? onClick)
{
UiFamily.Require("Gumatos.RealmApi.UI.MenuUI", mutates: true);
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException("Nome da aba vazio", "name");
}
if (menuTabs.ContainsKey(name))
{
throw new ArgumentException("Aba ja registrada: " + name, "name");
}
object obj = UiFamily.Host("ui.menu.host");
menuTabs.Add(name, new MenuEntry(builder, onClick));
UiFamily.Read("ui.menu.instance", obj);
return obj;
}
internal static object MenuRemove(string name)
{
UiFamily.Require("Gumatos.RealmApi.UI.MenuUI", mutates: true);
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentException("Nome da aba vazio", "name");
}
object obj = UiFamily.Host("ui.menu.host");
if (!menuTabs.Remove(name))
{
throw new InvalidOperationException("Aba nao registrada: " + name);
}
UiFamily.Read("ui.menu.instance", obj);
return obj;
}
internal static object TooltipHost()
{
object instance = UiFamily.Host("ui.tooltip.host");
return UiFamily.Read("ui.tooltip.link", instance) ?? throw new InvalidOperationException("Tooltip nativo indisponivel: GUIManager.tooltip e null");
}
internal static object TooltipShow(string title, string subtitle, object? icon)
{
UiFamily.Require("Gumatos.RealmApi.UI.TooltipHelper", mutates: true);
if (string.IsNullOrWhiteSpace(title))
{
throw new ArgumentException("Titulo vazio", "title");
}
object result = TooltipHost();
tooltipRequest = new TooltipRequest(title, subtitle ?? string.Empty, icon);
return result;
}
internal static object TooltipHide()
{
UiFamily.Require("Gumatos.RealmApi.UI.TooltipHelper", mutates: true);
object obj = TooltipHost();
UiFamily.Read("ui.tooltip.hide", obj);
tooltipRequest = null;
return obj;
}
}
}
namespace Gumatos.RealmApi.Skills
{
public enum SkillTree
{
Chaos,
Cold,
Custom,
Fire,
Innate,
Light,
Lightning,
Monk,
Nature,
Ranger,
Shadow,
Thief,
Warrior
}
}