using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Xml; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using ModifAmorphic.Outward.ActionUI.DataModels; using ModifAmorphic.Outward.ActionUI.Extensions; using ModifAmorphic.Outward.ActionUI.Models; using ModifAmorphic.Outward.ActionUI.Monobehaviours; using ModifAmorphic.Outward.ActionUI.Patches; using ModifAmorphic.Outward.ActionUI.Plugin.Services; using ModifAmorphic.Outward.ActionUI.Services; using ModifAmorphic.Outward.ActionUI.Services.Injectors; using ModifAmorphic.Outward.ActionUI.Settings; using ModifAmorphic.Outward.Config; using ModifAmorphic.Outward.Config.Models; using ModifAmorphic.Outward.Coroutines; using ModifAmorphic.Outward.Extensions; using ModifAmorphic.Outward.GameObjectResources; using ModifAmorphic.Outward.Logging; using ModifAmorphic.Outward.Modules; using ModifAmorphic.Outward.Modules.Localization; using ModifAmorphic.Outward.Unity.ActionMenus; using ModifAmorphic.Outward.Unity.ActionUI; using ModifAmorphic.Outward.Unity.ActionUI.Data; using ModifAmorphic.Outward.Unity.ActionUI.EquipmentSets; using ModifAmorphic.Outward.Unity.ActionUI.Models.EquipmentSets; using Newtonsoft.Json; using Rewired; using Rewired.Data; using Rewired.Data.Mapping; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("ModifAmorphic.Outward.ActionUI.Plugin")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0748ee4c3e5cabdf3003c1bbf7caa92a7535e9c1")] [assembly: AssemblyProduct("ModifAmorphic.Outward.ActionUI.Plugin")] [assembly: AssemblyTitle("ModifAmorphic.Outward.ActionUI.Plugin")] [assembly: AssemblyVersion("1.0.0.0")] [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] public class ConfigurationManagerAttributes : Attribute { public bool? ShowRangeAsPercent; public Action CustomDrawer; public bool? Browsable; public string Category; public object DefaultValue; public bool? HideDefaultButton; public bool? HideSettingName; public string Description; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; } namespace ModifAmorphic.Outward.ActionUI { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("ModifAmorphic.Outward.ActionUI", "Action Bar", "1.1.2")] public class ActionUIPlugin : BaseUnityPlugin { private static ServicesProvider _servicesProvider; internal static BaseUnityPlugin Instance; internal static ServicesProvider Services => _servicesProvider; internal void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown Instance = (BaseUnityPlugin)(object)this; ActionUISettings.Init(((BaseUnityPlugin)this).Config); new GlobalConfigService(); IModifLogger val = null; Harmony val2 = new Harmony("ModifAmorphic.Outward.ActionUI"); try { val = LoggerFactory.ConfigureLogger("ModifAmorphic.Outward.ActionUI", "Action Bar", (LogLevel)2); val.LogInfo("Patching..."); val2.PatchAll(typeof(PauseMenuPatches)); val2.PatchAll(typeof(SplitPlayerPatches)); val2.PatchAll(typeof(LobbySystemPatches)); val2.PatchAll(typeof(CharacterUIPatches)); Startup startup = new Startup(); val.LogInfo("Starting Action Bar 1.1.2..."); _servicesProvider = new ServicesProvider((BaseUnityPlugin)(object)this); startup.Start(val2, _servicesProvider); } catch (Exception ex) { if (val != null) { val.LogException("Failed to enable ModifAmorphic.Outward.ActionUI Action Bar 1.1.2.", ex); } val2.UnpatchSelf(); throw; } } } internal class DurabilityDisplayStartup : IStartable { private readonly Harmony _harmony; private readonly ServicesProvider _services; private readonly Func _loggerFactory; private readonly ModifGoService _modifGoService; private readonly LevelCoroutines _coroutines; private readonly string DurabilityModId = "ModifAmorphic.Outward.ActionUI.DurabilityDisplay"; private IModifLogger Logger => _loggerFactory(); public DurabilityDisplayStartup(ServicesProvider services, ModifGoService modifGoService, LevelCoroutines coroutines, Func loggerFactory) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown _services = services; _modifGoService = modifGoService; _coroutines = coroutines; _loggerFactory = loggerFactory; _harmony = new Harmony(DurabilityModId); } public void Start() { Logger.LogInfo("Starting Durability Display..."); _harmony.PatchAll(typeof(EquipmentPatches)); _services.AddSingleton(new DurabilityDisplayService(_services.GetService(), _coroutines, _loggerFactory)); } } internal class HotbarsStartup : IStartable { private readonly Harmony _harmony; private readonly ServicesProvider _services; private readonly PlayerMenuService _playerMenuService; private readonly Func _loggerFactory; private readonly ModifGoService _modifGoService; private readonly LevelCoroutines _coroutines; private readonly string HotbarsModId = "ModifAmorphic.Outward.ActionUI.Hotbars"; private IModifLogger Logger => _loggerFactory(); public HotbarsStartup(ServicesProvider services, PlayerMenuService playerMenuService, ModifGoService modifGoService, LevelCoroutines coroutines, Func loggerFactory) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown _services = services; _playerMenuService = playerMenuService; _modifGoService = modifGoService; _coroutines = coroutines; _loggerFactory = loggerFactory; _harmony = new Harmony(HotbarsModId); } public void Start() { Logger.LogInfo("Starting Hotbars..."); Logger.LogInfo("Patching..."); _harmony.PatchAll(typeof(InputManager_BasePatches)); _harmony.PatchAll(typeof(RewiredInputsPatches)); _harmony.PatchAll(typeof(QuickSlotPanelPatches)); _harmony.PatchAll(typeof(ControlsInputPatches)); _harmony.PatchAll(typeof(CharacterQuickSlotManagerPatches)); _harmony.PatchAll(typeof(SkillMenuPatches)); _harmony.PatchAll(typeof(ItemDisplayDropGroundPatches)); _harmony.PatchAll(typeof(EquipmentPatches)); _services.AddSingleton(new HotbarServicesInjector(_services, _playerMenuService, _coroutines, _loggerFactory)); } public void Stop() { _harmony.UnpatchSelf(); } } internal class InventoryStartup : IStartable { private readonly Harmony _harmony; private readonly ServicesProvider _services; private readonly PlayerMenuService _playerMenuService; private readonly Func _loggerFactory; private readonly ModifGoService _modifGoService; private readonly LevelCoroutines _coroutines; private readonly string ModId = "ModifAmorphic.Outward.ActionUI.CharacterInventory"; private readonly LocalizationModule _localizationsModule; private IModifLogger Logger => _loggerFactory(); public InventoryStartup(ServicesProvider services, PlayerMenuService playerMenuService, ModifGoService modifGoService, LevelCoroutines coroutines, Func loggerFactory) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown _services = services; _playerMenuService = playerMenuService; _modifGoService = modifGoService; _coroutines = coroutines; _loggerFactory = loggerFactory; _harmony = new Harmony(ModId); _localizationsModule = ModifModules.GetLocalizationModule(ModId); } public void Start() { Logger.LogInfo("Starting Inventory Mods..."); try { _localizationsModule.RegisterLocalization("Context_Item_MoveToStash", "Move to Stash"); } catch (Exception ex) { Logger.LogWarning("Failed to register localizations in InventoryStartup. This is likely due to LocalizationManager not being ready yet. Proceeding with startup. Error: " + ex.Message); } _harmony.PatchAll(typeof(CharacterInventoryPatches)); _harmony.PatchAll(typeof(EquipmentMenuPatches)); _harmony.PatchAll(typeof(InventoryContentDisplayPatches)); _harmony.PatchAll(typeof(ItemDisplayPatches)); _harmony.PatchAll(typeof(ItemDisplayClickPatches)); _harmony.PatchAll(typeof(CurrencyDisplayClickPatches)); _harmony.PatchAll(typeof(NetworkInstantiateManagerPatches)); _harmony.PatchAll(typeof(CharacterManagerPatches)); _harmony.PatchAll(typeof(MenuPanelPatches)); _harmony.PatchAll(typeof(ItemDisplayOptionPanelPatches)); _services.AddSingleton(new InventoryServicesInjector(_services, _playerMenuService, _modifGoService, _coroutines, _loggerFactory)); } } internal interface IStartable { void Start(); } internal static class ModInfo { public const string ModId = "ModifAmorphic.Outward.ActionUI"; public const string ModName = "Action Bar"; public const string ModVersion = "1.1.2"; public const string MinimumConfigVersion = "1.0.0"; } internal static class Starter { private static IModifLogger Logger => LoggerFactory.GetLogger("ModifAmorphic.Outward.ActionUI"); public static bool TryStart(IStartable startable) { try { Logger.LogDebug("Starting " + startable.GetType().Name + "."); startable.Start(); return true; } catch (Exception ex) { Logger.LogException("Failed to start " + startable.GetType().Name + ".", ex); } return false; } } internal class Startup { private ServicesProvider _services; private Func _loggerFactory; private IModifLogger Logger => _loggerFactory(); internal void Start(Harmony harmony, ServicesProvider services) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown _services = services; SettingsService settingsService = new SettingsService(services.GetService(), "1.0.0"); ConfigSettings configSettings = settingsService.ConfigureSettings(); ActionUISettings.Init(_services.GetService().Config); services.AddSingleton(configSettings).AddFactory((Func)(() => LoggerFactory.GetLogger("ModifAmorphic.Outward.ActionUI"))).AddSingleton(new ModifCoroutine(services.GetService(), (Func)services.GetService)) .AddSingleton(new LevelCoroutines(services.GetService(), (Func)services.GetService)) .AddSingleton(new ResetActionUIsService(services, services.GetService(), (Func)services.GetService)) .AddSingleton(new ModifGoService((Func)services.GetService)) .AddSingleton(new RewiredListener(services.GetService(), services.GetService(), configSettings, (Func)services.GetService)) .AddSingleton((IActionUIProfileService)(object)new GlobalActionUIProfileService()) .AddSingleton((IHotbarProfileService)(object)new GlobalHotbarService()) .AddSingleton((IPositionsProfileService)(object)new GlobalPositionsService()); _loggerFactory = services.GetServiceFactory(); GameObject val = ConfigureAssetBundle(); services.AddSingleton(new SharedServicesInjector(services, (Func)services.GetService)).AddSingleton(new PositionsService((ModifCoroutine)(object)services.GetService(), services.GetService(), (Func)services.GetService)).AddSingleton(new PlayerMenuService(services.GetService(), ((Component)val.GetComponentInChildren(true)).gameObject, services.GetService(), services.GetService(), services.GetService(), services.GetService(), (Func)services.GetService)) .AddSingleton(new PositionsServicesInjector(_services, services.GetService(), services.GetService(), (ModifCoroutine)(object)services.GetService(), (Func)services.GetService)); services.AddSingleton(new InventoryStartup(services, services.GetService(), services.GetService(), services.GetService(), _loggerFactory)).AddSingleton(new HotbarsStartup(services, services.GetService(), services.GetService(), services.GetService(), _loggerFactory)); Starter.TryStart(services.GetService()); Starter.TryStart(services.GetService()); } public GameObject ConfigureAssetBundle() { GameObject val = AttachScripts(typeof(PlayerActionMenus).Assembly); Logger.LogDebug("Loading asset bundle action-ui."); AssetBundle val2 = LoadAssetBundle(BaseUnityPluginExtensions.GetPluginDirectory(_services.GetService()), "", "action-ui"); string[] allAssetNames = val2.GetAllAssetNames(); string text = ""; string[] array = allAssetNames; foreach (string text2 in array) { text = text + text2 + ", "; } Logger.LogDebug("Assets in Bundle: " + text); GameObject val3 = val2.LoadAsset("assets/prefabs/actionui.prefab"); val3.SetActive(false); Logger.LogDebug("Loaded asset assets/prefabs/actionui.prefab."); Object.DontDestroyOnLoad((Object)(object)val3); val2.Unload(false); GameObject modResources = _services.GetService().GetModResources("ModifAmorphic.Outward.ActionUI", false); val3.transform.SetParent(modResources.transform); GameObject gameObject = ((Component)val3.transform.Find("PlayersServicesProvider")).gameObject; GameObject modResources2 = _services.GetService().GetModResources("ModifAmorphic.Outward.ActionUI", true); GameObject val4 = Object.Instantiate(gameObject); val4.transform.SetParent(modResources2.transform); ((Object)val4).name = "PlayersServicesProvider"; GameObject gameObject2 = ((Component)val3.transform.Find("ActionSprites")).gameObject; GameObject val5 = Object.Instantiate(gameObject2); val5.transform.SetParent(modResources2.transform); ((Object)val5).name = "ActionSprites"; GameObject gameObject3 = ((Component)val3.transform.Find("Prefabs")).gameObject; GameObject val6 = Object.Instantiate(gameObject3, modResources.transform); ((Object)val6).name = "Prefabs"; Object.Destroy((Object)(object)gameObject); Object.Destroy((Object)(object)gameObject2); Object.Destroy((Object)(object)gameObject3); Object.Destroy((Object)(object)val); return val3; } public GameObject AttachScripts(Assembly sourceAssembly) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown IEnumerable enumerable = from type in sourceAssembly.GetTypes() where type.GetCustomAttributes(typeof(UnityScriptComponentAttribute), inherit: true).Length != 0 select type; ModifGoService service = _services.GetService(); GameObject modResources = service.GetModResources("ModifAmorphic.Outward.ActionUI", false); GameObject val = new GameObject("scripts"); val.transform.SetParent(modResources.transform); foreach (Type item in enumerable) { Logger.LogTrace("Attaching script " + item.FullName); val.AddComponent(item); } return val; } private AssetBundle LoadAssetBundle(string pluginPath, string bundleDirectory, string bundleFileName) { using FileStream fileStream = new FileStream(Path.Combine(pluginPath, Path.Combine(bundleDirectory, bundleFileName)), FileMode.Open, FileAccess.Read); return AssetBundle.LoadFromStream((Stream)fileStream); } } } namespace ModifAmorphic.Outward.ActionUI.Settings { public static class ActionUISettings { public static class ActionViewer { public const string SkillsTab = "Skills"; public const string ConsumablesTab = "Consumables"; public const string DeployablesTab = "Deployables"; public const string WeaponsTab = "Weapons"; public const string ArmorTab = "Armor"; public const string CosmeticsTab = "Cosmetics"; public const string EquippedTab = "Equipped"; } public static readonly string PluginPath = Path.GetDirectoryName(ActionUIPlugin.Instance.Info.Location); public static readonly string ConfigPath = Path.GetDirectoryName(ActionUIPlugin.Instance.Config.ConfigFilePath); public static readonly string GlobalKeymapsPath = Path.Combine(ConfigPath, "ActionUI_Keymaps"); public static readonly string CharacterHotbarsPath = Path.Combine(ConfigPath, "ActionUI_CharacterSlots"); public static ConfigEntry Rows; public static ConfigEntry SlotsPerRow; public static ConfigEntry Scale; public static ConfigEntry HideLeftNav; public static ConfigEntry CombatMode; public static ConfigEntry ShowCooldownTimer; public static ConfigEntry PreciseCooldownTime; public static ConfigEntry DisabledSlots; public static ConfigEntry OpenPositioningUI; public static ConfigEntry ResetPositions; public static ConfigEntry HotbarPositionX; public static ConfigEntry HotbarPositionY; public static ConfigEntry SetHotkeyMode; public static ConfigEntry SerializedPositions; public static ConfigEntry SerializedHotbars; public static void Init(ConfigFile config) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Expected O, but got Unknown //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Expected O, but got Unknown //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Expected O, but got Unknown //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Expected O, but got Unknown //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown Rows = config.Bind("Hotbar", "Rows", 1, new ConfigDescription("Number of action bar rows.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 4), new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false } })); SlotsPerRow = config.Bind("Hotbar", "SlotsPerRow", 11, new ConfigDescription("Number of slots per row.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 20), new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false } })); Scale = config.Bind("Hotbar", "Scale", 100, new ConfigDescription("Scale of the action bars in percent.", (AcceptableValueBase)(object)new AcceptableValueRange(50, 200), new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false } })); HideLeftNav = config.Bind("Hotbar", "HideLeftNav", false, new ConfigDescription("Hide the left navigation arrows.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false } })); CombatMode = config.Bind("Hotbar", "CombatMode", true, new ConfigDescription("Automatically show action bars when entering combat.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false } })); ShowCooldownTimer = config.Bind("Hotbar", "ShowCooldownTimer", true, new ConfigDescription("Show numeric cooldown timer on slots.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false } })); PreciseCooldownTime = config.Bind("Hotbar", "PreciseCooldownTime", false, new ConfigDescription("Show decimal precision for cooldowns.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false } })); DisabledSlots = config.Bind("Hotbar", "DisabledSlots", "", new ConfigDescription("Internal list of disabled slot indices.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false, IsAdvanced = true } })); OpenPositioningUI = config.Bind("UI Positioning", "Open Visual Editor", false, new ConfigDescription("Click to open the visual drag-and-drop editor.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = DrawPositionButton, HideDefaultButton = true, IsAdvanced = false } })); ResetPositions = config.Bind("UI Positioning", "Reset UI Positions", false, new ConfigDescription("Reset all UI elements to their default positions.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = DrawResetInfo, HideDefaultButton = true, IsAdvanced = false } })); HotbarPositionX = config.Bind("UI Positioning", "Hotbar X", 0f, new ConfigDescription("Horizontal position of the Hotbar.", (AcceptableValueBase)(object)new AcceptableValueRange(-3840f, 0f), new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false, CustomDrawer = DrawHotbarX, HideDefaultButton = true } })); HotbarPositionY = config.Bind("UI Positioning", "Hotbar Y", 0f, new ConfigDescription("Vertical position of the Hotbar.", (AcceptableValueBase)(object)new AcceptableValueRange(-2160f, 0f), new object[1] { new ConfigurationManagerAttributes { IsAdvanced = false, CustomDrawer = DrawHotbarY, HideDefaultButton = true } })); SetHotkeyMode = config.Bind("Input", "Set Hotkey Mode", false, new ConfigDescription("Click to enter hotkey assignment mode.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = DrawHotkeyModeButton, HideDefaultButton = true, IsAdvanced = false } })); SerializedPositions = config.Bind("Internal", "SerializedPositions", "", new ConfigDescription("JSON serialized UI positions.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false, IsAdvanced = true } })); SerializedHotbars = config.Bind("Internal", "SerializedHotbars", "", new ConfigDescription("JSON serialized hotbar configuration.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = false, IsAdvanced = true } })); } private static void CloseConfigWindow() { try { Type type = Type.GetType("ConfigurationManager.ConfigurationManager, ConfigurationManager"); if (type == null) { return; } Object val = Object.FindObjectOfType(type); if (val != (Object)null) { PropertyInfo property = type.GetProperty("DisplayingWindow"); if (property != null) { property.SetValue(val, false, null); } } } catch (Exception) { } } private static void DrawPositionButton(ConfigEntryBase entry) { if (GUILayout.Button("Open Visual Editor", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { CloseConfigWindow(); PlayerActionMenus[] array = Object.FindObjectsOfType(); PlayerActionMenus[] array2 = array; foreach (PlayerActionMenus val in array2) { val.MainSettingsMenu.ShowMenu((ActionSettingsMenus)5); } } } private static void DrawResetInfo(ConfigEntryBase entry) { if (GUILayout.Button("Reset Positions", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { GlobalConfigService.Instance.PositionsProfile.Positions.Clear(); GlobalConfigService.Instance.SavePositions(); HotbarPositionX.Value = (float)((ConfigEntryBase)HotbarPositionX).DefaultValue; HotbarPositionY.Value = (float)((ConfigEntryBase)HotbarPositionY).DefaultValue; PositionableUI[] array = Object.FindObjectsOfType(); PositionableUI[] array2 = array; foreach (PositionableUI val in array2) { val.ResetToOrigin(); } } } private static void DrawHotbarX(ConfigEntryBase entry) { //IL_0067: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) float centerValue = (float)(-Screen.width) / 2f; string text = ""; try { HotbarsContainer val = Object.FindObjectOfType(); if ((Object)(object)val != (Object)null) { float num = Screen.width; Canvas componentInParent = ((Component)val).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.rootCanvas != (Object)null) { Rect rect = ((Component)componentInParent.rootCanvas).GetComponent().rect; num = ((Rect)(ref rect)).width; } float num2 = 0f; float num3 = 0f; float num4 = 50f; float num5 = 5f; bool flag = false; GridLayoutGroup[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); GridLayoutGroup val2 = ((IEnumerable)componentsInChildren).FirstOrDefault((Func)((GridLayoutGroup g) => ((Object)g).name == "BaseHotbarGrid")) ?? UnityEngineExtensions.FirstOrDefault((IList)componentsInChildren); if ((Object)(object)val2 != (Object)null) { num2 = ((LayoutGroup)val2).padding.left; num3 = ((LayoutGroup)val2).padding.right; num4 = val2.cellSize.x; num5 = val2.spacing.x; flag = true; } int value = SlotsPerRow.Value; float num6 = (num4 + num5) * (float)value - num5; float num7 = num6 + num2 + num3; float num8 = (float)Scale.Value / 100f; float num9 = (num6 / 2f + num3) * num8; centerValue = 0f - num / 2f + num9; if (flag) { text = ""; } else { text = ""; } } } catch (Exception) { } DrawHotbarSetting(entry, "Center", centerValue); } private static void DrawHotbarY(ConfigEntryBase entry) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) float centerValue = (float)(-Screen.height) / 2f; HotbarsContainer val = Object.FindObjectOfType(); if ((Object)(object)val != (Object)null) { RectTransform component = ((Component)val).GetComponent(); LayoutRebuilder.ForceRebuildLayoutImmediate(component); Canvas componentInParent = ((Component)val).GetComponentInParent(); RectTransform val2 = null; val2 = (RectTransform)(((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.rootCanvas != (Object)null) ? ((Component)componentInParent.rootCanvas).GetComponent() : ((!((Object)(object)componentInParent != (Object)null)) ? ((object)/*isinst with value type is only supported in some contexts*/) : ((object)((Component)componentInParent).GetComponent()))); float num; Rect rect; if (!Object.op_Implicit((Object)(object)val2)) { num = Screen.height; } else { rect = val2.rect; num = ((Rect)(ref rect)).height; } float num2 = num; rect = component.rect; float num3 = ((Rect)(ref rect)).height * ((Component)val).transform.localScale.y; centerValue = 0f - num2 / 2f + num3 / 2f; } DrawHotbarSetting(entry, "Center", centerValue); } private static void DrawHotbarSetting(ConfigEntryBase entry, string centerLabel, float centerValue) { float num = (float)entry.BoxedValue; AcceptableValueRange val = (AcceptableValueRange)(object)entry.Description.AcceptableValues; float num2 = val.MinValue; float num3 = val.MaxValue; GUILayout.BeginHorizontal(Array.Empty()); float num4 = GUILayout.HorizontalSlider(num, num2, num3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); string s = GUILayout.TextField(num4.ToString("F1"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (float.TryParse(s, out var result)) { num4 = Mathf.Clamp(result, num2, num3); } if (GUILayout.Button(centerLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { num4 = centerValue; } if (GUILayout.Button("Reset", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })) { num4 = (float)entry.DefaultValue; } GUILayout.EndHorizontal(); if (Mathf.Abs(num4 - num) > 0.001f) { entry.BoxedValue = num4; RefreshHotbarPositionFromConfig(); } } private static void RefreshHotbarPositionFromConfig() { HotbarsContainer[] array = Object.FindObjectsOfType(); HotbarsContainer[] array2 = array; foreach (HotbarsContainer val in array2) { PositionableUI component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.SetPosition(HotbarPositionX.Value, 0f - HotbarPositionY.Value); } } } private static void DrawHotkeyModeButton(ConfigEntryBase entry) { if (!GUILayout.Button("Enter Hotkey Mode", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { return; } CloseConfigWindow(); PlayerActionMenus[] array = Object.FindObjectsOfType(); PlayerActionMenus[] array2 = array; foreach (PlayerActionMenus val in array2) { if ((Object)(object)val.MainSettingsMenu != (Object)null && (Object)(object)val.MainSettingsMenu.HotkeyCaptureMenu != (Object)null) { val.MainSettingsMenu.HotkeyCaptureMenu.Show(); } } } } internal class ConfigSettings { private const string HotbarsSection = "Hotbars"; private const int HotbarsTopOrder = int.MaxValue; private const string AdvancedSection = "zz--Advanced Settings--zz"; private const int AdvancedTopOrder = -1000; public ConfigSetting Hotbars { get; } = new ConfigSetting { Name = "Hotbars", DefaultValue = 1, Section = "Hotbars", DisplayName = "Hotbars", Description = "Amount of hotbars.", Order = 2147483646, IsAdvanced = false }; public ConfigSetting ActionSlots { get; } = new ConfigSetting { Name = "ActionSlots", DefaultValue = 8, Section = "Hotbars", DisplayName = "Hotbar Action Slots", Description = "The number of slots per hotbar.", Order = 2147483645, IsAdvanced = false }; public ConfigSetting LogLevel { get; } = new ConfigSetting { Name = "LogLevel", DefaultValue = (LogLevel)2, Section = "zz--Advanced Settings--zz", DisplayName = "Minimum level for logging", Description = "The threshold for logging events to the UnityEngine.Debug logger. " + Enum.GetName(typeof(LogLevel), (object)(LogLevel)2) + " is the default.", Order = -1001, IsAdvanced = true }; public ConfigSetting ConfigVersion { get; } = new ConfigSetting { Name = "ConfigVersion", DefaultValue = "1.1.2", Section = "zz--Advanced Settings--zz", DisplayName = "Created with version", Description = "The version of Action Bar this configuration file was created for. **Warning - Changing this could result in resetting all config values.**", Order = -1002, IsAdvanced = true }; } public class HotbarSettings { private static List hotbarAssignments = new List { (IHotbarSlotData)(object)new HotbarData { HotbarIndex = 0, RewiredActionId = RewiredConstants.ActionSlots.HotbarNavActions[0].id, RewiredActionName = RewiredConstants.ActionSlots.HotbarNavActions[0].name, Slots = new List { (ISlotData)(object)new SlotData { SlotIndex = 0, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "Q", RewiredActionName = RewiredConstants.ActionSlots.Actions[0].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[0].id } }, (ISlotData)(object)new SlotData { SlotIndex = 1, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "E", RewiredActionName = RewiredConstants.ActionSlots.Actions[1].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[1].id } }, (ISlotData)(object)new SlotData { SlotIndex = 2, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "R", RewiredActionName = RewiredConstants.ActionSlots.Actions[2].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[2].id } }, (ISlotData)(object)new SlotData { SlotIndex = 3, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "1", RewiredActionName = RewiredConstants.ActionSlots.Actions[3].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[3].id } }, (ISlotData)(object)new SlotData { SlotIndex = 4, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "2", RewiredActionName = RewiredConstants.ActionSlots.Actions[4].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[4].id } }, (ISlotData)(object)new SlotData { SlotIndex = 5, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "3", RewiredActionName = RewiredConstants.ActionSlots.Actions[5].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[5].id } }, (ISlotData)(object)new SlotData { SlotIndex = 6, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "4", RewiredActionName = RewiredConstants.ActionSlots.Actions[6].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[6].id } }, (ISlotData)(object)new SlotData { SlotIndex = 7, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "5", RewiredActionName = RewiredConstants.ActionSlots.Actions[7].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[7].id } }, (ISlotData)(object)new SlotData { SlotIndex = 8, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "6", RewiredActionName = RewiredConstants.ActionSlots.Actions[8].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[8].id } }, (ISlotData)(object)new SlotData { SlotIndex = 9, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "7", RewiredActionName = RewiredConstants.ActionSlots.Actions[9].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[9].id } }, (ISlotData)(object)new SlotData { SlotIndex = 10, Config = (IActionSlotConfig)(object)new ActionConfig { HotkeyText = "8", RewiredActionName = RewiredConstants.ActionSlots.Actions[10].name, RewiredActionId = RewiredConstants.ActionSlots.Actions[10].id } } } } }; internal static HotbarProfileData DefaulHotbarProfile = new HotbarProfileData { Rows = 1, SlotsPerRow = hotbarAssignments.First().Slots.Count, Hotbars = hotbarAssignments, HideLeftNav = false, CombatMode = true, Scale = 100, NextRewiredActionId = RewiredConstants.ActionSlots.NextHotbarAction.id, NextRewiredActionName = RewiredConstants.ActionSlots.NextHotbarAction.name, PrevRewiredActionId = RewiredConstants.ActionSlots.PreviousHotbarAction.id, PrevRewiredActionName = RewiredConstants.ActionSlots.PreviousHotbarAction.name }; } internal class InventorySettings { public const int MaxSetItemID = -1310000000; public const int MinSetItemID = -1319999999; public const int MaxItemID = -1320000000; public const int MinItemID = -1329999999; public const string MoveToStashKey = "Context_Item_MoveToStash"; public static readonly HashSet StashAreas = new HashSet { (AreaEnum)100, (AreaEnum)200, (AreaEnum)500, (AreaEnum)300, (AreaEnum)400, (AreaEnum)601 }; } internal static class RewiredConstants { public static class ActionMenus { public const int CategoryMapId = 130000; public static InputMapCategory CategoryMap; public const int ActionCategoryId = 130001; public static InputCategory ActionCategory; static ActionMenus() { CategoryMap = GetMapCategory("ActionMenus", "ActionMenus", 130000, userAssignable: true); ActionCategory = GetActionCategory("ActionMenus", "ActionMenus", 130001, userAssignable: true); } } public static class ActionSlots { public const int CategoryMapId = 131000; public static InputMapCategory CategoryMap; public const int ActionCategoryId = 131001; public static InputCategory ActionCategory; public static List Actions; public static List HotbarNavActions; public const string NameFormat = "ActionSlot_00"; public const string NavNameFormat = "Hotbar_00"; public static InputAction NextHotbarAction; public static InputAction PreviousHotbarAction; public static InputAction NextHotbarAxisAction; public static InputAction PreviousHotbarAxisAction; public const string SelectHotbarNameFormat = "SelectHotbar_00"; public static readonly string DefaultKeyboardMapFile; public static readonly string DefaultMouseMapFile; public static readonly string DefaultJoystickMapFile; static ActionSlots() { DefaultKeyboardMapFile = Path.Combine(ActionUISettings.PluginPath, "Profiles", "Default", "Default-Keyboard-Map_ActionSlots.xml"); DefaultMouseMapFile = Path.Combine(ActionUISettings.PluginPath, "Profiles", "Default", "Default-Mouse-Map_ActionSlots.xml"); DefaultJoystickMapFile = string.Empty; CategoryMap = GetMapCategory("ActionSlots", "ActionSlots", 131000, userAssignable: true); ActionCategory = GetActionCategory("ActionSlots", "ActionSlots", 131001, userAssignable: true); Actions = GetSlotsActions("ActionSlot_00", "Action Slot ##0", (InputActionType)1, userAssignable: true, ActionCategory.id, 131500, 64); HotbarNavActions = GetHotbarNavActions("Hotbar_00", "Hotbar ##0", (InputActionType)1, userAssignable: true, ActionCategory.id, 131200, 64); NextHotbarAction = GetAction(131100, "NextHotbar", "Next Hotbar", (InputActionType)1, userAssignable: true, ActionCategory.id); PreviousHotbarAction = GetAction(131101, "PreviousHotbar", "Previous Hotbar", (InputActionType)1, userAssignable: true, ActionCategory.id); NextHotbarAxisAction = GetAction(131102, "NextHotbar+", "Next Hotbar", (InputActionType)0, userAssignable: true, ActionCategory.id); PreviousHotbarAxisAction = GetAction(131103, "PreviousHotbar-", "Previous Hotbar", (InputActionType)0, userAssignable: true, ActionCategory.id); HotbarNavActions.Add(NextHotbarAction); HotbarNavActions.Add(PreviousHotbarAction); HotbarNavActions.Add(NextHotbarAxisAction); HotbarNavActions.Add(PreviousHotbarAxisAction); } } private static InputMapCategory GetMapCategory(string name, string descriptiveName, int id, bool userAssignable) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown InputMapCategory val = new InputMapCategory(); ReflectionExtensions.SetPrivateField(val, "_name", name); ReflectionExtensions.SetPrivateField(val, "_descriptiveName", descriptiveName); ReflectionExtensions.SetPrivateField(val, "_id", id); ReflectionExtensions.SetPrivateField(val, "_userAssignable", userAssignable); return val; } private static InputCategory GetActionCategory(string name, string descriptiveName, int id, bool userAssignable) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown InputCategory val = new InputCategory(); ReflectionExtensions.SetPrivateField(val, "_name", name); ReflectionExtensions.SetPrivateField(val, "_descriptiveName", descriptiveName); ReflectionExtensions.SetPrivateField(val, "_id", id); ReflectionExtensions.SetPrivateField(val, "_userAssignable", userAssignable); return val; } private static List GetSlotsActions(string nameFormat, string descriptiveNameFormat, InputActionType inputActionType, bool userAssignable, int actionCategoryId, int startingId, int amount) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < amount; i++) { int num = i + 1; InputAction action = GetAction(i + startingId, num.ToString(nameFormat), num.ToString(descriptiveNameFormat), inputActionType, userAssignable, actionCategoryId); list.Add(action); } return list; } private static List GetHotbarNavActions(string nameFormat, string descriptiveNameFormat, InputActionType inputActionType, bool userAssignable, int actionCategoryId, int startingId, int amount) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < amount; i++) { int num = i + 1; InputAction action = GetAction(i + startingId, num.ToString(nameFormat), num.ToString(descriptiveNameFormat), inputActionType, userAssignable, actionCategoryId); list.Add(action); } return list; } public static InputAction GetAction(int id, string name, string descriptiveName, InputActionType inputActionType, bool userAssignable, int actionCategoryId) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) InputAction val = new InputAction(); ReflectionExtensions.SetPrivateField(val, "_id", id); ReflectionExtensions.SetPrivateField(val, "_name", name); ReflectionExtensions.SetPrivateField(val, "_descriptiveName", descriptiveName); ReflectionExtensions.SetPrivateField(val, "_type", inputActionType); ReflectionExtensions.SetPrivateField(val, "_userAssignable", userAssignable); ReflectionExtensions.SetPrivateField(val, "_categoryId", actionCategoryId); return val; } } internal class SettingsService { private readonly ConfigManagerService _configManagerService; private readonly ConfigSettingsService _configService; private readonly string _minConfigVersion; private readonly IModifLogger _logger = LoggerFactory.GetLogger("ModifAmorphic.Outward.ActionUI"); public SettingsService(BaseUnityPlugin plugin, string minConfigVersion) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown _logger.LogTrace("SettingsService() plugin is " + (((Object)(object)plugin == (Object)null) ? "null" : "not null") + ". minConfigVersion: " + minConfigVersion); ConfigManagerService configManagerService = new ConfigManagerService(plugin); ConfigSettingsService configService = new ConfigSettingsService(plugin); _configManagerService = configManagerService; _configService = configService; _minConfigVersion = minConfigVersion; } public ConfigSettings ConfigureSettings() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) ConfigSettings settings = new ConfigSettings(); if (!MeetsMinimumVersion(_minConfigVersion)) { } _configService.BindConfigSetting(settings.LogLevel, (Action>)delegate { //IL_0015: Unknown result type (might be due to invalid IL or missing references) LoggerFactory.ConfigureLogger("ModifAmorphic.Outward.ActionUI", "Action Bar", settings.LogLevel.Value); }, false, false); LoggerFactory.ConfigureLogger("ModifAmorphic.Outward.ActionUI", "Action Bar", settings.LogLevel.Value); _configService.BindConfigSetting(settings.ConfigVersion, (Action>)null, false, false); return settings; } private bool MeetsMinimumVersion(string minimumVersion) { string text = _configService.PeekSavedConfigValue(new ConfigSettings().ConfigVersion); if (string.IsNullOrWhiteSpace(text)) { return false; } if (!Version.TryParse(text, out Version result) || !Version.TryParse(minimumVersion, out Version result2)) { return false; } _logger.LogDebug(string.Format("Current Config {0}? {1}. Compared: ", "MeetsMinimumVersion", result.CompareTo(result2) >= 0) + $"ConfigVersion: {result} to MinimumVersion: {result2}"); return result.CompareTo(result2) >= 0; } } } namespace ModifAmorphic.Outward.ActionUI.Plugin.Services { internal class RewiredListener { private readonly ConfigSettings _settings; private readonly Func _getLogger; private readonly BaseUnityPlugin _baseUnityPlugin; private readonly LevelCoroutines _coroutine; private IModifLogger Logger => _getLogger(); public RewiredListener(BaseUnityPlugin baseUnityPlugin, LevelCoroutines coroutine, ConfigSettings settings, Func getLogger) { _baseUnityPlugin = baseUnityPlugin; _coroutine = coroutine; _settings = settings; _getLogger = getLogger; InputManager_BasePatches.BeforeInitialize += InitializeActonMenus; } private void InitializeActonMenus(InputManager_Base inputManager) { ActionCategoryMap privateField = ReflectionExtensions.GetPrivateField(inputManager.userData, "actionCategoryMap"); ReflectionExtensions.GetPrivateField>(inputManager.userData, "mapCategories").Add(RewiredConstants.ActionMenus.CategoryMap); ReflectionExtensions.GetPrivateField>(inputManager.userData, "actionCategories").Add(RewiredConstants.ActionMenus.ActionCategory); privateField.AddCategory(RewiredConstants.ActionMenus.ActionCategory.id); ReflectionExtensions.GetPrivateField>(inputManager.userData, "mapCategories").Add(RewiredConstants.ActionSlots.CategoryMap); ReflectionExtensions.GetPrivateField>(inputManager.userData, "actionCategories").Add(RewiredConstants.ActionSlots.ActionCategory); ReflectionExtensions.GetPrivateField(inputManager.userData, "actionCategoryMap").AddCategory(RewiredConstants.ActionSlots.ActionCategory.id); List privateField2 = ReflectionExtensions.GetPrivateField>(inputManager.userData, "actions"); foreach (InputAction action in RewiredConstants.ActionSlots.Actions) { Logger.LogDebug($"Adding action {action.name} with id {action.id}"); ReflectionExtensions.GetPrivateField>(inputManager.userData, "actions").Add(action); ReflectionExtensions.GetPrivateField(inputManager.userData, "actionCategoryMap").AddAction(action.categoryId, action.id); } foreach (InputAction hotbarNavAction in RewiredConstants.ActionSlots.HotbarNavActions) { Logger.LogDebug($"Adding hotbar nav action {hotbarNavAction.name} with id {hotbarNavAction.id}"); ReflectionExtensions.GetPrivateField>(inputManager.userData, "actions").Add(hotbarNavAction); ReflectionExtensions.GetPrivateField(inputManager.userData, "actionCategoryMap").AddAction(hotbarNavAction.categoryId, hotbarNavAction.id); } } } } namespace ModifAmorphic.Outward.ActionUI.Services { internal class ControllerMapService : IDisposable { public class MouseButton { public KeyCode KeyCode { get; set; } public int elementIdentifierId { get; set; } public string DisplayName { get; set; } } private readonly Func _getLogger; private readonly HotkeyCaptureMenu _captureDialog; private readonly IHotbarProfileService _hotbarProfileService; private readonly IActionUIProfileService _profileService; private readonly HotbarService _hotbarService; private readonly Player _player; private readonly ModifCoroutine _coroutine; private const string KeyboardMapFile = "KeyboardMap_ActionSlots.xml"; private const string MouseMapFile = "Mouse_ActionSlots.xml"; private const string JoystickMapFile = "Joystick_ActionSlots.xml"; private static Dictionary MapFiles = new Dictionary { { (ControllerType)0, "KeyboardMap_ActionSlots.xml" }, { (ControllerType)1, "Mouse_ActionSlots.xml" }, { (ControllerType)2, "Joystick_ActionSlots.xml" } }; public static Dictionary MouseButtons = new Dictionary { { (KeyCode)0, new MouseButton { KeyCode = (KeyCode)0, elementIdentifierId = -1, DisplayName = string.Empty } }, { (KeyCode)323, new MouseButton { KeyCode = (KeyCode)323, elementIdentifierId = 3, DisplayName = "LMB" } }, { (KeyCode)324, new MouseButton { KeyCode = (KeyCode)324, elementIdentifierId = 4, DisplayName = "RMB" } }, { (KeyCode)325, new MouseButton { KeyCode = (KeyCode)325, elementIdentifierId = 5, DisplayName = "MB 3" } }, { (KeyCode)326, new MouseButton { KeyCode = (KeyCode)326, elementIdentifierId = 6, DisplayName = "MB 4" } }, { (KeyCode)327, new MouseButton { KeyCode = (KeyCode)327, elementIdentifierId = 7, DisplayName = "MB 5" } }, { (KeyCode)328, new MouseButton { KeyCode = (KeyCode)328, elementIdentifierId = 8, DisplayName = "MB 6" } } }; public static Dictionary MouseButtonElementIds = new Dictionary { { 2, new MouseButton { KeyCode = (KeyCode)325, elementIdentifierId = 2, DisplayName = "Wheel" } }, { 3, new MouseButton { KeyCode = (KeyCode)323, elementIdentifierId = 3, DisplayName = "LMB" } }, { 4, new MouseButton { KeyCode = (KeyCode)324, elementIdentifierId = 4, DisplayName = "RMB" } }, { 5, new MouseButton { KeyCode = (KeyCode)325, elementIdentifierId = 5, DisplayName = "MB 3" } }, { 6, new MouseButton { KeyCode = (KeyCode)326, elementIdentifierId = 6, DisplayName = "MB 4" } }, { 7, new MouseButton { KeyCode = (KeyCode)327, elementIdentifierId = 7, DisplayName = "MB 5" } }, { 8, new MouseButton { KeyCode = (KeyCode)328, elementIdentifierId = 8, DisplayName = "MB 6" } } }; private bool disposedValue; private static readonly HashSet MouseKeyCodes = new HashSet { (KeyCode)323, (KeyCode)324, (KeyCode)325, (KeyCode)326, (KeyCode)327, (KeyCode)328, (KeyCode)329 }; private IModifLogger Logger => _getLogger(); public ControllerMapService(HotkeyCaptureMenu captureDialog, IHotbarProfileService hotbarProfileService, IActionUIProfileService profileService, HotbarService hotbarService, Player player, ModifCoroutine coroutine, Func getLogger) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown _captureDialog = captureDialog; _hotbarService = hotbarService; _player = player; _coroutine = coroutine; _getLogger = getLogger; _hotbarProfileService = hotbarProfileService; _profileService = profileService; RewiredInputsPatches.AfterSaveAllMaps += TryRemoveActionUIMaps; RewiredInputsPatches.AfterExportXmlData += RewiredInputsPatches_AfterExportXmlData; _hotbarProfileService.OnProfileChanged += SlotAmountChanged; _captureDialog.OnKeysSelected += new OnKeysSelectedDelegate(CaptureDialog_OnKeysSelected); } private void RewiredInputsPatches_AfterExportXmlData(int playerId) { if (playerId == _player.id) { LoadConfigMaps(forceRefresh: true); } } private void TryRemoveActionUIMaps(RewiredInputs rewiredInputs) { try { if (rewiredInputs.PlayerID != _player.id) { return; } Dictionary privateField = ReflectionExtensions.GetPrivateField>(rewiredInputs, "m_mappingData"); List list = privateField.Keys.Where((string k) => UnityEngineExtensions.Contains(k, "categoryId=131000", StringComparison.InvariantCultureIgnoreCase)).ToList(); foreach (string item in list) { try { if (privateField.Remove(item)) { Logger.LogDebug("Removed ControllerMap '" + item + "'."); } else { Logger.LogWarning("Failed to remove ControllerMap '" + item + "'."); } } catch (Exception ex) { Logger.LogException("Exception removing ControllerMap '" + item + "'", ex); } } } catch (Exception ex2) { Logger.LogException($"Failed to remove ActionUI Controller maps for player ID {rewiredInputs.PlayerID}.", ex2); } } public (KeyboardMap keyboardMap, MouseMap mouseMap) LoadConfigMaps(bool forceRefresh = false) { (KeyboardMap, MouseMap) result = (GetActionSlotsMap(forceRefresh), GetActionSlotsMap(forceRefresh)); if (forceRefresh) { _hotbarService.TryConfigureHotbars(_hotbarProfileService.GetProfile()); } return result; } public void Save() { var (controllerMap, controllerMap2) = LoadConfigMaps(); SaveControllerMap((ControllerMap)(object)controllerMap); SaveControllerMap((ControllerMap)(object)controllerMap2); ControlsInput.ExportXmlData(_player.id); } private void CaptureDialog_OnKeysSelected(int slotIndex, HotkeyCategories category, KeyGroup keyGroup) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Invalid comparison between Unknown and I4 //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Invalid comparison between Unknown and I4 //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Invalid comparison between Unknown and I4 //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) (KeyboardMap keyboardMap, MouseMap mouseMap) tuple = LoadConfigMaps(); KeyboardMap item = tuple.keyboardMap; MouseMap item2 = tuple.mouseMap; List list = new List(); string keyName = Keyboard.GetKeyName(keyGroup.KeyCode, GetModifierKeyFlags(keyGroup.Modifiers)); Logger.LogDebug($"KeyCode {keyGroup.KeyCode} has Keyboard KeyName {keyName}."); ControllerType controllerType; if (!string.IsNullOrWhiteSpace(keyName) && !MouseKeyCodes.Contains(keyGroup.KeyCode)) { controllerType = (ControllerType)0; } else { if (!MouseKeyCodes.Contains(keyGroup.KeyCode)) { return; } controllerType = (ControllerType)1; } list.Add((ControllerMap)(object)item); list.Add((ControllerMap)(object)item2); if ((int)category == 1) { SetActionSlotHotkey(slotIndex, keyGroup, controllerType, list); } else if ((int)category == 4) { SetHotbarHotkey(slotIndex, keyGroup, controllerType, list); } else if ((int)category == 3 || (int)category == 2) { SetHotbarNavHotkey(category, keyGroup, controllerType, list); } } private void SlotAmountChanged(IHotbarProfile hotbarProfile, HotbarProfileChangeTypes changeType) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (hotbarProfile.Rows != 1) { if ((int)changeType == 5) { ShiftActionSlotsForward(hotbarProfile); } else if ((int)changeType == 6) { ShiftActionSlotsBack(hotbarProfile); } } } private void ShiftActionSlotsForward(IHotbarProfile hotbarProfile) { //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0153: Unknown result type (might be due to invalid IL or missing references) (KeyboardMap keyboardMap, MouseMap mouseMap) tuple = LoadConfigMaps(); KeyboardMap item = tuple.keyboardMap; MouseMap item2 = tuple.mouseMap; List list = new List { (ControllerMap)(object)item, (ControllerMap)(object)item2 }; int index = hotbarProfile.SlotsPerRow - 1; int num = hotbarProfile.Rows * hotbarProfile.SlotsPerRow; List hotbars = hotbarProfile.Hotbars; int num2 = hotbarProfile.Rows - 1; ElementAssignment assignment = default(ElementAssignment); for (int num3 = num2; num3 > 0; num3--) { int num4 = num3 * hotbarProfile.SlotsPerRow; int num5 = (num3 + 1) * hotbarProfile.SlotsPerRow - 1; for (int num6 = num5; num6 >= num4; num6--) { ActionConfig actionConfig = hotbars[0].Slots[num6].Config as ActionConfig; ControllerType val = (ControllerType)0; int previousActionId = ((ActionConfig)(object)hotbars[0].Slots[num6].Config).RewiredActionId - num3; ActionElementMap val2 = ((IEnumerable)((ControllerMap)item).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == previousActionId)); ControllerMap map = (ControllerMap)(object)item; if (val2 == null || num6 == num5) { ((ElementAssignment)(ref assignment))..ctor(val, (ControllerElementType)1, -1, (AxisRange)1, (KeyCode)0, (ModifierKeyFlags)0, actionConfig.RewiredActionId, (Pole)0, false); } else { ((ElementAssignment)(ref assignment))..ctor(val, (ControllerElementType)1, val2.elementIdentifierId, (AxisRange)1, val2.keyCode, val2.modifierKeyFlags, actionConfig.RewiredActionId, (Pole)0, false); } ConfigureButtonMapping(assignment, val, map, out var hotkeyText); actionConfig.HotkeyText = hotkeyText; } } ActionConfig actionConfig2 = hotbars[0].Slots[index].Config as ActionConfig; ConfigureButtonMapping(new ElementAssignment((KeyCode)0, (ModifierKeyFlags)0, actionConfig2.RewiredActionId, (Pole)0, -1), (ControllerType)0, (ControllerMap)(object)item, out var hotkeyText2); ConfigureButtonMapping(new ElementAssignment((KeyCode)0, (ModifierKeyFlags)0, actionConfig2.RewiredActionId, (Pole)0, -1), (ControllerType)0, (ControllerMap)(object)item2, out hotkeyText2); actionConfig2.HotkeyText = string.Empty; for (int i = 1; i < hotbars.Count; i++) { for (int j = 0; j < hotbars[i].Slots.Count; j++) { hotbars[i].Slots[j].Config.HotkeyText = hotbars[0].Slots[j].Config.HotkeyText; } } SaveControllerMap((ControllerMap)(object)item); SaveControllerMap((ControllerMap)(object)item2); } private void ShiftActionSlotsBack(IHotbarProfile hotbarProfile) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) (KeyboardMap keyboardMap, MouseMap mouseMap) tuple = LoadConfigMaps(); KeyboardMap item = tuple.keyboardMap; MouseMap item2 = tuple.mouseMap; List list = new List { (ControllerMap)(object)item, (ControllerMap)(object)item2 }; List hotbars = hotbarProfile.Hotbars; ElementAssignment assignment = default(ElementAssignment); for (int i = 1; i < hotbarProfile.Rows; i++) { int num = i * hotbarProfile.SlotsPerRow; int num2 = (i + 1) * hotbarProfile.SlotsPerRow - 1; for (int j = num; j <= num2; j++) { ActionConfig actionConfig = hotbars[0].Slots[j].Config as ActionConfig; int nextActionId = ((ActionConfig)(object)hotbars[0].Slots[j].Config).RewiredActionId + i; ControllerType val = (ControllerType)0; ActionElementMap val2 = ((IEnumerable)((ControllerMap)item).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == nextActionId)); ControllerMap map = (ControllerMap)(object)item; if (val2 == null) { val2 = ((IEnumerable)((ControllerMap)item2).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == nextActionId)); val = (ControllerType)1; map = (ControllerMap)(object)item2; } if (val2 == null) { ((ElementAssignment)(ref assignment))..ctor(val, (ControllerElementType)1, -1, (AxisRange)1, (KeyCode)0, (ModifierKeyFlags)0, actionConfig.RewiredActionId, (Pole)0, false); } else { ((ElementAssignment)(ref assignment))..ctor(val, (ControllerElementType)1, val2.elementIdentifierId, (AxisRange)1, val2.keyCode, val2.modifierKeyFlags, actionConfig.RewiredActionId, (Pole)0, false); } ConfigureButtonMapping(assignment, val, map, out var hotkeyText); actionConfig.HotkeyText = hotkeyText; } } for (int k = 1; k < hotbars.Count; k++) { for (int l = 0; l < hotbars[k].Slots.Count; l++) { hotbars[k].Slots[l].Config.HotkeyText = hotbars[0].Slots[l].Config.HotkeyText; } } SaveControllerMap((ControllerMap)(object)item); SaveControllerMap((ControllerMap)(object)item2); } private void SetActionSlotHotkey(int slotIndex, KeyGroup keyGroup, ControllerType controllerType, List maps) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Logger.LogDebug($"Setting ActionSlot Hotkey for Slot Index {slotIndex} to KeyCode {keyGroup.KeyCode}."); IHotbarProfile profile = _hotbarProfileService.GetProfile(); List hotbars = profile.Hotbars; ActionConfig actionConfig = (ActionConfig)(object)hotbars[0].Slots[slotIndex].Config; ConfigureButtonMapping(actionConfig.RewiredActionId, keyGroup, controllerType, maps, out var hotkeyText); for (int i = 0; i < hotbars.Count; i++) { hotbars[i].Slots[slotIndex].Config.HotkeyText = hotkeyText; Logger.LogDebug($"Setting Hotkey to '{hotkeyText}' for hotbar {i}, slot {slotIndex}."); } _hotbarProfileService.Save(); _hotbarService.TryConfigureHotbars(profile); } private void SetHotbarHotkey(int id, KeyGroup keyGroup, ControllerType controllerType, IEnumerable maps) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) Logger.LogDebug($"Setting Hotbar Hotkey for Bar Index {id}."); IHotbarProfile profile = _hotbarProfileService.GetProfile(); HotbarData hotbarData = (HotbarData)(object)profile.Hotbars[id]; ConfigureButtonMapping(hotbarData.RewiredActionId, keyGroup, controllerType, maps, out var hotkeyText); hotbarData.HotbarHotkey = hotkeyText; _hotbarProfileService.Save(); _hotbarService.TryConfigureHotbars(profile); } private void SetHotbarNavHotkey(HotkeyCategories category, KeyGroup keyGroup, ControllerType controllerType, IEnumerable maps) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 HotbarProfileData hotbarProfileData = (HotbarProfileData)(object)_hotbarProfileService.GetProfile(); int rewiredActionId = (((int)category == 3) ? hotbarProfileData.NextRewiredActionId : hotbarProfileData.PrevRewiredActionId); if ((int)keyGroup.KeyCode == 325 && (int)keyGroup.AxisDirection > 0) { rewiredActionId = (((int)category == 3) ? hotbarProfileData.NextRewiredAxisActionId : hotbarProfileData.PrevRewiredAxisActionId); } ConfigureButtonMapping(rewiredActionId, keyGroup, controllerType, maps, out var hotkeyText); if ((int)category == 3) { hotbarProfileData.NextHotkey = hotkeyText; Logger.LogDebug("Setting NextHotkey text to " + hotkeyText + "."); } else { Logger.LogDebug("Setting PrevHotkey text to " + hotkeyText + "."); hotbarProfileData.PrevHotkey = hotkeyText; } _hotbarProfileService.Save(); _hotbarService.TryConfigureHotbars((IHotbarProfile)(object)hotbarProfileData); } private void ConfigureButtonMapping(int rewiredActionId, KeyGroup keyGroup, ControllerType controllerType, IEnumerable maps, out string hotkeyText) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_002e: 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_0037: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Invalid comparison between Unknown and I4 //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 //IL_0086: Unknown result type (might be due to invalid IL or missing references) hotkeyText = string.Empty; ElementAssignment assignment = default(ElementAssignment); foreach (ControllerMap map in maps) { int num = -1; AxisRange val = (AxisRange)(((int)keyGroup.AxisDirection != 2) ? 1 : 2); Pole val2 = (Pole)((int)keyGroup.AxisDirection == 2); if (map.controllerType == controllerType) { if ((int)controllerType == 1) { num = (((int)keyGroup.KeyCode != 325 || (int)keyGroup.AxisDirection <= 0) ? MouseButtons[keyGroup.KeyCode].elementIdentifierId : 2); } Logger.LogDebug($"Configuring Button Mapping for ControllerType {map.controllerType} and actionId {rewiredActionId}. Setting elementIdentifierId to {num}. Keycode is {keyGroup.KeyCode}"); if ((int)keyGroup.AxisDirection == 0) { ((ElementAssignment)(ref assignment))..ctor(map.controllerType, (ControllerElementType)1, num, (AxisRange)1, keyGroup.KeyCode, GetModifierKeyFlags(keyGroup.Modifiers), rewiredActionId, (Pole)0, false); } else { ((ElementAssignment)(ref assignment))..ctor(map.controllerType, (ControllerElementType)0, num, val, keyGroup.KeyCode, GetModifierKeyFlags(keyGroup.Modifiers), rewiredActionId, val2, false); } } else { Logger.LogDebug($"Configuring Removal Button Mapping for ControllerType {map.controllerType} and actionId {rewiredActionId}."); ((ElementAssignment)(ref assignment))..ctor(map.controllerType, (ControllerElementType)1, num, (AxisRange)1, (KeyCode)0, (ModifierKeyFlags)0, rewiredActionId, (Pole)0, false); } ConfigureButtonMapping(assignment, controllerType, map, out var hotkeyText2); if (!string.IsNullOrWhiteSpace(hotkeyText2)) { hotkeyText = hotkeyText2; } SaveControllerMap(map); } } private void ConfigureButtonMapping(ElementAssignment assignment, ControllerType controllerType, ControllerMap map, out string hotkeyText) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Invalid comparison between Unknown and I4 //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Invalid comparison between Unknown and I4 //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Invalid comparison between Unknown and I4 //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Invalid comparison between Unknown and I4 //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Invalid comparison between Unknown and I4 //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Invalid comparison between Unknown and I4 hotkeyText = string.Empty; List maps = map.AllMaps.Where((ActionElementMap m) => m.actionId == assignment.actionId).ToList(); AddHotbarNavMaps(assignment, map, ref maps); if (maps.Any()) { for (int i = 0; i < maps.Count; i++) { if (map.DeleteElementMap(maps[i].id)) { Logger.LogDebug($"Deleted existing map {maps[i].id} for rewiredId {assignment.actionId}."); } } } RemoveExistingAssignments(assignment, map); if (map.controllerType != controllerType) { return; } if ((int)assignment.keyboardKey != 0 || ((int)map.controllerType == 1 && MouseButtonElementIds.TryGetValue(assignment.elementIdentifierId, out var value) && (int)value.KeyCode > 0)) { bool flag = map.ReplaceOrCreateElementMap(assignment); Logger.LogDebug($"Attempted replace or create element map {assignment.elementMapId} to use keyboardKey {assignment.keyboardKey} in {map.controllerType} ControllerMap {map.id}. Result was {flag}"); } ActionElementMap? obj = ((IEnumerable)map.ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == assignment.actionId)); hotkeyText = ((obj != null) ? obj.elementIdentifierName : null); if ((int)map.controllerType != 1 || !MouseButtonElementIds.TryGetValue(assignment.elementIdentifierId, out var value2)) { return; } hotkeyText = value2.DisplayName; if ((int)value2.KeyCode == 325) { if ((int)assignment.axisRange == 1) { hotkeyText += "+"; } else if ((int)assignment.axisRange == 2) { hotkeyText += "-"; } } } private void RemoveExistingAssignments(ElementAssignment assignment, ControllerMap map) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) ElementAssignmentConflictCheck val = CreateConflictCheck(map, assignment); int num = map.RemoveElementAssignmentConflicts(val); Logger.LogDebug($"Removed {num} conflicts for key {assignment.keyboardKey} and modifiers {assignment.modifierKeyFlags}."); } private ElementAssignmentConflictCheck CreateConflictCheck(ControllerMap map, ElementAssignment assignment) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) ElementAssignmentConflictCheck result = ((ElementAssignment)(ref assignment)).ToElementAssignmentConflictCheck(); ((ElementAssignmentConflictCheck)(ref result)).playerId = map.id; ((ElementAssignmentConflictCheck)(ref result)).controllerType = map.controllerType; ((ElementAssignmentConflictCheck)(ref result)).controllerId = map.controllerId; ((ElementAssignmentConflictCheck)(ref result)).controllerMapId = map.id; ((ElementAssignmentConflictCheck)(ref result)).controllerMapCategoryId = map.categoryId; return result; } private void AddHotbarNavMaps(ElementAssignment assignment, ControllerMap map, ref List maps) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) if (assignment.actionId == RewiredConstants.ActionSlots.NextHotbarAction.id) { ActionElementMap val = ((IEnumerable)map.AllMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == RewiredConstants.ActionSlots.NextHotbarAxisAction.id)); if (val != null) { maps.Add(val); } } if (assignment.actionId == RewiredConstants.ActionSlots.PreviousHotbarAction.id) { ActionElementMap val2 = ((IEnumerable)map.AllMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == RewiredConstants.ActionSlots.PreviousHotbarAxisAction.id)); if (val2 != null) { maps.Add(val2); } } if (assignment.actionId == RewiredConstants.ActionSlots.NextHotbarAxisAction.id) { ActionElementMap val3 = ((IEnumerable)map.AllMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == RewiredConstants.ActionSlots.NextHotbarAction.id)); if (val3 != null) { maps.Add(val3); } } if (assignment.actionId == RewiredConstants.ActionSlots.PreviousHotbarAxisAction.id) { ActionElementMap val4 = ((IEnumerable)map.AllMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == RewiredConstants.ActionSlots.PreviousHotbarAction.id)); if (val4 != null) { maps.Add(val4); } } } private void SaveControllerMap(ControllerMap controllerMap) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(GetProfileFolder(), MapFiles[controllerMap.controllerType]); Logger.LogInfo($"Saving Controller Map {((controllerMap != null) ? new ControllerType?(controllerMap.controllerType) : null)} to '{text}'."); string xml = controllerMap.ToXmlString(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xml); using XmlTextWriter xmlTextWriter = new XmlTextWriter(text, Encoding.UTF8); xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.Indentation = 4; xmlDocument.Save(xmlTextWriter); xmlTextWriter.Close(); } private T GetActionSlotsMap(bool forceRefresh) where T : ControllerMap { //IL_0003: 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_0047: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) ControllerType val = (ControllerType)20; if (typeof(KeyboardMap).IsAssignableFrom(typeof(T))) { val = (ControllerType)0; } else if (typeof(MouseMap).IsAssignableFrom(typeof(T))) { val = (ControllerType)1; } else if (typeof(JoystickMap).IsAssignableFrom(typeof(T))) { val = (ControllerType)2; } Logger.LogDebug($"ActionSlots using {val} ControllerMap for player {_player.id}"); if ((int)val == 20) { return default(T); } T map = _player.controllers.maps.GetMap(0, 131000, 0); if (map != null && !forceRefresh) { Logger.LogDebug($"ActionSlots {val} ControllerMap found loaded for player {_player.id}"); return map; } string keyMapFileXml = GetKeyMapFileXml(val); T val2 = (T)(object)ControllerMap.CreateFromXml(val, keyMapFileXml); if (map != null) { Logger.LogDebug($"Replacing ActionSlots {val} ControllerMap found loaded for player {_player.id}"); _player.controllers.maps.RemoveMap(0, ((ControllerMap)val2).id); } _player.controllers.maps.AddMap(0, (ControllerMap)(object)val2); return val2; } private string GetKeyMapFileXml(ControllerType controllerType) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) HotbarProfileData hotbarProfileData = (HotbarProfileData)(object)_hotbarProfileService.GetProfile(); string text; string text2; if ((int)controllerType == 0) { text = RewiredConstants.ActionSlots.DefaultKeyboardMapFile; text2 = Path.Combine(ActionUISettings.PluginPath, "Default-Keyboard-Map_ActionSlots.xml"); } else if ((int)controllerType == 1) { text = RewiredConstants.ActionSlots.DefaultMouseMapFile; text2 = Path.Combine(ActionUISettings.PluginPath, "Default-Mouse-Map_ActionSlots.xml"); } else { if ((int)controllerType != 2) { return string.Empty; } text = RewiredConstants.ActionSlots.DefaultJoystickMapFile; text2 = string.Empty; } string text3 = text; if (!File.Exists(text3) && !string.IsNullOrEmpty(text2) && File.Exists(text2)) { Logger.LogDebug("Default keymap not found at '" + text + "', using fallback at '" + text2 + "'."); text3 = text2; } string text4 = text3; if (hotbarProfileData != null) { text4 = Path.Combine(GetProfileFolder(), MapFiles[controllerType]); if (!File.Exists(text4)) { string directoryName = Path.GetDirectoryName(text4); if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } if (!File.Exists(text3)) { Logger.LogWarning("No default keymap file found. Checked: '" + text + "' and '" + text2 + "'. Cannot create profile keymap."); return string.Empty; } File.Copy(text3, text4); Logger.LogDebug("Copied default keymap from '" + text3 + "' to '" + text4 + "'."); } } Logger.LogDebug($"Loading ActionSlots {controllerType} ControllerMap for player {_player.id} at location '{text4}'."); return File.ReadAllText(text4); } private string GetProfileFolder() { if (!Directory.Exists(ActionUISettings.GlobalKeymapsPath)) { Directory.CreateDirectory(ActionUISettings.GlobalKeymapsPath); } return ActionUISettings.GlobalKeymapsPath; } private ModifierKeyFlags GetModifierKeyFlags(IEnumerable modifiers) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) ModifierKeyFlags val = (ModifierKeyFlags)0; if (modifiers.Contains((KeyCode)307) || modifiers.Contains((KeyCode)308)) { val = (ModifierKeyFlags)(val | 0xC); } if (modifiers.Contains((KeyCode)305) || modifiers.Contains((KeyCode)306)) { val = (ModifierKeyFlags)(val | 3); } if (modifiers.Contains((KeyCode)303) || modifiers.Contains((KeyCode)304)) { val = (ModifierKeyFlags)(val | 0x30); } return val; } protected virtual void Dispose(bool disposing) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown if (disposedValue) { return; } if (disposing) { RewiredInputsPatches.AfterSaveAllMaps -= TryRemoveActionUIMaps; RewiredInputsPatches.AfterExportXmlData -= RewiredInputsPatches_AfterExportXmlData; if (_hotbarProfileService != null) { _hotbarProfileService.OnProfileChanged -= SlotAmountChanged; } if ((Object)(object)_captureDialog != (Object)null) { _captureDialog.OnKeysSelected -= new OnKeysSelectedDelegate(CaptureDialog_OnKeysSelected); } } disposedValue = true; } public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } } internal class HotbarKeyListener : IHotbarNavActions { private readonly Player _player; public HotbarKeyListener(Player player) { _player = player; } public bool IsNextRequested() { return _player.GetButtonDown(RewiredConstants.ActionSlots.NextHotbarAction.id) || !Mathf.Approximately(_player.GetAxis(RewiredConstants.ActionSlots.NextHotbarAxisAction.id), 0f); } public bool IsPreviousRequested() { return _player.GetButtonDown(RewiredConstants.ActionSlots.PreviousHotbarAction.id) || !Mathf.Approximately(_player.GetAxis(RewiredConstants.ActionSlots.PreviousHotbarAxisAction.id), 0f); } public bool IsHotbarRequested(out int hotbarIndex) { hotbarIndex = -1; if (!_player.GetAnyButtonDown()) { return false; } for (int i = 0; i < RewiredConstants.ActionSlots.HotbarNavActions.Count; i++) { if (_player.GetButtonDown(RewiredConstants.ActionSlots.HotbarNavActions[i].id)) { hotbarIndex = i; return true; } } return false; } } internal class HotbarService : IDisposable { private sealed class WeaponContextSnapshot { public int MainWeaponType { get; } public int OffWeaponType { get; } public string[] ResolveKeys { get; } public string EditKey { get; } public string Signature { get; } public WeaponContextSnapshot(int mainWeaponType, int offWeaponType, string[] resolveKeys, string editKey) { MainWeaponType = mainWeaponType; OffWeaponType = offWeaponType; ResolveKeys = resolveKeys ?? Array.Empty(); EditKey = editKey ?? GlobalHotbarService.GetBaselineContextKey(); Signature = $"{MainWeaponType}|{OffWeaponType}"; } } private readonly Func _getLogger; private readonly HotbarsContainer _hotbars; private readonly Player _player; private readonly Character _character; private readonly CharacterUI _characterUI; private readonly IHotbarProfileService _hotbarProfileService; private readonly IActionUIProfileService _profileService; private readonly SlotDataService _slotData; private readonly LevelCoroutines _levelCoroutines; private bool _saveDisabled; private bool _isProfileInit; private bool _isStarted = false; private string _activeContextSignature = string.Empty; private bool _pendingHotbarConfigRefresh; private const int NoWeaponType = -1; private const int OffhandNonWeaponContextOffset = 1000000; private const int MainNonWeaponContextOffset = 2000000; private bool disposedValue; private bool _isConfiguring = false; private IModifLogger Logger => _getLogger(); public Guid InstanceID { get; } = Guid.NewGuid(); public HotbarService(HotbarsContainer hotbarsContainer, Player player, Character character, IHotbarProfileService hotbarProfileService, IActionUIProfileService profileService, SlotDataService slotData, LevelCoroutines levelCoroutines, Func getLogger) { if ((Object)(object)hotbarsContainer == (Object)null) { throw new ArgumentNullException("hotbarsContainer"); } if ((Object)(object)character == (Object)null) { throw new ArgumentNullException("character"); } if (hotbarProfileService == null) { throw new ArgumentNullException("hotbarProfileService"); } if (profileService == null) { throw new ArgumentNullException("profileService"); } if (slotData == null) { throw new ArgumentNullException("slotData"); } _hotbars = hotbarsContainer; _player = player; _character = character; _characterUI = character.CharacterUI; _hotbarProfileService = hotbarProfileService; _profileService = profileService; _slotData = slotData; _levelCoroutines = levelCoroutines; _getLogger = getLogger; QuickSlotPanelPatches.StartInitAfter += DisableKeyboardQuickslots; SkillMenuPatches.AfterOnSectionSelected += SetSkillsMovable; ItemDisplayDropGroundPatches.TryGetIsDropValids.Add(_player.id, TryGetIsDropValid); EquipmentPatches.AfterOnEquip += OnEquipmentChanged; EquipmentPatches.AfterOnUnequip += OnEquipmentChanged; _hotbars.OnAwake += StartNextFrame; if (_hotbars.IsAwake) { StartNextFrame(); } } private void StartNextFrame() { try { ((ModifCoroutine)_levelCoroutines).DoNextFrame((Action)delegate { Start(); }); } catch (Exception ex) { Logger.LogException("Failed to start HotbarService coroutine Start.", ex); } } public void Start() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) try { _isStarted = true; _saveDisabled = true; SwapCanvasGroup(); IHotbarProfile orCreateActiveProfile = GetOrCreateActiveProfile(); if (_hotbarProfileService is GlobalHotbarService globalHotbarService) { globalHotbarService.LoadCharacterSlots(UID.op_Implicit(_character.UID)); } TryConfigureHotbars(orCreateActiveProfile, (HotbarProfileChangeTypes)0); _hotbars.ClearChanges(); _hotbarProfileService.OnProfileChanged += TryConfigureHotbars; _hotbars.OnHasChanges.AddListener(new UnityAction(Save)); CharacterUIPatches.AfterRefreshHUDVisibility += ShowHideHotbars; AssignSlotActions(); AssignSlotActions(); EnsureNoWeaponDynamicPresetsInitialized(); ApplyDynamicPresetsForCurrentWeapon(force: true); ShowHideHotbars(_characterUI); InitializePositionConfig(); ActionUISettings.Rows.SettingChanged += OnHotbarConfigChanged; ActionUISettings.SlotsPerRow.SettingChanged += OnHotbarConfigChanged; ActionUISettings.Scale.SettingChanged += OnHotbarConfigChanged; ActionUISettings.HideLeftNav.SettingChanged += OnHotbarConfigChanged; ActionUISettings.CombatMode.SettingChanged += OnHotbarConfigChanged; ActionUISettings.ShowCooldownTimer.SettingChanged += OnHotbarConfigChanged; ActionUISettings.PreciseCooldownTime.SettingChanged += OnHotbarConfigChanged; } catch (Exception ex) { Logger.LogException("Failed to start HotbarService.", ex); } } private void ShowHideHotbars(CharacterUI characterui) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!(characterui.TargetCharacter.UID != _character.UID)) { int num = UnityEngineExtensions.ToInt(OptionManager.Instance.GetHudVisibility(_character.OwnerPlayerSys.PlayerID)); ((Component)_hotbars.ActionBarsCanvas).GetComponent().alpha = num; } } private void SetSkillsMovable(ItemListDisplay itemListDisplay) { IActionUIProfile activeProfile = _profileService.GetActiveProfile(); if (activeProfile == null || activeProfile.ActionSlotsEnabled) { ItemDisplay[] componentsInChildren = ((Component)itemListDisplay).GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Movable = true; } } } private bool TryGetIsDropValid(ItemDisplay draggedDisplay, Character character, out bool result) { result = false; if (!((Object)(object)((draggedDisplay != null) ? draggedDisplay.RefItem : null) == (Object)null)) { Item refItem = draggedDisplay.RefItem; Skill val = (Skill)(object)((refItem is Skill) ? refItem : null); if (val != null) { Logger.LogDebug("TryGetIsDropValid:: Blocking drop of skill " + ((Object)val).name + " to DropPanel."); return true; } } return false; } public void TryConfigureHotbars(IHotbarProfile profile) { try { if (!_hotbars.IsAwake || !_isStarted) { return; } Character character = _character; if ((Object)(object)((character != null) ? character.Inventory : null) == (Object)null) { return; } _isConfiguring = true; _saveDisabled = true; SetProfileHotkeys(profile); _hotbars.Controller.ConfigureHotbars(profile); ActionSlot[][] hotbars = _hotbars.Hotbars; foreach (ActionSlot[] array in hotbars) { if (array == null) { continue; } ActionSlot[] array2 = array; foreach (ActionSlot val in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val.ActionButton != (Object)null) { UnityEngineExtensions.GetOrAddComponent(((Component)val.ActionButton).gameObject).SetLogger(_getLogger); } } } if (profile.HideLeftNav) { _hotbars.LeftHotbarNav.Hide(); } else { _hotbars.LeftHotbarNav.Show(); } if (_isProfileInit) { AssignSlotActions(profile); } ScaleHotbars(profile.Scale); } catch (Exception ex) { Logger.LogException("Failed to configure Hotbars.", ex); } finally { _isConfiguring = false; _saveDisabled = false; if (_pendingHotbarConfigRefresh) { _pendingHotbarConfigRefresh = false; OnHotbarConfigChanged(this, EventArgs.Empty); } } } private void TryConfigureHotbars(IHotbarProfile profile, HotbarProfileChangeTypes changeType) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 try { if ((int)changeType == 11) { ScaleHotbars(profile.Scale); } else { TryConfigureHotbars(profile); } } catch (Exception ex) { Logger.LogException("Failed to configure Hotbars.", ex); } } private void Save() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) try { if (!_isConfiguring && _hotbars.HasChanges && !_saveDisabled) { IHotbarProfile orCreateActiveProfile = GetOrCreateActiveProfile(); Logger.LogDebug(string.Format("{0}_{1}: Hotbar changes detected. Saving.", "HotbarService", InstanceID)); SyncDynamicPresetsForCurrentWeapon(); _hotbarProfileService.Update(_hotbars); if (_hotbarProfileService is GlobalHotbarService globalHotbarService) { globalHotbarService.SaveCharacterSlots(UID.op_Implicit(_character.UID)); } _hotbars.ClearChanges(); } } catch (Exception ex) { Logger.LogException("Failed to Save Hotbar changes.", ex); } } private void ScaleHotbars(int scaleAmount) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_hotbars == (Object)null)) { float num = (float)scaleAmount / 100f; ((Component)_hotbars).transform.localScale = new Vector3(num, num, 1f); } } private void SwapCanvasGroup() { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown try { QuickSlotControllerSwitcher val = ((IEnumerable)((Component)_characterUI).GetComponentsInChildren()).FirstOrDefault((Func)((QuickSlotControllerSwitcher q) => ((Object)q).name == "QuickSlot")); if ((Object)(object)val == (Object)null) { Logger.LogWarning("[HotbarService] QuickSlotControllerSwitcher not found!"); return; } CanvasGroup privateField = ReflectionExtensions.GetPrivateField(val, "m_keyboardQuickSlots"); CanvasGroup privateField2 = ReflectionExtensions.GetPrivateField(val, "m_gamepadQuickSlots"); if (_hotbars.VanillaSuppressionTargets == null) { _hotbars.VanillaSuppressionTargets = new List(); } _hotbars.VanillaSuppressionTargets.Clear(); if ((Object)(object)privateField != (Object)null) { ((Component)privateField).gameObject.SetActive(false); privateField.alpha = 0f; _hotbars.VanillaSuppressionTargets.Add(((Component)privateField).gameObject); } GameObject val2 = new GameObject("DummyKeyboardSlots"); val2.transform.SetParent(((Component)val).transform); CanvasGroup val3 = val2.AddComponent(); val3.alpha = 0f; val3.blocksRaycasts = false; val3.interactable = false; ReflectionExtensions.SetPrivateField(val, "m_keyboardQuickSlots", val3); if (_hotbars.VanillaOverlayTargets == null) { _hotbars.VanillaOverlayTargets = new List(); } _hotbars.VanillaOverlayTargets.Clear(); if ((Object)(object)privateField2 != (Object)null) { _hotbars.VanillaOverlayTargets.Add(privateField2); } Logger.LogDebug($"[HotbarService] SwapCanvasGroup Complete. KeyboardGroup found: {(Object)(object)privateField != (Object)null}, GamepadGroup found: {(Object)(object)privateField2 != (Object)null}. Swapped to Dummy."); } catch (Exception ex) { Logger.LogException("Failed to populate VanillaOverlayTargets or disable QuickSlots.", ex); } } public void DisableKeyboardQuickslots(KeyboardQuickSlotPanel keyboard) { if ((Object)(object)keyboard != (Object)null && ((Component)keyboard).gameObject.activeSelf) { IModifLogger logger = Logger; int? obj; if (keyboard == null) { obj = null; } else { CharacterUI characterUI = ((UIElement)keyboard).CharacterUI; obj = ((characterUI != null) ? new int?(characterUI.RewiredID) : null); } logger.LogDebug($"Disabling Keyboard QuickSlots for RewiredID {obj}."); ((Component)keyboard).gameObject.SetActive(false); } } private IHotbarProfile GetOrCreateActiveProfile() { IActionUIProfile activeProfile = _profileService.GetActiveProfile(); IHotbarProfile profile = _hotbarProfileService.GetProfile(); Logger.LogDebug("Got or Created Active Profile '" + activeProfile.Name + "'"); return profile; } public void AssignSlotActions() { AssignSlotActions(GetOrCreateActiveProfile()); } public void AssignSlotActions(IHotbarProfile profile) { Logger.LogDebug(string.Format("{0}_{1}: Assigning Slot Actions.", "HotbarService", InstanceID)); _saveDisabled = true; _isConfiguring = true; try { for (int i = 0; i < profile.Hotbars.Count; i++) { for (int j = 0; j < profile.Hotbars[i].Slots.Count; j++) { try { SlotData slotData = profile.Hotbars[i].Slots[j] as SlotData; ActionSlot val = _hotbars.Controller.GetActionSlots()[i][j]; bool flag = false; if (slotData != null && (Object)(object)val != (Object)null && _slotData.TryGetItemSlotAction(slotData, profile.CombatMode, out var slotAction)) { try { val.Controller.AssignSlotAction(slotAction, false); flag = true; } catch (Exception ex) { Logger.LogException($"Failed to assign slot action '{((slotAction != null) ? slotAction.DisplayName : null)}' to Bar {i}, Slot Index {j}.", ex); } } if (!flag) { val.Controller.AssignEmptyAction(); } } catch (Exception ex2) { Logger.LogException($"Failed to assign action to slot {i}_{j}.", ex2); } } } SetProfileHotkeys(profile); if (!_isProfileInit) { _isProfileInit = true; } _hotbars.Controller.Refresh(); } finally { Logger.LogDebug("Clearing Hotbar Change Flag and enabling save."); _hotbars.ClearChanges(); _saveDisabled = false; _isConfiguring = false; } } private void OnEquipmentChanged(Character character, Equipment equipment) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) try { if (_isStarted && !((Object)(object)character == (Object)null) && !((Object)(object)_character == (Object)null) && !(character.UID != _character.UID)) { ((ModifCoroutine)_levelCoroutines).DoNextFrame((Action)delegate { ApplyDynamicPresetsForCurrentWeapon(); }); } } catch (Exception ex) { Logger.LogException("Failed applying dynamic presets after equipment change.", ex); } } private void ApplyDynamicPresetsForCurrentWeapon(bool force = false) { //IL_0248: Unknown result type (might be due to invalid IL or missing references) if (!(_hotbarProfileService is GlobalHotbarService globalHotbarService)) { return; } WeaponContextSnapshot currentWeaponContext = GetCurrentWeaponContext(); if (!force && string.Equals(currentWeaponContext.Signature, _activeContextSignature, StringComparison.Ordinal)) { return; } _activeContextSignature = currentWeaponContext.Signature; IHotbarProfile orCreateActiveProfile = GetOrCreateActiveProfile(); bool flag = false; ActionSlot[][] actionSlots = _hotbars.Controller.GetActionSlots(); for (int i = 0; i < actionSlots.Length; i++) { ActionSlot[] array = actionSlots[i]; for (int j = 0; j < array.Length; j++) { ActionSlot val = array[j]; if (((val != null) ? val.Config : null) == null || !val.Config.IsDynamic) { continue; } SlotDataEntry slotEntry = null; bool flag2 = false; for (int k = 0; k < currentWeaponContext.ResolveKeys.Length; k++) { if (globalHotbarService.TryGetDynamicPresetSlot(currentWeaponContext.ResolveKeys[k], i, j, out slotEntry)) { flag2 = true; break; } } if (!flag2 || slotEntry == null) { continue; } ISlotAction slotAction; if (slotEntry.ItemID <= 0 && string.IsNullOrWhiteSpace(slotEntry.ItemUID)) { if (val.SlotAction != null) { val.Controller.AssignEmptyAction(); flag = true; } } else if ((val.SlotAction == null || val.SlotAction.ActionId != slotEntry.ItemID || !string.Equals(val.SlotAction.ActionUid ?? string.Empty, slotEntry.ItemUID ?? string.Empty, StringComparison.Ordinal)) && _slotData.TryGetItemSlotAction(slotEntry.ItemID, slotEntry.ItemUID, orCreateActiveProfile.CombatMode, out slotAction)) { val.Controller.AssignSlotAction(slotAction, true); flag = true; } } } if (flag) { _hotbarProfileService.Update(_hotbars); globalHotbarService.SaveCharacterSlots(UID.op_Implicit(_character.UID)); _hotbars.ClearChanges(); } } private void SyncDynamicPresetsForCurrentWeapon() { if (!(_hotbarProfileService is GlobalHotbarService globalHotbarService)) { return; } WeaponContextSnapshot currentWeaponContext = GetCurrentWeaponContext(); string editKey = currentWeaponContext.EditKey; ActionSlot[][] actionSlots = _hotbars.Controller.GetActionSlots(); for (int i = 0; i < actionSlots.Length; i++) { ActionSlot[] array = actionSlots[i]; for (int j = 0; j < array.Length; j++) { ActionSlot val = array[j]; if (((val != null) ? val.Config : null) == null || !val.Config.IsDynamic) { continue; } if (val.SlotAction == null) { if (string.Equals(editKey, GlobalHotbarService.GetBaselineContextKey(), StringComparison.Ordinal)) { globalHotbarService.SetDynamicPresetSlot(editKey, i, j, -1, null); } else { globalHotbarService.RemoveDynamicPresetSlot(editKey, i, j); } } else { globalHotbarService.SetDynamicPresetSlot(editKey, i, j, val.SlotAction.ActionId, val.SlotAction.ActionUid); } } } } private void EnsureNoWeaponDynamicPresetsInitialized() { //IL_0138: Unknown result type (might be due to invalid IL or missing references) if (!(_hotbarProfileService is GlobalHotbarService globalHotbarService)) { return; } ActionSlot[][] actionSlots = _hotbars.Controller.GetActionSlots(); for (int i = 0; i < actionSlots.Length; i++) { ActionSlot[] array = actionSlots[i]; for (int j = 0; j < array.Length; j++) { ActionSlot val = array[j]; if (((val != null) ? val.Config : null) == null || !val.Config.IsDynamic) { continue; } string baselineContextKey = GlobalHotbarService.GetBaselineContextKey(); if (!globalHotbarService.TryGetDynamicPresetSlot(baselineContextKey, i, j, out var _)) { if (val.SlotAction == null) { globalHotbarService.SetDynamicPresetSlot(baselineContextKey, i, j, -1, null); } else { globalHotbarService.SetDynamicPresetSlot(baselineContextKey, i, j, val.SlotAction.ActionId, val.SlotAction.ActionUid); } } } } if (_hotbarProfileService is GlobalHotbarService globalHotbarService2 && (Object)(object)_character != (Object)null) { globalHotbarService2.SaveCharacterSlots(UID.op_Implicit(_character.UID)); } } private WeaponContextSnapshot GetCurrentWeaponContext() { int mainWeaponType = -1; int offWeaponType = -1; try { Equipment val = ReadMainHandEquipment(_character); Equipment val2 = ReadOffhandEquipment(_character); if ((Object)(object)val == (Object)null) { Weapon val3 = ReadCurrentWeapon(_character); if ((Object)(object)val3 != (Object)null && ((Object)(object)val2 == (Object)null || val3 != val2)) { val = (Equipment)(object)val3; } } if ((Object)(object)val != (Object)null) { mainWeaponType = GetMainContextType(val); } if ((Object)(object)val2 != (Object)null && val2 != val) { offWeaponType = GetOffhandContextType(val2); } } catch { mainWeaponType = -1; offWeaponType = -1; } string[] resolveKeys = BuildResolveKeys(mainWeaponType, offWeaponType); string editKey = BuildEditKey(mainWeaponType, offWeaponType); return new WeaponContextSnapshot(mainWeaponType, offWeaponType, resolveKeys, editKey); } private static Weapon ReadCurrentWeapon(Character character) { if ((Object)(object)character == (Object)null) { return null; } Type type = ((object)character).GetType(); object? obj = type.GetProperty("CurrentWeapon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(character, null); Weapon val = (Weapon)((obj is Weapon) ? obj : null); if (val != null) { return val; } CharacterInventory inventory = character.Inventory; CharacterEquipment val2 = ((inventory != null) ? inventory.Equipment : null); if ((Object)(object)val2 == (Object)null) { return null; } object? obj2 = ((object)val2).GetType().GetProperty("CurrentWeapon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(val2, null); return (Weapon)((obj2 is Weapon) ? obj2 : null); } private static Equipment ReadMainHandEquipment(Character character) { if ((Object)(object)character == (Object)null) { return null; } Equipment val = ReadEquipmentFromPropertyNames(character, "RightHandWeapon", "RightHandEquipment", "MainHandWeapon", "MainHandEquipment"); if ((Object)(object)val != (Object)null) { return val; } CharacterInventory inventory = character.Inventory; CharacterEquipment val2 = ((inventory != null) ? inventory.Equipment : null); if ((Object)(object)val2 == (Object)null) { return null; } Equipment val3 = ReadEquipmentFromPropertyNames(val2, "RightHandWeapon", "RightHandEquipment", "MainHandWeapon", "MainHandEquipment"); if ((Object)(object)val3 != (Object)null) { return val3; } return ReadEquipmentFromSlots(character, isMainHand: true); } private static Equipment ReadOffhandEquipment(Character character) { if ((Object)(object)character == (Object)null) { return null; } Equipment val = ReadEquipmentFromPropertyNames(character, "LeftHandWeapon", "LeftHandEquipment", "OffHandWeapon", "OffHandEquipment"); if ((Object)(object)val != (Object)null) { return val; } CharacterInventory inventory = character.Inventory; CharacterEquipment val2 = ((inventory != null) ? inventory.Equipment : null); if ((Object)(object)val2 == (Object)null) { return null; } Equipment val3 = ReadEquipmentFromPropertyNames(val2, "LeftHandWeapon", "LeftHandEquipment", "OffHandWeapon", "OffHandEquipment"); if ((Object)(object)val3 != (Object)null) { return val3; } return ReadEquipmentFromSlots(character, isMainHand: false); } private static Equipment ReadEquipmentFromPropertyNames(object source, params string[] propertyNames) { if (source == null || propertyNames == null || propertyNames.Length == 0) { return null; } Type type = source.GetType(); for (int i = 0; i < propertyNames.Length; i++) { PropertyInfo property = type.GetProperty(propertyNames[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(property == null)) { object? value = property.GetValue(source, null); Equipment val = (Equipment)((value is Equipment) ? value : null); if (val != null) { return val; } } } return null; } private static int GetMainContextType(Equipment mainEquipment) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected I4, but got Unknown if ((Object)(object)mainEquipment == (Object)null) { return -1; } Weapon val = (Weapon)(object)((mainEquipment is Weapon) ? mainEquipment : null); if (val != null) { return (int)val.Type; } if (TryGetStableEquipmentContextId(mainEquipment, out var itemId)) { return 2000000 + itemId; } return -1; } private static int GetOffhandContextType(Equipment offhandEquipment) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected I4, but got Unknown if ((Object)(object)offhandEquipment == (Object)null) { return -1; } Weapon val = (Weapon)(object)((offhandEquipment is Weapon) ? offhandEquipment : null); if (val != null) { return (int)val.Type; } if (TryGetStableEquipmentContextId(offhandEquipment, out var itemId)) { return 1000000 + itemId; } return -1; } private static Equipment ReadEquipmentFromSlots(Character character, bool isMainHand) { CharacterInventory val = ((character != null) ? character.Inventory : null); CharacterEquipment val2 = ((val != null) ? val.Equipment : null); if ((Object)(object)val2 == (Object)null) { return null; } IEnumerable enumerable = ReadObjectEnumerable(val2, "EquipmentSlots", "m_equipmentSlots", "Slots", "m_slots"); if (enumerable == null) { return null; } foreach (object item in enumerable) { if (item == null) { continue; } string text = ReadSlotTypeName(item); if (string.IsNullOrWhiteSpace(text)) { continue; } bool flag = text.IndexOf("Right", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Main", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Primary", StringComparison.OrdinalIgnoreCase) >= 0; bool flag2 = text.IndexOf("Left", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Off", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Secondary", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Lantern", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Lexicon", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Tome", StringComparison.OrdinalIgnoreCase) >= 0; if ((!isMainHand || flag) && (isMainHand || flag2)) { Equipment val3 = ReadEquipmentFromPropertyNames(item, "EquippedItem", "m_equippedItem", "Item"); if ((Object)(object)val3 != (Object)null) { return val3; } } } return null; } private static IEnumerable ReadObjectEnumerable(object source, params string[] memberNames) { if (source == null || memberNames == null || memberNames.Length == 0) { return null; } Type type = source.GetType(); for (int i = 0; i < memberNames.Length; i++) { if (type.GetProperty(memberNames[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(source, null) is IEnumerable enumerable) { List list = new List(); foreach (object item in enumerable) { list.Add(item); } return list; } if (!(type.GetField(memberNames[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(source) is IEnumerable enumerable2)) { continue; } List list2 = new List(); foreach (object item2 in enumerable2) { list2.Add(item2); } return list2; } return null; } private static string ReadSlotTypeName(object slot) { if (slot == null) { return null; } Type type = slot.GetType(); object obj = type.GetProperty("SlotType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(slot, null); if (obj != null) { return obj.ToString(); } return (type.GetField("m_slotType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(slot))?.ToString(); } private static bool TryGetStableEquipmentContextId(Equipment equipment, out int itemId) { itemId = 0; if ((Object)(object)equipment == (Object)null) { return false; } if (TryReadIntMember(equipment, out itemId, "ItemID", "ItemId", "ID", "m_itemID", "m_itemId", "_itemID", "_itemId")) { return itemId > 0; } string text = ReadStringMember(equipment, "UID", "ItemUID", "ItemUid", "m_uid", "m_UID", "_uid"); if (!string.IsNullOrWhiteSpace(text)) { itemId = StablePositiveHash(text); return itemId > 0; } string name = ((Object)equipment).name; if (!string.IsNullOrWhiteSpace(name)) { itemId = StablePositiveHash("name:" + name); return itemId > 0; } return false; } private static bool TryReadIntMember(object source, out int value, params string[] memberNames) { value = 0; if (source == null || memberNames == null || memberNames.Length == 0) { return false; } Type type = source.GetType(); for (int i = 0; i < memberNames.Length; i++) { PropertyInfo property = type.GetProperty(memberNames[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && TryConvertToInt(property.GetValue(source, null), out value)) { return true; } FieldInfo field = type.GetField(memberNames[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && TryConvertToInt(field.GetValue(source), out value)) { return true; } MethodInfo method = type.GetMethod(memberNames[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method != null && TryConvertToInt(method.Invoke(source, null), out value)) { return true; } } return false; } private static string ReadStringMember(object source, params string[] memberNames) { if (source == null || memberNames == null || memberNames.Length == 0) { return null; } Type type = source.GetType(); for (int i = 0; i < memberNames.Length; i++) { if (type.GetProperty(memberNames[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(source, null) is string text && !string.IsNullOrWhiteSpace(text)) { return text; } if (type.GetField(memberNames[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(source) is string text2 && !string.IsNullOrWhiteSpace(text2)) { return text2; } } return null; } private static bool TryConvertToInt(object value, out int result) { result = 0; if (value == null) { return false; } if (!(value is int num)) { if (!(value is long num2)) { if (value is short num3) { short num4 = num3; result = num4; return true; } if (!(value is uint num5)) { if (value is byte b) { byte b2 = b; result = b2; return true; } if (value is string text) { string s = text; if (int.TryParse(s, out var result2)) { result = result2; return true; } } } else { uint num6 = num5; if (num6 <= int.MaxValue) { result = (int)num6; return true; } } } else { long num7 = num2; if (num7 <= int.MaxValue && num7 >= int.MinValue) { result = (int)num7; return true; } } return false; } int num8 = num; result = num8; return true; } private static int StablePositiveHash(string text) { uint num = 2166136261u; for (int i = 0; i < text.Length; i++) { num ^= text[i]; num *= 16777619; } int num2 = (int)(num & 0x7FFFFFFF); return (num2 == 0) ? 1 : num2; } private static string[] BuildResolveKeys(int mainWeaponType, int offWeaponType) { List list = new List(4); if (mainWeaponType != -1 && offWeaponType != -1) { list.Add(GlobalHotbarService.GetComboContextKey(mainWeaponType, offWeaponType)); } if (mainWeaponType != -1) { list.Add(GlobalHotbarService.GetMainContextKey(mainWeaponType)); } if (offWeaponType != -1) { list.Add(GlobalHotbarService.GetOffContextKey(offWeaponType)); } list.Add(GlobalHotbarService.GetBaselineContextKey()); return list.Distinct().ToArray(); } private static string BuildEditKey(int mainWeaponType, int offWeaponType) { if (mainWeaponType != -1 && offWeaponType != -1) { return GlobalHotbarService.GetComboContextKey(mainWeaponType, offWeaponType); } if (mainWeaponType != -1) { return GlobalHotbarService.GetMainContextKey(mainWeaponType); } if (offWeaponType != -1) { return GlobalHotbarService.GetOffContextKey(offWeaponType); } return GlobalHotbarService.GetBaselineContextKey(); } private void SetProfileHotkeys(IHotbarProfile profile) { KeyboardMap map = _player.controllers.maps.GetMap(0, 131000, 0); MouseMap map2 = _player.controllers.maps.GetMap(0, 131000, 0); if (map == null || map2 == null) { Logger.LogWarning($"SetProfileHotkeys: Controller maps not found for player {_player.id}. Skipping hotkey configuration. (KeyMap: {map != null}, MouseMap: {map2 != null})"); return; } HotbarProfileData profileData = (HotbarProfileData)(object)profile; HotbarProfileData hotbarProfileData = profileData; ActionElementMap? obj = ((IEnumerable)((ControllerMap)map).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == profileData.NextRewiredActionId)); hotbarProfileData.NextHotkey = ((obj != null) ? obj.elementIdentifierName : null); if (string.IsNullOrWhiteSpace(profileData.NextHotkey)) { HotbarProfileData hotbarProfileData2 = profileData; ActionElementMap? obj2 = ((IEnumerable)((ControllerMap)map2).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == profileData.NextRewiredActionId)); hotbarProfileData2.NextHotkey = ((obj2 != null) ? obj2.elementIdentifierName : null); } if (string.IsNullOrWhiteSpace(profileData.NextHotkey) && ((ControllerMap)map2).AllMaps.Any((ActionElementMap m) => m.actionId == profileData.NextRewiredAxisActionId)) { profileData.NextHotkey = "Wheel+"; } HotbarProfileData hotbarProfileData3 = profileData; ActionElementMap? obj3 = ((IEnumerable)((ControllerMap)map).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == profileData.PrevRewiredActionId)); hotbarProfileData3.PrevHotkey = ((obj3 != null) ? obj3.elementIdentifierName : null); if (string.IsNullOrWhiteSpace(profileData.PrevHotkey)) { HotbarProfileData hotbarProfileData4 = profileData; ActionElementMap? obj4 = ((IEnumerable)((ControllerMap)map2).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == profileData.PrevRewiredActionId)); hotbarProfileData4.PrevHotkey = ((obj4 != null) ? obj4.elementIdentifierName : null); } if (string.IsNullOrWhiteSpace(profileData.PrevHotkey) && ((ControllerMap)map2).AllMaps.Any((ActionElementMap m) => m.actionId == profileData.PrevRewiredAxisActionId)) { profileData.PrevHotkey = "Wheel-"; } foreach (HotbarData bar2 in profileData.Hotbars) { HotbarData hotbarData = bar2; ActionElementMap? obj5 = ((IEnumerable)((ControllerMap)map).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == bar2.RewiredActionId)); hotbarData.HotbarHotkey = ((obj5 != null) ? obj5.elementIdentifierName : null); foreach (ISlotData slot in bar2.Slots) { ActionConfig config2 = (ActionConfig)(object)slot.Config; ActionElementMap val = ((IEnumerable)((ControllerMap)map).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == config2.RewiredActionId)); if (val != null) { slot.Config.HotkeyText = val.elementIdentifierName; } else { slot.Config.HotkeyText = string.Empty; } } } foreach (HotbarData bar in profileData.Hotbars) { ActionElementMap val2 = ((IEnumerable)((ControllerMap)map2).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == bar.RewiredActionId)); if (val2 != null) { bar.HotbarHotkey = ControllerMapService.MouseButtonElementIds[val2.elementIdentifierId].DisplayName; } foreach (ISlotData slot2 in bar.Slots) { ActionConfig config = (ActionConfig)(object)slot2.Config; ActionElementMap val3 = ((IEnumerable)((ControllerMap)map2).ButtonMaps).FirstOrDefault((Func)((ActionElementMap m) => m.actionId == config.RewiredActionId)); if (val3 != null) { slot2.Config.HotkeyText = ControllerMapService.MouseButtonElementIds[val3.elementIdentifierId].DisplayName; } } } } protected virtual void Dispose(bool disposing) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown if (disposedValue) { return; } if (disposing) { Logger.LogDebug(string.Format("Disposing of {0} instance '{1}'. Unsubscribing to events.", "HotbarService", InstanceID)); QuickSlotPanelPatches.StartInitAfter -= DisableKeyboardQuickslots; SkillMenuPatches.AfterOnSectionSelected -= SetSkillsMovable; EquipmentPatches.AfterOnEquip -= OnEquipmentChanged; EquipmentPatches.AfterOnUnequip -= OnEquipmentChanged; if (ItemDisplayDropGroundPatches.TryGetIsDropValids.ContainsKey(_player.id)) { ItemDisplayDropGroundPatches.TryGetIsDropValids.Remove(_player.id); } if ((Object)(object)_hotbars != (Object)null) { _hotbars.OnHasChanges.RemoveListener(new UnityAction(Save)); _hotbars.OnAwake -= StartNextFrame; } if (_hotbarProfileService != null) { _hotbarProfileService.OnProfileChanged -= TryConfigureHotbars; } ActionUISettings.HotbarPositionX.SettingChanged -= OnHotbarPositionConfigChanged; ActionUISettings.HotbarPositionY.SettingChanged -= OnHotbarPositionConfigChanged; ActionUISettings.Rows.SettingChanged -= OnHotbarConfigChanged; ActionUISettings.SlotsPerRow.SettingChanged -= OnHotbarConfigChanged; ActionUISettings.Scale.SettingChanged -= OnHotbarConfigChanged; ActionUISettings.HideLeftNav.SettingChanged -= OnHotbarConfigChanged; ActionUISettings.CombatMode.SettingChanged -= OnHotbarConfigChanged; ActionUISettings.ShowCooldownTimer.SettingChanged -= OnHotbarConfigChanged; ActionUISettings.PreciseCooldownTime.SettingChanged -= OnHotbarConfigChanged; if ((Object)(object)_hotbars != (Object)null) { PositionableUI component = ((Component)_hotbars).GetComponent(); if ((Object)(object)component != (Object)null) { component.UIElementMoved.RemoveListener((UnityAction)OnHotbarUIMoved); } } } disposedValue = true; } private void InitializePositionConfig() { PositionableUI component = ((Component)_hotbars).GetComponent(); if ((Object)(object)component != (Object)null) { component.SetPosition(ActionUISettings.HotbarPositionX.Value, 0f - ActionUISettings.HotbarPositionY.Value); ActionUISettings.HotbarPositionX.SettingChanged += OnHotbarPositionConfigChanged; ActionUISettings.HotbarPositionY.SettingChanged += OnHotbarPositionConfigChanged; component.UIElementMoved.AddListener((UnityAction)OnHotbarUIMoved); } } private void OnHotbarPositionConfigChanged(object sender, EventArgs e) { if ((Object)(object)_hotbars != (Object)null) { PositionableUI component = ((Component)_hotbars).GetComponent(); if ((Object)(object)component != (Object)null) { component.SetPosition(ActionUISettings.HotbarPositionX.Value, 0f - ActionUISettings.HotbarPositionY.Value); } } } private void OnHotbarConfigChanged(object sender, EventArgs e) { if (!_isStarted || (Object)(object)_hotbars == (Object)null) { return; } if (_isConfiguring) { _pendingHotbarConfigRefresh = true; return; } try { IHotbarProfile val = _hotbarProfileService.GetProfile(); if (val == null) { return; } while (val.Rows < ActionUISettings.Rows.Value) { val = _hotbarProfileService.AddRow(); } while (val.Rows > ActionUISettings.Rows.Value) { val = _hotbarProfileService.RemoveRow(); } while (val.SlotsPerRow < ActionUISettings.SlotsPerRow.Value) { val = _hotbarProfileService.AddSlot(); } while (val.SlotsPerRow > ActionUISettings.SlotsPerRow.Value) { val = _hotbarProfileService.RemoveSlot(); } if (val.Scale != ActionUISettings.Scale.Value) { val = _hotbarProfileService.SetScale(ActionUISettings.Scale.Value); } if (val.HideLeftNav != ActionUISettings.HideLeftNav.Value) { val = _hotbarProfileService.SetHideLeftNav(ActionUISettings.HideLeftNav.Value); } if (val.CombatMode != ActionUISettings.CombatMode.Value) { val = _hotbarProfileService.SetCombatMode(ActionUISettings.CombatMode.Value); } if (val.Hotbars.Count > 0 && val.Hotbars[0].Slots.Count > 0) { IActionSlotConfig config = val.Hotbars[0].Slots[0].Config; if (config.ShowCooldownTime != ActionUISettings.ShowCooldownTimer.Value || config.PreciseCooldownTime != ActionUISettings.PreciseCooldownTime.Value) { val = _hotbarProfileService.SetCooldownTimer(ActionUISettings.ShowCooldownTimer.Value, ActionUISettings.PreciseCooldownTime.Value); } } TryConfigureHotbars(val, (HotbarProfileChangeTypes)0); _hotbars.ClearChanges(); } catch (Exception ex) { Logger.LogException("Failed applying hotbar settings from config.", ex); } } private void OnHotbarUIMoved(PositionableUI p) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_002f: Unknown result type (might be due to invalid IL or missing references) float num = p.RectTransform.anchoredPosition.x - p.DynamicOffset.x; float num2 = p.RectTransform.anchoredPosition.y - p.DynamicOffset.y; if (Math.Abs(ActionUISettings.HotbarPositionX.Value - num) > 0.1f) { ActionUISettings.HotbarPositionX.Value = num; } if (Math.Abs(ActionUISettings.HotbarPositionY.Value - (0f - num2)) > 0.1f) { ActionUISettings.HotbarPositionY.Value = 0f - num2; } } public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } } public class InventoryService : IDisposable, IStartable { private readonly Func _getLogger; private Character _character; private readonly int _playerID; private readonly IActionUIProfileService _profileService; private bool _isRemoved; private readonly LevelCoroutines _coroutines; private bool disposedValue; private IModifLogger Logger => _getLogger(); private CharacterInventory _characterInventory => _character.Inventory; private CharacterEquipment _characterEquipment => _character.Inventory.Equipment; private IActionUIProfile _profile => _profileService.GetActiveProfile(); public InventoryService(Character character, IActionUIProfileService profileService, LevelCoroutines coroutines, Func getLogger) { _character = character; _profileService = profileService; _coroutines = coroutines; _getLogger = getLogger; _playerID = _character.OwnerPlayerSys.PlayerID; } public void Start() { try { CharacterInventoryPatches.AfterInventoryIngredients += AddStashIngredients; CharacterManagerPatches.AfterAddCharacter += ConfigureStashPreserverDelayed; ItemDisplayOptionPanelPatches.TryGetActiveActions.Add(_playerID, TryAddStashActionID); ItemDisplayOptionPanelPatches.PlayersPressedAction.Add(_playerID, StashContextButtonPressed); ItemDisplayPatches.PlayersUpdateValueDisplay.Add(_playerID, TryAddCurrencyValue); MenuPanelPatches.AfterOnHideInventoryMenu += HideCurrencyValues; _profileService.OnActiveProfileChanged += TryConfigureStashPreserver; _profileService.OnActiveProfileSwitched += TryConfigureStashPreserver; ((ModifCoroutine)_coroutines).DoWhen((Func)(() => (Object)(object)_characterInventory.Stash != (Object)null), (Action)delegate { TryConfigureStashPreserver(_profile); }, 180, 0f, (Func)null); } catch (Exception ex) { Logger.LogException("Failed to start InventoryService.", ex); } } private bool TryAddStashActionID(int rewiredId, Item item, List baseActiveActions, out List activeActions) { activeActions = null; if (rewiredId != _playerID || !GetStashInventoryEnabled() || (Object)(object)item == (Object)null) { return false; } if (ItemDisplayOptionPanelPatches.PlayersMoveToStashID == -1) { return false; } int num = baseActiveActions.IndexOf(7); int num2 = baseActiveActions.IndexOf(8); int num3 = ((num2 != -1) ? num2 : num); if (num3 == -1) { return false; } if (_characterInventory.Stash.Contains(item.UID)) { return false; } activeActions = new List(); for (int i = 0; i < baseActiveActions.Count(); i++) { activeActions.Add(baseActiveActions[i]); if (i == num3) { activeActions.Add(ItemDisplayOptionPanelPatches.PlayersMoveToStashID); } } return true; } private bool TryAddCurrencyValue(ItemDisplay itemDisplay) { if (!_profile.StorageSettingsProfile.DisplayCurrencyEnabled) { return false; } Item refItem = itemDisplay.RefItem; if ((Object)(object)refItem == (Object)null) { return false; } if ((Object)(object)_character?.CharacterUI != (Object)null && (Object)(object)_characterInventory != (Object)null && (_character.CharacterUI.GetIsMenuDisplayed((MenuScreens)12) || !_characterInventory.OwnsItem(refItem.UID))) { return false; } if (!_character.CharacterUI.GetIsMenuDisplayed((MenuScreens)2)) { return false; } GameObject privateField = ReflectionExtensions.GetPrivateField(itemDisplay, "m_valueHolder"); if ((Object)(object)privateField == (Object)null) { return false; } if (privateField.activeSelf) { return true; } Text privateField2 = ReflectionExtensions.GetPrivateField(itemDisplay, "m_lblValue"); if ((Object)(object)privateField2 == (Object)null) { return false; } DictionaryExt val = typeof(Merchant).GetField("m_sceneMerchants", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as DictionaryExt; Merchant val2 = null; if (val != null && val.Values.Any()) { val2 = UnityEngineExtensions.FirstOrDefault((IList)val.Values); } int num; if ((Object)(object)val2 != (Object)null) { Logger.LogDebug("Getting merchant " + ((val2 != null) ? val2.ShopName : null) + "'s sell to amount for item " + ((refItem != null) ? ((Object)refItem).name : null)); num = refItem.GetSellValue(_character, val2, false); Logger.LogDebug($"Got merchant {val2.ShopName}'s sell to amount of {num} for item {((Object)refItem).name}"); } else { float privateField3 = ReflectionExtensions.GetPrivateField(refItem, "m_overrideSellModifier"); float num2 = (((double)privateField3 != -1.0) ? privateField3 : 0.3f); num = Mathf.RoundToInt((float)refItem.RawCurrentValue * num2); Logger.LogDebug($"Got default sell to amount of {num} for item {((Object)refItem).name}"); } privateField.SetActive(true); privateField2.text = num.ToString(); return true; } private void HideCurrencyValues(InventoryMenu menu) { Logger.LogDebug("HideCurrencyValues: Hiding sell to amounts for menu " + ((Object)menu).name + "."); InventoryContentDisplay componentInChildren = ((Component)menu).GetComponentInChildren(); Logger.LogDebug($"HideCurrencyValues: invDisplay==null=={(Object)(object)componentInChildren == (Object)null}."); if ((Object)(object)componentInChildren == (Object)null) { return; } ItemDisplay[] componentsInChildren = ((Component)componentInChildren).GetComponentsInChildren(); Logger.LogDebug($"HideCurrencyValues: itemDisplays.Length=={componentsInChildren.Length}."); for (int i = 0; i < componentsInChildren.Length; i++) { GameObject privateField = ReflectionExtensions.GetPrivateField(componentsInChildren[i], "m_valueHolder"); if ((Object)(object)privateField != (Object)null && privateField.activeSelf) { privateField.SetActive(false); Text privateField2 = ReflectionExtensions.GetPrivateField(componentsInChildren[i], "m_lblValue"); if ((Object)(object)privateField2 != (Object)null) { privateField2.text = string.Empty; } } } } private void StashContextButtonPressed(int actionID, ItemDisplay itemDisplay) { if (ItemDisplayOptionPanelPatches.PlayersMoveToStashID != -1 && ItemDisplayOptionPanelPatches.PlayersMoveToStashID == actionID) { itemDisplay.TryMoveTo(_characterInventory.Stash); } } private void AddStashIngredients(CharacterInventory characterInventory, Character character, Tag craftingStationTag, ref DictionaryExt sortedIngredients) { //IL_0018: 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_0064: Unknown result type (might be due to invalid IL or missing references) if (GetCraftFromStashEnabled() && !((Object)(object)character.Stash == (Object)null) && !(character.UID != _character.UID)) { List list = character.Stash.GetContainedItems().ToList(); MethodInfo method = ((object)characterInventory).GetType().GetMethod("InventoryIngredients", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(characterInventory, new object[3] { craftingStationTag, sortedIngredients, list }); } } private void TryConfigureStashPreserver(IActionUIProfile profile) { try { Logger.LogDebug("Trying to Configure Stash Preserver for profile '" + ((profile != null) ? profile.Name : null) + "'."); ConfigureStashPreserver(_character); if (PlayerSystemExtensions.IsHostPlayer(_character.OwnerPlayerSys)) { IEnumerable enumerable = CharacterManager.Instance.Characters.Values.Where((Character c) => !c.IsAI); { foreach (Character item in enumerable) { ConfigureStashPreserver(item); } return; } } if (PhotonNetwork.isNonMasterClientInRoom) { ConfigureStashPreserver(_character); } } catch (Exception ex) { Logger.LogException("Failed to configure stash preserver.", ex); } } private void ConfigureStashPreserverDelayed(Character character) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 if ((int)character.InstantiationType == 1) { ((ModifCoroutine)_coroutines).DoWhen((Func)stashCreated, (Action)delegate { ConfigureStashPreserver(character); }, 120, 0f, (Func)null); } bool stashCreated() { CharacterInventory inventory = character.Inventory; return (Object)(object)((inventory != null) ? inventory.Stash : null) != (Object)null && ((Item)character.Inventory.Stash).IsFirstSyncDone; } } private float CalculateDurabilityReduction(Item item, Character character, float durabilityReduction) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) StashSettingsProfile stashSettingsProfile = _profile.StashSettingsProfile; if (_character.UID != _character.UID || (Object)(object)item.PerishScript == (Object)null || !stashSettingsProfile.PreservesFoodEnabled || !item.Tags.Contains(TagSourceManager.Food)) { return durabilityReduction; } float privateProperty = ReflectionExtensions.GetPrivateProperty(item.PerishScript, "DeltaGameTime"); float num = item.PerishScript.DepletionRate * privateProperty; if (!Mathf.Approximately(durabilityReduction, num) && durabilityReduction != num) { Logger.LogDebug($"Calculated new durability reduction for character {character.UID} Item {((Object)item).name}. Original reduction: {durabilityReduction}. Adjusted reduction: {num}"); } return num; } private void ConfigureStashPreserver(Character character) { //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) ItemContainer stash = character.Stash; StashSettingsProfile stashSettingsProfile = _profile.StashSettingsProfile; Preserver val = ReflectionExtensions.GetPrivateField(stash, "m_preservationExt"); TagSourceSelector foodTag = ReflectionExtensions.GetPrivateField(TagSourceManager.Instance, "m_foodTag"); if (stashSettingsProfile.PreservesFoodEnabled) { bool flag = false; if ((Object)(object)val == (Object)null) { val = UnityEngineExtensions.GetOrAddComponent(((Component)stash).gameObject); flag = true; } List privateField = ReflectionExtensions.GetPrivateField>(val, "m_preservedElements"); if (!flag) { if (privateField.Count == 0) { flag = true; } else { PreservedElement val2 = ((IEnumerable)privateField).FirstOrDefault((Func)((PreservedElement p) => p.Tag.Tag == foodTag.Tag)); if (val2 == null) { flag = true; } else if (val.NullifyPerishing && stashSettingsProfile.PreservesFoodAmount != 100) { flag = true; } else if (!val.NullifyPerishing && stashSettingsProfile.PreservesFoodAmount == 100) { flag = true; } else if (!Mathf.Approximately(val2.Preservation, (float)stashSettingsProfile.PreservesFoodAmount) && (!val.NullifyPerishing || stashSettingsProfile.PreservesFoodAmount != 100)) { flag = true; } } } if (!flag) { return; } val.NullifyPerishing = stashSettingsProfile.PreservesFoodAmount == 100; privateField.RemoveAll((PreservedElement p) => p.Tag == foodTag); privateField.Add(new PreservedElement { Preservation = (val.NullifyPerishing ? 100f : ((float)stashSettingsProfile.PreservesFoodAmount)), Tag = foodTag }); ((Item)stash).AddItemExtension((ItemExtension)(object)val); List itemsFromTag = stash.GetItemsFromTag(TagSourceManager.Food); Perishable[] componentsInChildren = ((Component)stash).GetComponentsInChildren(); Perishable[] array = componentsInChildren; foreach (Perishable val3 in array) { try { if ((Object)(object)val3 != (Object)null) { ((ItemExtension)val3).ItemParentChanged(); } } catch (Exception ex) { Logger.LogException("Unable to set preservation for perishable " + ((val3 != null) ? ((Object)val3).name : null) + ".", ex); } } Logger.LogInfo($"Stash preservation amount set to {stashSettingsProfile.PreservesFoodAmount}% for character '{((character != null) ? character.Name : null)}' '{((character != null) ? new UID?(character.UID) : null)}'"); } else if (TryRemoveStashPreserver()) { Logger.LogInfo("Stash set to not preserve food."); } } private bool TryRemoveStashPreserver() { try { ItemContainer stash = _characterInventory.Stash; if ((Object)(object)((stash != null) ? ((Component)stash).gameObject : null) == (Object)null) { Logger.LogInfo("Stash was null. Exiting TryRemoveStashPreserver."); return false; } Preserver privateField = ReflectionExtensions.GetPrivateField(stash, "m_preservationExt"); if ((Object)(object)privateField != (Object)null) { ReflectionExtensions.SetPrivateField(stash, "m_preservationExt", (Preserver)null); } Preserver component = ((Component)stash).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); return true; } } catch (Exception ex) { Logger.LogException("Failed to remove stash preserver.", ex); } return false; } public static Dictionary GetItemPrefabs() { FieldInfo field = typeof(ResourcesPrefabManager).GetField("ITEM_PREFABS", BindingFlags.Static | BindingFlags.NonPublic); return (Dictionary)field.GetValue(null); } public bool GetAreaContainsStash() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) AreaEnum area; return TryGetCurrentAreaEnum(out area) && InventorySettings.StashAreas.Contains(area); } public bool GetStashInventoryEnabled() { return _profile.StashSettingsProfile.CharInventoryEnabled && (GetAreaContainsStash() || _profile.StashSettingsProfile.CharInventoryAnywhereEnabled); } public bool GetMerchantStashEnabled() { return _profile.StashSettingsProfile.MerchantEnabled && (GetAreaContainsStash() || _profile.StashSettingsProfile.MerchantAnywhereEnabled); } public bool GetCraftFromStashEnabled() { return _profile.StashSettingsProfile.CraftingInventoryEnabled && (GetAreaContainsStash() || _profile.StashSettingsProfile.CraftingInventoryAnywhereEnabled); } public static bool TryGetCurrentAreaEnum(out AreaEnum area) { area = (AreaEnum)0; AreaManager instance = AreaManager.Instance; string text = ((instance == null) ? null : instance.CurrentArea?.SceneName); if (string.IsNullOrEmpty(text)) { return false; } area = (AreaEnum)AreaManager.Instance.GetAreaIndexFromSceneName(text); return true; } protected virtual void Dispose(bool disposing) { if (disposedValue) { return; } if (disposing) { CharacterInventoryPatches.AfterInventoryIngredients -= AddStashIngredients; CharacterManagerPatches.AfterAddCharacter -= ConfigureStashPreserverDelayed; if (_profileService != null) { _profileService.OnActiveProfileChanged -= TryConfigureStashPreserver; _profileService.OnActiveProfileSwitched -= TryConfigureStashPreserver; } ItemDisplayOptionPanelPatches.TryGetActiveActionsDelegate tryGetActiveActionsDelegate = default(ItemDisplayOptionPanelPatches.TryGetActiveActionsDelegate); IDictionaryExtensions.TryRemove((IDictionary)ItemDisplayOptionPanelPatches.TryGetActiveActions, _playerID, ref tryGetActiveActionsDelegate); ItemDisplayOptionPanelPatches.PressedActionDelegate pressedActionDelegate = default(ItemDisplayOptionPanelPatches.PressedActionDelegate); IDictionaryExtensions.TryRemove((IDictionary)ItemDisplayOptionPanelPatches.PlayersPressedAction, _playerID, ref pressedActionDelegate); ItemDisplayPatches.BeforeUpdateValueDisplayDelegate beforeUpdateValueDisplayDelegate = default(ItemDisplayPatches.BeforeUpdateValueDisplayDelegate); IDictionaryExtensions.TryRemove((IDictionary)ItemDisplayPatches.PlayersUpdateValueDisplay, _playerID, ref beforeUpdateValueDisplayDelegate); MenuPanelPatches.AfterOnHideInventoryMenu -= HideCurrencyValues; } _character = null; disposedValue = true; } public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } } internal class SlotActionViewData : IActionViewData { private readonly Func _getLogger; private readonly Player _player; private readonly Character _character; private readonly CharacterInventory _inventory; private readonly SlotDataService _slotData; private readonly IActionUIProfileService _profileService; private IModifLogger Logger => _getLogger(); public SlotActionViewData(Player player, Character character, SlotDataService slotData, IActionUIProfileService profileService, Func getLogger) { if (player == null) { throw new ArgumentNullException("player"); } if ((Object)(object)character == (Object)null) { throw new ArgumentNullException("character"); } _player = player; _character = character; _slotData = slotData; _inventory = character.Inventory; _profileService = profileService; _getLogger = getLogger; } public IEnumerable GetActionsTabData() { List list = new List(); int num = 0; list.Add(new ActionsDisplayTab { DisplayName = "Skills", TabOrder = num++, GetSlotActionsQuery = () => GetActiveSkills() }); list.Add(new ActionsDisplayTab { DisplayName = "Consumables", TabOrder = num++, GetSlotActionsQuery = () => GetConsumables() }); list.Add(new ActionsDisplayTab { DisplayName = "Deployables", TabOrder = num++, GetSlotActionsQuery = () => GetDeployables() }); list.Add(new ActionsDisplayTab { DisplayName = "Weapons", TabOrder = num++, GetSlotActionsQuery = () => GetWeapons() }); list.Add(new ActionsDisplayTab { DisplayName = "Armor", TabOrder = num++, GetSlotActionsQuery = () => GetArmor() }); list.Add(new ActionsDisplayTab { DisplayName = "Cosmetics", TabOrder = num++, GetSlotActionsQuery = () => GetCosmeticSkills() }); return (IEnumerable)list; } public IEnumerable GetAllActions() { List list = new List(); list.AddRange(GetArmor()); list.AddRange(GetWeapons()); list.AddRange(GetEquipped()); list.AddRange(GetDeployables()); list.AddRange(GetConsumables()); return list.OrderBy((ISlotAction i) => i.DisplayName); } public IEnumerable GetWeapons() { List list = new List(); list.AddRange(from s in _inventory.Equipment.EquipmentSlots where (Object)(object)s != (Object)null && s.HasItemEquipped && ((int)s.SlotType == 6 || (int)s.SlotType == 5) select s into e select _slotData.GetSlotAction((Item)(object)e.EquippedItem)); list.AddRange(from i in _inventory.Pouch.GetContainedItems() where i is Weapon select i into w select _slotData.GetSlotAction(w)); if (_inventory.HasABag) { list.AddRange(from i in ((ItemContainer)_inventory.EquippedBag.Container).GetContainedItems() where i is Weapon select i into w select _slotData.GetSlotAction(w)); } return list; } public IEnumerable GetActiveSkills() { return from Skill s in ((CharacterKnowledge)_inventory.SkillKnowledge).GetLearnedItems() where ((Item)s).IsQuickSlotable && !s.IsCosmetic && !(s is EquipmentSetSkill) select _slotData.GetSlotAction((Item)(object)s); } public IEnumerable GetCosmeticSkills() { return from Skill s in ((CharacterKnowledge)_inventory.SkillKnowledge).GetLearnedItems() where ((Item)s).IsQuickSlotable && s.IsCosmetic && !(s is EquipmentSetSkill) select _slotData.GetSlotAction((Item)(object)s); } public IEnumerable GetConsumables() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return from i in _inventory.GetOwnedItems(TagSourceManager.Consumable) group i by i.ItemID into i select _slotData.GetSlotAction(i.First()); } public IEnumerable GetDeployables() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return from s in _inventory.GetOwnedItems(TagSourceManager.Deployable) select _slotData.GetSlotAction(s); } public IEnumerable GetEquipped() { return from s in _inventory.Equipment.EquipmentSlots where (Object)(object)s != (Object)null && s.HasItemEquipped select s into e select _slotData.GetSlotAction((Item)(object)e.EquippedItem); } public IEnumerable GetArmor() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) return from s in ((IEnumerable)(from s in _inventory.Equipment.EquipmentSlots where (Object)(object)s != (Object)null && s.HasItemEquipped && ((int)s.SlotType == 0 || (int)s.SlotType == 1 || (int)s.SlotType == 3) select s into e select e.EquippedItem)).Union(_inventory.GetOwnedItems(TagSourceManager.Armor)) select _slotData.GetSlotAction(s); } } internal class SlotDataService : IDisposable { private readonly Func _getLogger; private readonly Player _rewiredPlayer; private readonly Character _character; private readonly CharacterInventory _inventory; private readonly IHotbarProfileService _profileService; private bool disposedValue; private IModifLogger Logger => _getLogger(); public SlotDataService(Player rewiredPlayer, Character character, IHotbarProfileService profileService, Func getLogger) { if (rewiredPlayer == null) { throw new ArgumentNullException("rewiredPlayer"); } if ((Object)(object)character == (Object)null) { throw new ArgumentNullException("character"); } _rewiredPlayer = rewiredPlayer; _character = character; _inventory = character.Inventory; _profileService = profileService; _getLogger = getLogger; } public bool TryGetItemSlotAction(SlotData slotData, bool combatModeEnabled, out ISlotAction slotAction) { return TryGetItemSlotAction(slotData.ItemID, slotData.ItemUID, combatModeEnabled, out slotAction); } public bool TryGetItemSlotAction(int itemID, string itemUID, bool combatModeEnabled, out ISlotAction slotAction) { slotAction = null; if (!TryFindOwnedItem(itemID, itemUID, out var item) && !TryFindPrefab(itemID, out item)) { return false; } Skill val = (Skill)(object)((item is Skill) ? item : null); if (val != null) { slotAction = (ISlotAction)(object)new SkillSlotAction(val, _rewiredPlayer, _character, this, combatModeEnabled, _getLogger); } else { Equipment val2 = (Equipment)(object)((item is Equipment) ? item : null); if (val2 != null) { slotAction = (ISlotAction)(object)new EquipmentSlotAction(val2, _rewiredPlayer, _character, this, combatModeEnabled, _getLogger); } else { slotAction = (ISlotAction)(object)new ItemSlotAction(item, _rewiredPlayer, _character, this, combatModeEnabled, _getLogger); } } return slotAction != null; } public bool TryFindOwnedItem(int itemId, string uid, out Item item) { item = null; IEnumerable source = from s in ((CharacterKnowledge)_inventory.SkillKnowledge).GetLearnedItems() where s.ItemID == itemId select s; if (source.Any()) { item = source.FirstOrDefault((Func)((Item s) => s.ItemID == itemId)) ?? source.First(); return true; } if (!_inventory.OwnsOrHasEquipped(itemId)) { return false; } if (!string.IsNullOrEmpty(uid)) { Item item2 = ItemManager.Instance.GetItem(uid); if ((Object)(object)item2 != (Object)null && (Object)(object)((EffectSynchronizer)item2).OwnerCharacter == (Object)(object)_character) { item = item2; return true; } } List ownedItems = _inventory.GetOwnedItems(itemId); if (ownedItems != null && ownedItems.Any()) { item = ownedItems.First(); return true; } _inventory.Equipment.OwnsItem(itemId, ref item); return (Object)(object)item != (Object)null; } public bool TryFindPrefab(int itemId, out Item item) { item = ResourcesPrefabManager.Instance.GetItemPrefab(itemId); return (Object)(object)item != (Object)null; } public ISlotAction GetSlotAction(Item item) { Skill val = (Skill)(object)((item is Skill) ? item : null); if (val != null) { Player rewiredPlayer = _rewiredPlayer; Character character = _character; IHotbarProfile profile = _profileService.GetProfile(); return (ISlotAction)(object)new SkillSlotAction(val, rewiredPlayer, character, this, profile == null || profile.CombatMode, _getLogger); } Equipment val2 = (Equipment)(object)((item is Equipment) ? item : null); if (val2 != null) { Player rewiredPlayer2 = _rewiredPlayer; Character character2 = _character; IHotbarProfile profile2 = _profileService.GetProfile(); return (ISlotAction)(object)new EquipmentSlotAction(val2, rewiredPlayer2, character2, this, profile2 == null || profile2.CombatMode, _getLogger); } Player rewiredPlayer3 = _rewiredPlayer; Character character3 = _character; IHotbarProfile profile3 = _profileService.GetProfile(); return (ISlotAction)(object)new ItemSlotAction(item, rewiredPlayer3, character3, this, profile3 == null || profile3.CombatMode, _getLogger); } protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { } disposedValue = true; } } public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } } internal class DurabilityDisplayService { private readonly Func _loggerFactory; private PlayerMenuService _playerMenuService; private LevelCoroutines _coroutines; private bool _unequipedAdded; private bool _equipTracked = false; private bool _configured = false; private static readonly UnequippedDurabilityTracker UnequippedHelm = new UnequippedDurabilityTracker((EquipSlots)1, (DurableEquipmentType)1, 1f); private static readonly UnequippedDurabilityTracker UnequippedChest = new UnequippedDurabilityTracker((EquipSlots)2, (DurableEquipmentType)2, 1f); private static readonly UnequippedDurabilityTracker UnequippedBoots = new UnequippedDurabilityTracker((EquipSlots)5, (DurableEquipmentType)6, 1f); private static readonly Dictionary Unequipped = new Dictionary { { UnequippedHelm.DurableEquipmentSlot, UnequippedHelm }, { UnequippedChest.DurableEquipmentSlot, UnequippedChest }, { UnequippedBoots.DurableEquipmentSlot, UnequippedBoots } }; private IModifLogger Logger => _loggerFactory(); public DurabilityDisplayService(PlayerMenuService playerMenuService, LevelCoroutines coroutines, Func loggerFactory) { _playerMenuService = playerMenuService; _coroutines = coroutines; _loggerFactory = loggerFactory; EquipmentPatches.AfterOnEquip += TrackEquippedItem; EquipmentPatches.AfterOnUnequip += UntrackEquippedItem; _playerMenuService.OnPlayerActionMenusConfigured += TryConfigureShowHide; SplitScreenManagerPatches.RemoveLocalPlayerAfter += SplitScreenManagerPatches_RemoveLocalPlayerAfter; } private void TryConfigureShowHide(PlayerActionMenus actionMenus, SplitPlayer splitPlayer) { try { ConfigureShowHide(actionMenus, splitPlayer); } catch (Exception ex) { Logger.LogException("Failed to configure DurabilityDisplayService.", ex); } } private void ConfigureShowHide(PlayerActionMenus actionMenus, SplitPlayer splitPlayer) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown UnityServicesProvider servicesProvider = Psp.Instance.GetServicesProvider(splitPlayer.RewiredID); IActionUIProfileService profileService = servicesProvider.GetService(); Reset(actionMenus); profileService.OnActiveProfileChanged += delegate(IActionUIProfile profile) { ShowHide(splitPlayer.RewiredID, profile.DurabilityDisplayEnabled); }; profileService.OnActiveProfileSwitched += delegate(IActionUIProfile profile) { ShowHide(splitPlayer.RewiredID, profile.DurabilityDisplayEnabled); }; if (actionMenus.DurabilityDisplay.IsAwake) { ShowHide(splitPlayer.RewiredID, profileService.GetActiveProfile().DurabilityDisplayEnabled); } else { actionMenus.DurabilityDisplay.OnAwake.AddListener((UnityAction)delegate { ShowHide(splitPlayer.RewiredID, profileService.GetActiveProfile().DurabilityDisplayEnabled); }); } _configured = true; } private void Reset(PlayerActionMenus actionMenus) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) if (!actionMenus.DurabilityDisplay.IsAwake) { return; } Logger.LogDebug(string.Format("{0}::{1}: Stopping Durability tracking for all slots for rewiredId={2}.", "DurabilityDisplayService", "Reset", actionMenus.PlayerID)); foreach (EquipSlots item in Enum.GetValues(typeof(EquipSlots)).Cast()) { actionMenus.DurabilityDisplay.StopTracking(item); } } private void ShowHide(int playerId, bool showDurabilityDisplay) { Logger.LogDebug(string.Format("{0}::{1}: playerId={2}, showDurabilityDisplay={3}", "DurabilityDisplayService", "ShowHide", playerId, showDurabilityDisplay)); UnityServicesProvider servicesProvider = Psp.Instance.GetServicesProvider(playerId); PlayerActionMenus service = servicesProvider.GetService(); DurabilityDisplay durabilityDisplay = service.DurabilityDisplay; if (showDurabilityDisplay) { if (!((Component)durabilityDisplay).gameObject.activeSelf) { ((Component)durabilityDisplay).gameObject.SetActive(true); } _equipTracked = true; SplitPlayer val = ((IEnumerable)SplitScreenManager.Instance.LocalPlayers).FirstOrDefault((Func)((SplitPlayer p) => p.RewiredID == playerId)); if (val != null && (Object)(object)((val != null) ? val.AssignedCharacter : null) != (Object)null) { AddUnequippedTrackers(val.RewiredID); durabilityDisplay.StopTracking((EquipSlots)4); durabilityDisplay.StopTracking((EquipSlots)3); TrackAllEquipment(val.AssignedCharacter); } } else { if (((Component)durabilityDisplay).gameObject.activeSelf) { ((Component)durabilityDisplay).gameObject.SetActive(false); } if (_equipTracked) { durabilityDisplay.StopAllTracking(); _equipTracked = false; } } } private void TrackAllEquipment(Character character) { Logger.LogDebug(string.Format("{0}::{1}: Player RewiredID {2}", "DurabilityDisplayService", "TrackAllEquipment", character.CharacterUI.RewiredID)); TrackEquipmentSlot(character, (EquipmentSlotIDs)0); TrackEquipmentSlot(character, (EquipmentSlotIDs)1); TrackEquipmentSlot(character, (EquipmentSlotIDs)3); TrackEquipmentSlot(character, (EquipmentSlotIDs)5); TrackEquipmentSlot(character, (EquipmentSlotIDs)6); } public void UntrackAllEquipment() { } private void TrackEquipmentSlot(Character character, EquipmentSlotIDs slot) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown if (!character.Inventory.Equipment.IsEquipmentSlotEmpty(slot)) { Logger.LogDebug(string.Format("{0}::{1}: Tracking Equipment Slot {2} for Player RewiredID {3}", "DurabilityDisplayService", "TrackEquipmentSlot", slot, character.CharacterUI.RewiredID)); TrackEquippedItem(character, (Equipment)character.Inventory.Equipment.GetEquippedItem(slot)); } } private void SplitScreenManagerPatches_RemoveLocalPlayerAfter(SplitScreenManager splitScreenManager, SplitPlayer player, string playerUID) { ShowHide(player.RewiredID, showDurabilityDisplay: false); } private void AddUnequippedTrackers(int playerId) { Logger.LogDebug(string.Format("{0}::{1}: Adding Unequipped Helm, Chest and Boots trackers for for playerId {2}", "DurabilityDisplayService", "AddUnequippedTrackers", playerId)); DurabilityDisplay durabilityDisplay = GetDurabilityDisplay(playerId); durabilityDisplay.TrackDurability((IDurability)(object)UnequippedHelm); durabilityDisplay.TrackDurability((IDurability)(object)UnequippedChest); durabilityDisplay.TrackDurability((IDurability)(object)UnequippedBoots); _unequipedAdded = true; } private void TrackEquippedItem(Character character, Equipment equipment) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) if (!_equipTracked) { return; } DurabilityDisplay durabilityDisplay = GetDurabilityDisplay(character.OwnerPlayerSys.PlayerID); if ((Object)(object)durabilityDisplay == (Object)null) { return; } EquipSlots val = ((Item)equipment).CurrentEquipmentSlot.SlotType.ToDurableEquipmentSlot(); if ((int)val == 0) { return; } if (!_unequipedAdded) { AddUnequippedTrackers(character.OwnerPlayerSys.PlayerID); } if (((Item)equipment).IsIndestructible || !character.Inventory.Equipment.HasItemEquipped(((Item)equipment).CurrentEquipmentSlot.SlotType)) { if (Unequipped.TryGetValue(val, out var value)) { durabilityDisplay.TrackDurability((IDurability)(object)value); } else { durabilityDisplay.StopTracking(val); } } else { Logger.LogDebug($"Tracking durability of equipment {((Object)equipment).name} for player {character.OwnerPlayerSys.PlayerID}."); durabilityDisplay.TrackDurability((IDurability)(object)new DurabilityTracker(equipment)); } } private void UntrackEquippedItem(Character character, Equipment equipment) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (!_equipTracked) { return; } DurabilityDisplay durabilityDisplay = GetDurabilityDisplay(character.OwnerPlayerSys.PlayerID); if ((Object)(object)durabilityDisplay == (Object)null) { return; } EquipSlots val = ((Item)equipment).CurrentEquipmentSlot.SlotType.ToDurableEquipmentSlot(); if ((int)val == 0) { return; } if (!_unequipedAdded) { AddUnequippedTrackers(character.OwnerPlayerSys.PlayerID); } if (character.Inventory.Equipment.IsEquipmentSlotEmpty(equipment.EquipSlot)) { if (!character.Inventory.Equipment.HasItemEquipped(((Item)equipment).CurrentEquipmentSlot.SlotType) && Unequipped.TryGetValue(val, out var value)) { durabilityDisplay.TrackDurability((IDurability)(object)value); return; } durabilityDisplay.StopTracking(val); Logger.LogDebug($"Stopped tracking durability of equipment {((Object)equipment).name} for player {character.OwnerPlayerSys.PlayerID}."); } } private DurabilityDisplay GetDurabilityDisplay(int playerId) { UnityServicesProvider val = default(UnityServicesProvider); PlayerActionMenus val2 = default(PlayerActionMenus); if (Psp.Instance.TryGetServicesProvider(playerId, ref val) && val.TryGetService(ref val2)) { return val2.DurabilityDisplay; } return null; } } public class GlobalActionUIProfileService : IActionUIProfileService { private class GlobalActionUIProfile : IActionUIProfile { public string Name { get; set; } = "Global"; public bool ActionSlotsEnabled { get; set; } = true; public bool DurabilityDisplayEnabled { get; set; } = true; public bool EquipmentSetsEnabled { get { return false; } set { } } public EquipmentSetsSettingsProfile EquipmentSetsSettingsProfile { get; set; } = new EquipmentSetsSettingsProfile(); public StashSettingsProfile StashSettingsProfile { get; set; } = new StashSettingsProfile(); public StorageSettingsProfile StorageSettingsProfile { get; set; } = new StorageSettingsProfile(); } private GlobalActionUIProfile _globalProfile = new GlobalActionUIProfile(); public event Action OnActiveProfileChanged; public event Action OnActiveProfileSwitched; public event Action OnActiveProfileSwitching; public IActionUIProfile GetActiveProfile() { return (IActionUIProfile)(object)_globalProfile; } public IEnumerable GetProfileNames() { return new string[1] { "Global" }; } public void Save() { } public void SaveNew(IActionUIProfile profile) { } public void SetActiveProfile(string name) { } public void Rename(string newName) { } } public class GlobalConfigService { public static GlobalConfigService Instance { get; private set; } public PositionsProfile PositionsProfile { get; private set; } public IHotbarProfile NavPanelProfile { get; private set; } public GlobalConfigService() { Instance = this; LoadPositions(); } public void LoadPositions() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (string.IsNullOrEmpty(ActionUISettings.SerializedPositions.Value)) { PositionsProfile = new PositionsProfile(); return; } try { PositionsProfile = JsonConvert.DeserializeObject(ActionUISettings.SerializedPositions.Value); } catch { PositionsProfile = new PositionsProfile(); } } public void SavePositions() { if (PositionsProfile != null) { ActionUISettings.SerializedPositions.Value = JsonConvert.SerializeObject((object)PositionsProfile, (Formatting)0); } } } public class GlobalHotbarService : IHotbarProfileService { private HotbarProfileData _cachedProfile; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private Action m_OnProfileChanged; private IModifLogger Logger = LoggerFactory.GetLogger("ModifAmorphic.Outward.ActionUI"); private CharacterSlotData _activeCharacterSlotData; private string _activeCharacterUID; private const int LegacyNoWeaponType = -1; private bool _isSaving = false; public event Action OnProfileChanged { [CompilerGenerated] add { Action val = this.m_OnProfileChanged; Action val2; do { val2 = val; Action value2 = (Action)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref this.m_OnProfileChanged, value2, val2); } while (val != val2); } [CompilerGenerated] remove { Action val = this.m_OnProfileChanged; Action val2; do { val2 = val; Action value2 = (Action)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value); val = Interlocked.CompareExchange(ref this.m_OnProfileChanged, value2, val2); } while (val != val2); } } public GlobalHotbarService() { LoadProfile(); ActionUISettings.Rows.SettingChanged += delegate { UpdateFromSettings((HotbarProfileChangeTypes)3); }; ActionUISettings.SlotsPerRow.SettingChanged += delegate { UpdateFromSettings((HotbarProfileChangeTypes)5); }; ActionUISettings.Scale.SettingChanged += delegate { UpdateFromSettings((HotbarProfileChangeTypes)11); }; ActionUISettings.HideLeftNav.SettingChanged += delegate { UpdateFromSettings((HotbarProfileChangeTypes)10); }; ActionUISettings.CombatMode.SettingChanged += delegate { UpdateFromSettings((HotbarProfileChangeTypes)8); }; ActionUISettings.ShowCooldownTimer.SettingChanged += delegate { UpdateFromSettings((HotbarProfileChangeTypes)7); }; ActionUISettings.PreciseCooldownTime.SettingChanged += delegate { UpdateFromSettings((HotbarProfileChangeTypes)7); }; } private void LoadProfile() { string value = ActionUISettings.SerializedHotbars.Value; if (string.IsNullOrEmpty(value)) { _cachedProfile = CreateDefaultProfile(); Save(); return; } try { _cachedProfile = JsonConvert.DeserializeObject(value); if (_cachedProfile == null) { _cachedProfile = CreateDefaultProfile(); } SyncSettingsToProfile(_cachedProfile); } catch { _cachedProfile = CreateDefaultProfile(); } } private void SyncSettingsToProfile(HotbarProfileData profile) { profile.Rows = ActionUISettings.Rows.Value; profile.SlotsPerRow = ActionUISettings.SlotsPerRow.Value; profile.Scale = ActionUISettings.Scale.Value; profile.HideLeftNav = ActionUISettings.HideLeftNav.Value; profile.CombatMode = ActionUISettings.CombatMode.Value; foreach (IHotbarSlotData hotbar in profile.Hotbars) { foreach (ISlotData slot in hotbar.Slots) { slot.Config.ShowCooldownTime = ActionUISettings.ShowCooldownTimer.Value; slot.Config.PreciseCooldownTime = ActionUISettings.PreciseCooldownTime.Value; } } EnsureDimensions(profile, profile.Rows, profile.SlotsPerRow); } private void EnsureDimensions(HotbarProfileData profile, int rows, int slotsPerRow) { if (profile == null) { return; } profile.Rows = Math.Max(1, rows); profile.SlotsPerRow = Math.Max(1, slotsPerRow); if (profile.Hotbars == null || profile.Hotbars.Count == 0) { profile.Hotbars = DeepCloneHotbars(HotbarSettings.DefaulHotbarProfile.Hotbars); } int num = profile.Rows * profile.SlotsPerRow; for (int i = 0; i < profile.Hotbars.Count; i++) { HotbarData hotbarData = profile.Hotbars[i] as HotbarData; if (hotbarData == null) { hotbarData = new HotbarData { HotbarIndex = i, RewiredActionId = RewiredConstants.ActionSlots.HotbarNavActions[Math.Min(i, RewiredConstants.ActionSlots.HotbarNavActions.Count - 1)].id, RewiredActionName = RewiredConstants.ActionSlots.HotbarNavActions[Math.Min(i, RewiredConstants.ActionSlots.HotbarNavActions.Count - 1)].name, Slots = new List() }; profile.Hotbars[i] = (IHotbarSlotData)(object)hotbarData; } if (hotbarData.Slots == null) { hotbarData.Slots = new List(); } if (hotbarData.Slots.Count == 0) { hotbarData.Slots.Add((ISlotData)(object)CreateDefaultSlotData(0)); } while (hotbarData.Slots.Count < num) { hotbarData.Slots.Add((ISlotData)(object)CreateSlotDataFrom(hotbarData.Slots[0], hotbarData.Slots.Count)); } if (hotbarData.Slots.Count > num) { hotbarData.Slots.RemoveRange(num, hotbarData.Slots.Count - num); } ReindexSlots(hotbarData.Slots); } } private HotbarProfileData CreateDefaultProfile() { HotbarProfileData hotbarProfileData = new HotbarProfileData { Rows = ActionUISettings.Rows.Value, SlotsPerRow = ActionUISettings.SlotsPerRow.Value, Scale = ActionUISettings.Scale.Value, HideLeftNav = ActionUISettings.HideLeftNav.Value, CombatMode = ActionUISettings.CombatMode.Value, Hotbars = DeepCloneHotbars(HotbarSettings.DefaulHotbarProfile.Hotbars), NextRewiredActionId = RewiredConstants.ActionSlots.NextHotbarAction.id, NextRewiredActionName = RewiredConstants.ActionSlots.NextHotbarAction.name, PrevRewiredActionId = RewiredConstants.ActionSlots.PreviousHotbarAction.id, PrevRewiredActionName = RewiredConstants.ActionSlots.PreviousHotbarAction.name, NextRewiredAxisActionName = RewiredConstants.ActionSlots.NextHotbarAxisAction.name, NextRewiredAxisActionId = RewiredConstants.ActionSlots.NextHotbarAxisAction.id, PrevRewiredAxisActionName = RewiredConstants.ActionSlots.PreviousHotbarAxisAction.name, PrevRewiredAxisActionId = RewiredConstants.ActionSlots.PreviousHotbarAxisAction.id }; EnsureDimensions(hotbarProfileData, hotbarProfileData.Rows, hotbarProfileData.SlotsPerRow); return hotbarProfileData; } public IHotbarProfile GetProfile() { if (_cachedProfile == null) { LoadProfile(); } return (IHotbarProfile)(object)_cachedProfile; } public void Save() { SaveNew(GetProfile()); } public void SaveNew(IHotbarProfile hotbarProfile) { if (_isSaving) { return; } _isSaving = true; try { if (ActionUISettings.Rows.Value != hotbarProfile.Rows) { ActionUISettings.Rows.Value = hotbarProfile.Rows; } if (ActionUISettings.SlotsPerRow.Value != hotbarProfile.SlotsPerRow) { ActionUISettings.SlotsPerRow.Value = hotbarProfile.SlotsPerRow; } if (ActionUISettings.Scale.Value != hotbarProfile.Scale) { ActionUISettings.Scale.Value = hotbarProfile.Scale; } if (ActionUISettings.HideLeftNav.Value != hotbarProfile.HideLeftNav) { ActionUISettings.HideLeftNav.Value = hotbarProfile.HideLeftNav; } if (ActionUISettings.CombatMode.Value != hotbarProfile.CombatMode) { ActionUISettings.CombatMode.Value = hotbarProfile.CombatMode; } if (hotbarProfile.Hotbars.Count > 0 && hotbarProfile.Hotbars[0].Slots.Count > 0) { IActionSlotConfig config = hotbarProfile.Hotbars[0].Slots[0].Config; if (ActionUISettings.ShowCooldownTimer.Value != config.ShowCooldownTime) { ActionUISettings.ShowCooldownTimer.Value = config.ShowCooldownTime; } if (ActionUISettings.PreciseCooldownTime.Value != config.PreciseCooldownTime) { ActionUISettings.PreciseCooldownTime.Value = config.PreciseCooldownTime; } } string text = JsonConvert.SerializeObject((object)hotbarProfile, (Formatting)0); if (ActionUISettings.SerializedHotbars.Value != text) { ActionUISettings.SerializedHotbars.Value = text; } } finally { _isSaving = false; } } public IHotbarProfile AddHotbar() { int num = GetProfile().Hotbars.Last().HotbarIndex + 1; HotbarData hotbarData = new HotbarData { HotbarIndex = num, RewiredActionId = RewiredConstants.ActionSlots.HotbarNavActions[num].id, RewiredActionName = RewiredConstants.ActionSlots.HotbarNavActions[num].name }; foreach (ISlotData slot in GetProfile().Hotbars.First().Slots) { SlotData slotData = slot as SlotData; hotbarData.Slots.Add((ISlotData)(object)CreateSlotDataFrom(slot, slot.SlotIndex)); } GetProfile().Hotbars.Add((IHotbarSlotData)(object)hotbarData); Save(); this.OnProfileChanged?.Invoke(GetProfile(), (HotbarProfileChangeTypes)1); return GetProfile(); } public IHotbarProfile RemoveHotbar() { if (GetProfile().Hotbars.Count > 1) { GetProfile().Hotbars.RemoveAt(GetProfile().Hotbars.Count - 1); Save(); this.OnProfileChanged?.Invoke(GetProfile(), (HotbarProfileChangeTypes)2); } return GetProfile(); } public IHotbarProfile AddRow() { IHotbarProfile profile = GetProfile(); int rows = profile.Rows; profile.Rows = rows + 1; SyncStructure(); Save(); this.OnProfileChanged?.Invoke(GetProfile(), (HotbarProfileChangeTypes)3); return GetProfile(); } public IHotbarProfile RemoveRow() { if (GetProfile().Rows > 1) { IHotbarProfile profile = GetProfile(); int rows = profile.Rows; profile.Rows = rows - 1; SyncStructure(); Save(); this.OnProfileChanged?.Invoke(GetProfile(), (HotbarProfileChangeTypes)4); } return GetProfile(); } public IHotbarProfile AddSlot() { IHotbarProfile profile = GetProfile(); int slotsPerRow = profile.SlotsPerRow; profile.SlotsPerRow = slotsPerRow + 1; SyncStructure(); Save(); this.OnProfileChanged?.Invoke(GetProfile(), (HotbarProfileChangeTypes)5); return GetProfile(); } public IHotbarProfile RemoveSlot() { if (GetProfile().SlotsPerRow > 1) { IHotbarProfile profile = GetProfile(); int slotsPerRow = profile.SlotsPerRow; profile.SlotsPerRow = slotsPerRow - 1; SyncStructure(); Save(); this.OnProfileChanged?.Invoke(GetProfile(), (HotbarProfileChangeTypes)6); } return GetProfile(); } public void Update(HotbarsContainer hotbar) { //IL_01e9: Unknown result type (might be due to invalid IL or missing references) if (((hotbar != null) ? hotbar.Hotbars : null) != null && _cachedProfile?.Hotbars != null) { bool flag = true; for (int i = 0; i < hotbar.Hotbars.Length; i++) { if (hotbar.Hotbars[i].Any((ActionSlot s) => s.SlotAction != null)) { flag = false; break; } } bool flag2 = false; if (flag) { bool flag3 = false; foreach (IHotbarSlotData hotbar2 in _cachedProfile.Hotbars) { if (hotbar2.Slots.Any((ISlotData s) => s.ItemID > 0 || !string.IsNullOrEmpty(s.ItemUID))) { flag3 = true; break; } } if (flag3) { Logger.LogWarning("GlobalHotbarService: Detected update from EMPTY UI while profile has items. Preserving item assignments and syncing slot config only."); flag2 = true; } } for (int j = 0; j < hotbar.Hotbars.Length && j < _cachedProfile.Hotbars.Count; j++) { ActionSlot[] array = hotbar.Hotbars[j]; IHotbarSlotData val = _cachedProfile.Hotbars[j]; for (int k = 0; k < array.Length && k < val.Slots.Count; k++) { ActionSlot val2 = array[k]; ISlotData val3 = val.Slots[k]; if (!flag2 && val2.SlotAction != null) { val3.ItemID = val2.SlotAction.ActionId; val3.ItemUID = val2.SlotAction.ActionUid; } else if (!flag2) { val3.ItemID = -1; val3.ItemUID = null; } if (val2.Config != null) { val3.Config.EmptySlotOption = val2.Config.EmptySlotOption; val3.Config.IsDisabled = val2.Config.IsDisabled; val3.Config.IsDynamic = val2.Config.IsDynamic; } } } } Save(); } public IHotbarProfile SetCooldownTimer(bool showTimer, bool preciseTime) { _cachedProfile.ShowCooldownTimer = showTimer; foreach (IHotbarSlotData hotbar in _cachedProfile.Hotbars) { foreach (ISlotData slot in hotbar.Slots) { slot.Config.ShowCooldownTime = showTimer; slot.Config.PreciseCooldownTime = preciseTime; } } Save(); this.OnProfileChanged?.Invoke((IHotbarProfile)(object)_cachedProfile, (HotbarProfileChangeTypes)7); return (IHotbarProfile)(object)_cachedProfile; } public IHotbarProfile SetCombatMode(bool combatMode) { _cachedProfile.CombatMode = combatMode; Save(); this.OnProfileChanged?.Invoke((IHotbarProfile)(object)_cachedProfile, (HotbarProfileChangeTypes)8); return (IHotbarProfile)(object)_cachedProfile; } public IHotbarProfile SetEmptySlotView(EmptySlotOptions option) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) foreach (IHotbarSlotData hotbar in _cachedProfile.Hotbars) { foreach (ISlotData slot in hotbar.Slots) { slot.Config.EmptySlotOption = option; } } Save(); this.OnProfileChanged?.Invoke((IHotbarProfile)(object)_cachedProfile, (HotbarProfileChangeTypes)9); return (IHotbarProfile)(object)_cachedProfile; } public IHotbarProfile SetHideLeftNav(bool hideLeftNav) { _cachedProfile.HideLeftNav = hideLeftNav; Save(); this.OnProfileChanged?.Invoke((IHotbarProfile)(object)_cachedProfile, (HotbarProfileChangeTypes)10); return (IHotbarProfile)(object)_cachedProfile; } public IHotbarProfile SetScale(int scale) { _cachedProfile.Scale = scale; Save(); this.OnProfileChanged?.Invoke((IHotbarProfile)(object)_cachedProfile, (HotbarProfileChangeTypes)11); return (IHotbarProfile)(object)_cachedProfile; } private void SyncStructure() { EnsureDimensions(_cachedProfile, _cachedProfile.Rows, _cachedProfile.SlotsPerRow); } private void UpdateFromSettings(HotbarProfileChangeTypes type) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!_isSaving) { SyncSettingsToProfile(_cachedProfile); SyncStructure(); Save(); this.OnProfileChanged?.Invoke((IHotbarProfile)(object)_cachedProfile, type); } } private void ReindexSlots(List slots) { for (int i = 0; i < slots.Count; i++) { slots[i].SlotIndex = i; if (i < RewiredConstants.ActionSlots.Actions.Count) { ((ActionConfig)(object)slots[i].Config).RewiredActionId = RewiredConstants.ActionSlots.Actions[i].id; ((ActionConfig)(object)slots[i].Config).RewiredActionName = RewiredConstants.ActionSlots.Actions[i].name; } } } private SlotData CreateSlotDataFrom(ISlotData source, int slotIndex) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) ActionConfig config = new ActionConfig { EmptySlotOption = source.Config.EmptySlotOption, ShowCooldownTime = source.Config.ShowCooldownTime, PreciseCooldownTime = source.Config.PreciseCooldownTime, ShowZeroStackAmount = source.Config.ShowZeroStackAmount, IsDisabled = source.Config.IsDisabled, IsDynamic = source.Config.IsDynamic }; return new SlotData { SlotIndex = slotIndex, Config = (IActionSlotConfig)(object)config, ItemID = -1, ItemUID = null }; } private List DeepCloneHotbars(List original) { //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got I4 //IL_01c0->IL01c0: Incompatible stack types: O vs I4 //IL_01bb->IL01c0: Incompatible stack types: I4 vs O //IL_01bb->IL01c0: Incompatible stack types: O vs I4 List list = new List(); if (original == null) { return list; } for (int i = 0; i < original.Count; i++) { IHotbarSlotData val = original[i]; HotbarData hotbarData = val as HotbarData; HotbarData hotbarData2 = new HotbarData { HotbarIndex = val.HotbarIndex, RewiredActionId = (hotbarData?.RewiredActionId ?? RewiredConstants.ActionSlots.HotbarNavActions[Math.Min(i, RewiredConstants.ActionSlots.HotbarNavActions.Count - 1)].id), RewiredActionName = (hotbarData?.RewiredActionName ?? RewiredConstants.ActionSlots.HotbarNavActions[Math.Min(i, RewiredConstants.ActionSlots.HotbarNavActions.Count - 1)].name), HotbarHotkey = val.HotbarHotkey, Slots = new List() }; if (val.Slots != null) { for (int j = 0; j < val.Slots.Count; j++) { ISlotData val2 = val.Slots[j]; object obj = hotbarData2.Slots; SlotData slotData = new SlotData { SlotIndex = val2.SlotIndex, ItemID = val2.ItemID, ItemUID = val2.ItemUID }; object obj2 = slotData; ActionConfig actionConfig = new ActionConfig(); IActionSlotConfig config = val2.Config; actionConfig.HotkeyText = ((config != null) ? config.HotkeyText : null); IActionSlotConfig config2 = val2.Config; actionConfig.ShowCooldownTime = config2 != null && config2.ShowCooldownTime; IActionSlotConfig config3 = val2.Config; actionConfig.PreciseCooldownTime = config3 != null && config3.PreciseCooldownTime; IActionSlotConfig config4 = val2.Config; actionConfig.ShowZeroStackAmount = config4 != null && config4.ShowZeroStackAmount; obj2 = actionConfig; IActionSlotConfig config5 = val2.Config; int num; if (config5 == null) { num = 0; obj = num; num = (int)obj; } else { obj = config5.EmptySlotOption; num = (int)obj; } ((ActionConfig)obj2).EmptySlotOption = (EmptySlotOptions)obj; actionConfig.RewiredActionName = (val2.Config as ActionConfig)?.RewiredActionName; actionConfig.RewiredActionId = (val2.Config as ActionConfig)?.RewiredActionId ?? 0; IActionSlotConfig config6 = val2.Config; actionConfig.IsDisabled = config6 != null && config6.IsDisabled; IActionSlotConfig config7 = val2.Config; actionConfig.IsDynamic = config7 != null && config7.IsDynamic; ((SlotData)obj2).Config = (IActionSlotConfig)(object)actionConfig; ((List)num).Add((ISlotData)(object)slotData); } } list.Add((IHotbarSlotData)(object)hotbarData2); } return list; } private SlotData CreateDefaultSlotData(int slotIndex) { int index = Math.Min(slotIndex, RewiredConstants.ActionSlots.Actions.Count - 1); return new SlotData { SlotIndex = slotIndex, ItemID = -1, ItemUID = null, Config = (IActionSlotConfig)(object)new ActionConfig { RewiredActionId = RewiredConstants.ActionSlots.Actions[index].id, RewiredActionName = RewiredConstants.ActionSlots.Actions[index].name, EmptySlotOption = (EmptySlotOptions)0, ShowCooldownTime = ActionUISettings.ShowCooldownTimer.Value, PreciseCooldownTime = ActionUISettings.PreciseCooldownTime.Value, ShowZeroStackAmount = false, IsDisabled = false, IsDynamic = false } }; } public void LoadCharacterSlots(string characterUID) { if (string.IsNullOrEmpty(characterUID)) { Logger.LogWarning("LoadCharacterSlots called with empty characterUID"); return; } _activeCharacterUID = characterUID; _activeCharacterSlotData = new CharacterSlotData { CharacterUID = characterUID, Slots = new Dictionary(), DisabledSlots = new HashSet(), DynamicPresets = new Dictionary>() }; string characterSlotFilePath = GetCharacterSlotFilePath(characterUID); if (!File.Exists(characterSlotFilePath)) { Logger.LogDebug("No character slot file found for " + characterUID + " at " + characterSlotFilePath + ". Starting with empty slots."); { foreach (IHotbarSlotData hotbar in _cachedProfile.Hotbars) { foreach (ISlotData slot in hotbar.Slots) { slot.ItemID = -1; slot.ItemUID = null; } } return; } } try { string text = File.ReadAllText(characterSlotFilePath); CharacterSlotData characterSlotData = JsonConvert.DeserializeObject(text); if (characterSlotData == null) { return; } if (characterSlotData.Slots == null) { characterSlotData.Slots = new Dictionary(); } if (characterSlotData.DisabledSlots == null) { characterSlotData.DisabledSlots = new HashSet(); } if (characterSlotData.DynamicPresets == null) { characterSlotData.DynamicPresets = new Dictionary>(); } MigrateLegacyDynamicPresetKeys(characterSlotData); _activeCharacterSlotData = characterSlotData; foreach (IHotbarSlotData hotbar2 in _cachedProfile.Hotbars) { int num = _cachedProfile.Hotbars.IndexOf(hotbar2); foreach (ISlotData slot2 in hotbar2.Slots) { int num2 = hotbar2.Slots.IndexOf(slot2); string key = $"{num}_{num2}"; if (characterSlotData.Slots.TryGetValue(key, out var value)) { slot2.ItemID = value.ItemID; slot2.ItemUID = value.ItemUID; } else { slot2.ItemID = -1; slot2.ItemUID = null; } } } Logger.LogDebug("Loaded character slots for " + characterUID + " from " + characterSlotFilePath + "."); } catch (Exception ex) { Logger.LogException("Failed to load character slots for " + characterUID, ex); } } public void SaveCharacterSlots(string characterUID) { if (string.IsNullOrEmpty(characterUID)) { Logger.LogWarning("SaveCharacterSlots called with empty characterUID"); return; } try { string characterHotbarsPath = ActionUISettings.CharacterHotbarsPath; if (!Directory.Exists(characterHotbarsPath)) { Directory.CreateDirectory(characterHotbarsPath); } CharacterSlotData characterSlotData = _activeCharacterSlotData; if (characterSlotData == null || !string.Equals(_activeCharacterUID, characterUID, StringComparison.Ordinal)) { characterSlotData = new CharacterSlotData { CharacterUID = characterUID, Slots = new Dictionary(), DisabledSlots = new HashSet(), DynamicPresets = new Dictionary>() }; } characterSlotData.CharacterUID = characterUID; characterSlotData.Slots = new Dictionary(); if (characterSlotData.DisabledSlots == null) { characterSlotData.DisabledSlots = new HashSet(); } if (characterSlotData.DynamicPresets == null) { characterSlotData.DynamicPresets = new Dictionary>(); } foreach (IHotbarSlotData hotbar in _cachedProfile.Hotbars) { int num = _cachedProfile.Hotbars.IndexOf(hotbar); foreach (ISlotData slot in hotbar.Slots) { int num2 = hotbar.Slots.IndexOf(slot); string key = $"{num}_{num2}"; if (slot.ItemID > 0 || !string.IsNullOrEmpty(slot.ItemUID)) { characterSlotData.Slots[key] = new SlotDataEntry { ItemID = slot.ItemID, ItemUID = slot.ItemUID }; } } } string characterSlotFilePath = GetCharacterSlotFilePath(characterUID); string contents = JsonConvert.SerializeObject((object)characterSlotData, (Formatting)1); File.WriteAllText(characterSlotFilePath, contents); _activeCharacterUID = characterUID; _activeCharacterSlotData = characterSlotData; Logger.LogDebug("Saved character slots for " + characterUID + " to " + characterSlotFilePath + "."); } catch (Exception ex) { Logger.LogException("Failed to save character slots for " + characterUID, ex); } } public bool TryGetDynamicPresetSlot(string contextKey, int hotbarIndex, int slotIndex, out SlotDataEntry slotEntry) { slotEntry = null; if (string.IsNullOrWhiteSpace(contextKey) || _activeCharacterSlotData?.DynamicPresets == null) { return false; } string slotKey = GetSlotKey(hotbarIndex, slotIndex); if (!_activeCharacterSlotData.DynamicPresets.TryGetValue(contextKey, out var value) || value == null) { return false; } return value.TryGetValue(slotKey, out slotEntry) && slotEntry != null; } public void SetDynamicPresetSlot(string contextKey, int hotbarIndex, int slotIndex, int itemId, string itemUid) { if (!string.IsNullOrWhiteSpace(contextKey)) { if (_activeCharacterSlotData == null) { _activeCharacterSlotData = new CharacterSlotData { CharacterUID = _activeCharacterUID, Slots = new Dictionary(), DisabledSlots = new HashSet(), DynamicPresets = new Dictionary>() }; } if (_activeCharacterSlotData.DynamicPresets == null) { _activeCharacterSlotData.DynamicPresets = new Dictionary>(); } string slotKey = GetSlotKey(hotbarIndex, slotIndex); if (!_activeCharacterSlotData.DynamicPresets.TryGetValue(contextKey, out var value) || value == null) { value = new Dictionary(); _activeCharacterSlotData.DynamicPresets[contextKey] = value; } value[slotKey] = new SlotDataEntry { ItemID = itemId, ItemUID = itemUid }; } } public void RemoveDynamicPresetSlot(string contextKey, int hotbarIndex, int slotIndex) { if (string.IsNullOrWhiteSpace(contextKey) || _activeCharacterSlotData?.DynamicPresets == null) { return; } string slotKey = GetSlotKey(hotbarIndex, slotIndex); if (_activeCharacterSlotData.DynamicPresets.TryGetValue(contextKey, out var value) && value != null) { value.Remove(slotKey); if (value.Count == 0) { _activeCharacterSlotData.DynamicPresets.Remove(contextKey); } } } private string GetCharacterSlotFilePath(string characterUID) { string text = characterUID.Replace("\\", "_").Replace("/", "_").Replace(":", "_"); return Path.Combine(ActionUISettings.CharacterHotbarsPath, text + ".json"); } private static string GetSlotKey(int hotbarIndex, int slotIndex) { return $"{hotbarIndex}_{slotIndex}"; } public static string GetBaselineContextKey() { return "baseline"; } public static string GetMainContextKey(int mainType) { return $"main:{mainType}"; } public static string GetOffContextKey(int offType) { return $"off:{offType}"; } public static string GetComboContextKey(int mainType, int offType) { return $"combo:{mainType}:{offType}"; } private static void MigrateLegacyDynamicPresetKeys(CharacterSlotData charData) { if (charData?.DynamicPresets == null || charData.DynamicPresets.Count == 0) { return; } Dictionary> dictionary = new Dictionary>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair> dynamicPreset in charData.DynamicPresets) { string text = NormalizeDynamicContextKey(dynamicPreset.Key); if (string.IsNullOrWhiteSpace(text)) { continue; } if (!dictionary.TryGetValue(text, out var value) || value == null) { value = (dictionary[text] = new Dictionary()); } if (dynamicPreset.Value == null) { continue; } foreach (KeyValuePair item in dynamicPreset.Value) { value[item.Key] = item.Value; } } charData.DynamicPresets = dictionary; } private static string NormalizeDynamicContextKey(string rawKey) { if (string.IsNullOrWhiteSpace(rawKey)) { return null; } string text = rawKey.Trim(); if (text.StartsWith("combo:", StringComparison.OrdinalIgnoreCase) || text.StartsWith("main:", StringComparison.OrdinalIgnoreCase) || text.StartsWith("off:", StringComparison.OrdinalIgnoreCase) || text.Equals("baseline", StringComparison.OrdinalIgnoreCase)) { return text.ToLowerInvariant(); } if (int.TryParse(text, out var result)) { if (result == -1) { return GetBaselineContextKey(); } return GetMainContextKey(result); } return text.ToLowerInvariant(); } } public class GlobalPositionsService : IPositionsProfileService { private PositionsProfile _cachedProfile; public event Action OnProfileChanged; public GlobalPositionsService() { LoadProfile(); } private void LoadProfile() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown string value = ActionUISettings.SerializedPositions.Value; if (string.IsNullOrEmpty(value)) { _cachedProfile = new PositionsProfile(); return; } try { _cachedProfile = JsonConvert.DeserializeObject(value); } catch { _cachedProfile = new PositionsProfile(); } } public PositionsProfile GetProfile() { if (_cachedProfile == null) { LoadProfile(); } return _cachedProfile; } public void Save() { SaveNew(GetProfile()); } public void SaveNew(PositionsProfile positionsProfile) { string text = JsonConvert.SerializeObject((object)positionsProfile, (Formatting)0); if (ActionUISettings.SerializedPositions.Value != text) { ActionUISettings.SerializedPositions.Value = text; } this.OnProfileChanged?.Invoke(positionsProfile); } public void AddOrUpdate(UIPositions position) { GetProfile().AddOrReplacePosition(position); Save(); } public void Remove(UIPositions position) { if (GetProfile().RemovePosition(position)) { Save(); } } } public class PlayerMenuService : IDisposable { public delegate void PlayerActionMenusConfigured(PlayerActionMenus actionMenus, SplitPlayer splitPlayer); [CompilerGenerated] private sealed class d__32 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PauseMenu pauseMenu; public PlayerMenuService <>4__this; private RectTransform 5__1; private Transform 5__2; private VerticalLayoutGroup 5__3; private Button[] 5__4; private float 5__5; private float 5__6; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__32(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: { <>1__state = -1; 5__1 = ((Component)((Component)pauseMenu).transform.Find("Buttons")).GetComponent(); Rect rect; if (<>4__this._initialPauseMenuHeight == 0f) { PlayerMenuService playerMenuService = <>4__this; rect = 5__1.rect; playerMenuService._initialPauseMenuHeight = ((Rect)(ref rect)).height; } 5__2 = ((Component)pauseMenu).transform.Find("Buttons/Content/HideOnPause"); 5__3 = ((Component)5__2).GetComponent(); 5__4 = ((Component)5__2).GetComponentsInChildren