Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of ExtraSkillSlots v1.6.4
plugins/ExtraSkillSlots/ExtraSkillSlots.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using EntityStates; using IL.EntityStates; using IL.RoR2; using IL.RoR2.UI; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour.HookGen; using On.EntityStates; using On.RoR2; using On.RoR2.UI; using Rewired; using Rewired.Data; using Rewired.Data.Mapping; using RoR2; using RoR2.UI; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.4.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ExtraSkillSlots { internal class ExtraBaseSkillState { private static readonly ConditionalWeakTable<BaseSkillState, ExtraBaseSkillState> instances = new ConditionalWeakTable<BaseSkillState, ExtraBaseSkillState>(); public ExtraSkillLocator ExtraSkillLocator { get; private set; } public ExtraInputBankTest ExtraInputBankTest { get; private set; } public static void IsKeyDownAuthorityILHook(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchNewobj<ArgumentOutOfRangeException>(x), (Instruction x) => ILPatternMatchingExt.MatchThrow(x) }); int index = val.Index; val.Index = index + 1; val.Previous.OpCode = OpCodes.Nop; val.Previous.Operand = null; val.Remove(); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Call, (MethodBase)typeof(ExtraBaseSkillState).GetMethod("IsKeyDown", BindingFlags.Static | BindingFlags.NonPublic)); val.Emit(OpCodes.Ret); } private static bool IsKeyDown(BaseSkillState skillState) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected I4, but got Unknown if (!instances.TryGetValue(skillState, out var value)) { ConditionalWeakTable<BaseSkillState, ExtraBaseSkillState> conditionalWeakTable = instances; ExtraBaseSkillState obj = new ExtraBaseSkillState { ExtraSkillLocator = ((Component)((EntityState)skillState).outer).GetComponent<ExtraSkillLocator>(), ExtraInputBankTest = ((Component)((EntityState)skillState).outer).GetComponent<ExtraInputBankTest>() }; value = obj; conditionalWeakTable.Add(skillState, obj); } ExtraSkillLocator extraSkillLocator = value.ExtraSkillLocator; ExtraInputBankTest extraInputBankTest = value.ExtraInputBankTest; if (!Object.op_Implicit((Object)(object)extraSkillLocator) || !Object.op_Implicit((Object)(object)extraInputBankTest)) { return false; } return (ExtraSkillSlot)(int)((EntityState)skillState).skillLocator.FindSkillSlot(skillState.activatorSkillSlot) switch { ExtraSkillSlot.ExtraFirst => extraInputBankTest.extraSkill1.down, ExtraSkillSlot.ExtraSecond => extraInputBankTest.extraSkill2.down, ExtraSkillSlot.ExtraThird => extraInputBankTest.extraSkill3.down, ExtraSkillSlot.ExtraFourth => extraInputBankTest.extraSkill4.down, _ => throw new ArgumentOutOfRangeException(), }; } } internal static class ExtraCharacterBody { internal static void RecalculateStatsILHook(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int cooldownScaleIndex = -1; int flatCooldownReductionIndex = -1; val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<SkillLocator>(x, "primary") }); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GenericSkill>(x, "set_cooldownScale") }); val.GotoPrev(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref cooldownScaleIndex) }); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GenericSkill>(x, "set_flatCooldownReduction") }); val.GotoPrev(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref flatCooldownReductionIndex) }); val.GotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) }); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldloc, cooldownScaleIndex); val.Emit(OpCodes.Ldloc, flatCooldownReductionIndex); val.Emit(OpCodes.Call, (MethodBase)typeof(ExtraCharacterBody).GetMethod("RecalculateCooldowns", BindingFlags.Static | BindingFlags.NonPublic)); } private static void RecalculateCooldowns(CharacterBody characterBody, float scale, float flatCooldownReduction) { ExtraSkillLocator component = ((Component)characterBody).GetComponent<ExtraSkillLocator>(); if (Object.op_Implicit((Object)(object)component)) { if (Object.op_Implicit((Object)(object)component.extraFirst)) { component.extraFirst.cooldownScale = scale; component.extraFirst.flatCooldownReduction = flatCooldownReduction; } if (Object.op_Implicit((Object)(object)component.extraSecond)) { component.extraSecond.cooldownScale = scale; component.extraSecond.flatCooldownReduction = flatCooldownReduction; } if (Object.op_Implicit((Object)(object)component.extraThird)) { component.extraThird.cooldownScale = scale; component.extraThird.flatCooldownReduction = flatCooldownReduction; } if (Object.op_Implicit((Object)(object)component.extraFourth)) { component.extraFourth.cooldownScale = scale; component.extraFourth.flatCooldownReduction = flatCooldownReduction; } } } } internal class ExtraGenericCharacterMain { private static readonly ConditionalWeakTable<GenericCharacterMain, ExtraGenericCharacterMain> instances = new ConditionalWeakTable<GenericCharacterMain, ExtraGenericCharacterMain>(); public bool extraSkill1InputReceived; public bool extraSkill2InputReceived; public bool extraSkill3InputReceived; public bool extraSkill4InputReceived; public ExtraSkillLocator ExtraSkillLocator { get; private set; } public ExtraInputBankTest ExtraInputBankTest { get; private set; } private ExtraGenericCharacterMain() { } internal static void PerformInputsOverrideHook(orig_PerformInputs orig, GenericCharacterMain self) { orig.Invoke(self); if (((EntityState)self).isAuthority) { if (!instances.TryGetValue(self, out var value)) { ConditionalWeakTable<GenericCharacterMain, ExtraGenericCharacterMain> conditionalWeakTable = instances; GenericCharacterMain key = self; ExtraGenericCharacterMain obj = new ExtraGenericCharacterMain { ExtraSkillLocator = ((Component)((EntityState)self).outer).GetComponent<ExtraSkillLocator>(), ExtraInputBankTest = ((Component)((EntityState)self).outer).GetComponent<ExtraInputBankTest>() }; value = obj; conditionalWeakTable.Add(key, obj); } ExtraSkillLocator extraSkillLocator = value.ExtraSkillLocator; ExtraInputBankTest extraInputBankTest = value.ExtraInputBankTest; if (Object.op_Implicit((Object)(object)extraSkillLocator) && Object.op_Implicit((Object)(object)extraInputBankTest) && value != null) { HandleSkill(extraSkillLocator.extraFirst, ref value.extraSkill1InputReceived, ((ButtonState)(ref extraInputBankTest.extraSkill1)).justPressed); HandleSkill(extraSkillLocator.extraSecond, ref value.extraSkill2InputReceived, ((ButtonState)(ref extraInputBankTest.extraSkill2)).justPressed); HandleSkill(extraSkillLocator.extraThird, ref value.extraSkill3InputReceived, ((ButtonState)(ref extraInputBankTest.extraSkill3)).justPressed); HandleSkill(extraSkillLocator.extraFourth, ref value.extraSkill4InputReceived, ((ButtonState)(ref extraInputBankTest.extraSkill4)).justPressed); } } void HandleSkill(GenericSkill skillSlot, ref bool inputReceived, bool justPressed) { bool flag = inputReceived; inputReceived = false; if (Object.op_Implicit((Object)(object)skillSlot) && (justPressed || (flag && !skillSlot.mustKeyPress)) && self.CanExecuteSkill(skillSlot)) { skillSlot.ExecuteIfReady(); } } } internal static void GatherInputsOverrideHook(orig_GatherInputs orig, GenericCharacterMain self) { orig.Invoke(self); if (!instances.TryGetValue(self, out var value)) { ConditionalWeakTable<GenericCharacterMain, ExtraGenericCharacterMain> conditionalWeakTable = instances; ExtraGenericCharacterMain obj = new ExtraGenericCharacterMain { ExtraSkillLocator = ((Component)((EntityState)self).outer).GetComponent<ExtraSkillLocator>(), ExtraInputBankTest = ((Component)((EntityState)self).outer).GetComponent<ExtraInputBankTest>() }; value = obj; conditionalWeakTable.Add(self, obj); } ExtraInputBankTest extraInputBankTest = value.ExtraInputBankTest; if (Object.op_Implicit((Object)(object)extraInputBankTest)) { value.extraSkill1InputReceived |= extraInputBankTest.extraSkill1.down; value.extraSkill2InputReceived |= extraInputBankTest.extraSkill2.down; value.extraSkill3InputReceived |= extraInputBankTest.extraSkill3.down; value.extraSkill4InputReceived |= extraInputBankTest.extraSkill4.down; } } } [RequireComponent(typeof(HUD))] internal class ExtraHud : MonoBehaviour { private HUD hud; public SkillIcon extraSkillIconFirst; public SkillIcon extraSkillIconSecond; public SkillIcon extraSkillIconThird; public SkillIcon extraSkillIconFourth; private void Awake() { hud = ((Component)this).GetComponent<HUD>(); SkillIcon[] skillIcons = hud.skillIcons; extraSkillIconFirst = CopyUISkillSlot(RewiredAction.FirstExtraSkill.Name, skillIcons[0]); extraSkillIconSecond = CopyUISkillSlot(RewiredAction.SecondExtraSkill.Name, skillIcons[1]); extraSkillIconThird = CopyUISkillSlot(RewiredAction.ThirdExtraSkill.Name, skillIcons[2]); extraSkillIconFourth = CopyUISkillSlot(RewiredAction.FourthExtraSkill.Name, skillIcons[3]); } internal static SkillIcon CopyUISkillSlot(string actionName, SkillIcon skillsContainer) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)skillsContainer).gameObject.transform; Transform obj = Object.Instantiate<Transform>(transform, transform.parent); RectTransform component = ((Component)obj).GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 2.5f); component.anchorMax = new Vector2(1f, 2.5f); ((Component)obj).GetComponentInChildren<InputBindingDisplayController>().actionName = actionName; return ((Component)obj).GetComponent<SkillIcon>(); } private void Update() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)hud.targetBodyObject)) { return; } ExtraSkillLocator component = hud.targetBodyObject.GetComponent<ExtraSkillLocator>(); if (Object.op_Implicit((Object)(object)component)) { PlayerCharacterMasterController playerCharacterMasterController = (Object.op_Implicit((Object)(object)hud.targetMaster) ? hud.targetMaster.playerCharacterMasterController : null); if (Object.op_Implicit((Object)(object)extraSkillIconFirst)) { ((Component)extraSkillIconFirst).gameObject.SetActive(ShouldShow(component.extraFirst)); extraSkillIconFirst.targetSkillSlot = (SkillSlot)11; extraSkillIconFirst.targetSkill = component.extraFirst; extraSkillIconFirst.playerCharacterMasterController = playerCharacterMasterController; } if (Object.op_Implicit((Object)(object)extraSkillIconSecond)) { ((Component)extraSkillIconSecond).gameObject.SetActive(ShouldShow(component.extraSecond)); extraSkillIconSecond.targetSkillSlot = (SkillSlot)12; extraSkillIconSecond.targetSkill = component.extraSecond; extraSkillIconSecond.playerCharacterMasterController = playerCharacterMasterController; } if (Object.op_Implicit((Object)(object)extraSkillIconThird)) { ((Component)extraSkillIconThird).gameObject.SetActive(ShouldShow(component.extraThird)); extraSkillIconThird.targetSkillSlot = (SkillSlot)13; extraSkillIconThird.targetSkill = component.extraThird; extraSkillIconThird.playerCharacterMasterController = playerCharacterMasterController; } if (Object.op_Implicit((Object)(object)extraSkillIconFourth)) { ((Component)extraSkillIconFourth).gameObject.SetActive(ShouldShow(component.extraFourth)); extraSkillIconFourth.targetSkillSlot = (SkillSlot)14; extraSkillIconFourth.targetSkill = component.extraFourth; extraSkillIconFourth.playerCharacterMasterController = playerCharacterMasterController; } } else { if (Object.op_Implicit((Object)(object)extraSkillIconFirst)) { ((Component)extraSkillIconFirst).gameObject.SetActive(false); } if (Object.op_Implicit((Object)(object)extraSkillIconSecond)) { ((Component)extraSkillIconSecond).gameObject.SetActive(false); } if (Object.op_Implicit((Object)(object)extraSkillIconThird)) { ((Component)extraSkillIconThird).gameObject.SetActive(false); } if (Object.op_Implicit((Object)(object)extraSkillIconFourth)) { ((Component)extraSkillIconFourth).gameObject.SetActive(false); } } } private bool ShouldShow(GenericSkill skill) { if (Object.op_Implicit((Object)(object)skill) && Object.op_Implicit((Object)(object)skill.skillDef)) { return !skill.skillDef.skillName.Equals("Disabled", StringComparison.InvariantCultureIgnoreCase); } return false; } } [RequireComponent(typeof(InputBankTest))] [DisallowMultipleComponent] public class ExtraInputBankTest : MonoBehaviour { public ButtonState extraSkill1; public ButtonState extraSkill2; public ButtonState extraSkill3; public ButtonState extraSkill4; internal static bool CheckAnyButtonDownOverrideHook(orig_CheckAnyButtonDown orig, InputBankTest self) { if (orig.Invoke(self)) { return true; } ExtraInputBankTest component = ((Component)self).GetComponent<ExtraInputBankTest>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } if (!component.extraSkill1.down && !component.extraSkill2.down && !component.extraSkill3.down) { return component.extraSkill4.down; } return true; } } internal static class ExtraInputs { internal static void AddActionsToInputCatalog() { //IL_000a: 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_0046: 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) InputCatalog.actionToToken[RewiredAction.FirstExtraSkill] = RewiredAction.FirstExtraSkill.DisplayToken; InputCatalog.actionToToken[RewiredAction.SecondExtraSkill] = RewiredAction.SecondExtraSkill.DisplayToken; InputCatalog.actionToToken[RewiredAction.ThirdExtraSkill] = RewiredAction.ThirdExtraSkill.DisplayToken; InputCatalog.actionToToken[RewiredAction.FourthExtraSkill] = RewiredAction.FourthExtraSkill.DisplayToken; } internal static void AddCustomActions(Action<UserData> orig, UserData self) { self.actions?.Add(RewiredAction.FirstExtraSkill); self.actions?.Add(RewiredAction.SecondExtraSkill); self.actions?.Add(RewiredAction.ThirdExtraSkill); self.actions?.Add(RewiredAction.FourthExtraSkill); FillActionMaps(RewiredAction.FirstExtraSkill, self.keyboardMaps, self.joystickMaps); FillActionMaps(RewiredAction.SecondExtraSkill, self.keyboardMaps, self.joystickMaps); FillActionMaps(RewiredAction.ThirdExtraSkill, self.keyboardMaps, self.joystickMaps); FillActionMaps(RewiredAction.FourthExtraSkill, self.keyboardMaps, self.joystickMaps); orig(self); } internal static void OnLoadUserProfiles(orig_LoadUserProfiles orig, SaveSystem self) { orig.Invoke(self); foreach (var (text2, val2) in self.loadedUserProfiles) { try { AddMissingBindings(val2); val2.RequestEventualSave(); } catch (Exception ex) { ExtraSkillSlotsPlugin.InstanceLogger.LogWarning((object)("Failed to add default bindings to '" + text2 + "' profile")); ExtraSkillSlotsPlugin.InstanceLogger.LogError((object)ex); } } } internal static void OnLoadDefaultProfile(orig_LoadDefaultProfile orig) { orig.Invoke(); try { AddMissingBindings(UserProfile.defaultProfile); } catch (Exception ex) { ExtraSkillSlotsPlugin.InstanceLogger.LogWarning((object)"Failed to add default bindings to default profile"); ExtraSkillSlotsPlugin.InstanceLogger.LogError((object)ex); } } internal static void OnFillDefaultJoystickMaps(orig_FillDefaultJoystickMaps orig, UserProfile self) { orig.Invoke(self); AddMissingBindings(self); } private static void AddMissingBindings(UserProfile userProfile) { AddActionMaps(RewiredAction.FirstExtraSkill, userProfile); AddActionMaps(RewiredAction.SecondExtraSkill, userProfile); AddActionMaps(RewiredAction.ThirdExtraSkill, userProfile); AddActionMaps(RewiredAction.FourthExtraSkill, userProfile); } private static void FillActionMaps(RewiredAction action, List<ControllerMap_Editor> keyboardMaps, List<ControllerMap_Editor> joystickMaps) { foreach (ControllerMap_Editor joystickMap in joystickMaps) { if (joystickMap.categoryId == 0 && joystickMap.actionElementMaps.All((ActionElementMap map) => map.actionId != action.ActionId)) { joystickMap.actionElementMaps.Add(action.DefaultJoystickMap); } } foreach (ControllerMap_Editor keyboardMap in keyboardMaps) { if (keyboardMap.categoryId == 0 && keyboardMap.actionElementMaps.All((ActionElementMap map) => map.actionId != action.ActionId)) { keyboardMap.actionElementMaps.Add(action.DefaultKeyboardMap); } } } private static void AddActionMaps(RewiredAction action, UserProfile userProfile) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) foreach (var (_, val2) in userProfile.HardwareJoystickMaps2) { if (((ControllerMap)val2).AllMaps.All((ActionElementMap map) => map.actionId != action.ActionId)) { ((ControllerMap)val2).CreateElementMap(action.DefaultJoystickMap.actionId, action.DefaultJoystickMap.axisContribution, action.DefaultJoystickMap.elementIdentifierId, action.DefaultJoystickMap.elementType, action.DefaultJoystickMap.axisRange, action.DefaultJoystickMap.invert); action.DefaultJoystickMap.cVYzDXVDMNXvRMrklCVdVyeXGAlK((ControllerMap)(object)val2); } } if (((ControllerMap)userProfile.keyboardMap).AllMaps.All((ActionElementMap map) => map.actionId != action.ActionId)) { ActionElementMap val3 = default(ActionElementMap); ((ControllerMap)userProfile.keyboardMap).CreateElementMap(action.DefaultKeyboardMap.actionId, action.DefaultKeyboardMap.axisContribution, action.DefaultKeyboardMap.elementIdentifierId, action.DefaultJoystickMap.elementType, action.DefaultJoystickMap.axisRange, action.DefaultJoystickMap.invert, ref val3); val3._keyboardKeyCode = action.DefaultKeyboardKey; action.DefaultKeyboardMap.cVYzDXVDMNXvRMrklCVdVyeXGAlK((ControllerMap)(object)userProfile.keyboardMap); } } } internal class ExtraPlayerCharacterMasterController : NetworkBehaviour { private PlayerCharacterMasterController playerCharacterMasterController; private ExtraInputBankTest extraInputBankTest; public void Awake() { playerCharacterMasterController = ((Component)this).GetComponent<PlayerCharacterMasterController>(); } public void FixedUpdate() { if (Object.op_Implicit((Object)(object)extraInputBankTest) && playerCharacterMasterController.hasEffectiveAuthority && Object.op_Implicit((Object)(object)extraInputBankTest)) { bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; LocalUser val = default(LocalUser); Player val2 = default(Player); CameraRigController val3 = default(CameraRigController); bool flag5 = default(bool); if (PlayerCharacterMasterController.CanSendBodyInput(playerCharacterMasterController.networkUser, ref val, ref val2, ref val3, ref flag5) && !flag5) { flag = val2.GetButton(RewiredAction.FirstExtraSkill.ActionId); flag2 = val2.GetButton(RewiredAction.SecondExtraSkill.ActionId); flag3 = val2.GetButton(RewiredAction.ThirdExtraSkill.ActionId); flag4 = val2.GetButton(RewiredAction.FourthExtraSkill.ActionId); } ((ButtonState)(ref extraInputBankTest.extraSkill1)).PushState(flag); ((ButtonState)(ref extraInputBankTest.extraSkill2)).PushState(flag2); ((ButtonState)(ref extraInputBankTest.extraSkill3)).PushState(flag3); ((ButtonState)(ref extraInputBankTest.extraSkill4)).PushState(flag4); } } internal static void SetBodyOverrideHook(orig_SetBody orig, PlayerCharacterMasterController self, GameObject newBody) { orig.Invoke(self, newBody); ExtraPlayerCharacterMasterController component = ((Component)self).GetComponent<ExtraPlayerCharacterMasterController>(); if (Object.op_Implicit((Object)(object)component)) { component.extraInputBankTest = (Object.op_Implicit((Object)(object)self.body) ? ((Component)self.body).GetComponent<ExtraInputBankTest>() : null); } } internal static void AwakeHook(orig_Awake orig, PlayerCharacterMasterController self) { orig.Invoke(self); ((Component)self).gameObject.AddComponent<ExtraPlayerCharacterMasterController>(); } } [RequireComponent(typeof(SkillLocator))] [DisallowMultipleComponent] public class ExtraSkillLocator : MonoBehaviour { public GenericSkill extraFirst; public GenericSkill extraSecond; public GenericSkill extraThird; public GenericSkill extraFourth; private void Awake() { if (!Object.op_Implicit((Object)(object)((Component)this).GetComponent<ExtraInputBankTest>())) { ((Component)this).gameObject.AddComponent<ExtraInputBankTest>(); } } internal static GenericSkill GetSkillOverrideHook(orig_GetSkill orig, SkillLocator self, SkillSlot skillSlot) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) ExtraSkillLocator component = ((Component)self).GetComponent<ExtraSkillLocator>(); if (!Object.op_Implicit((Object)(object)component)) { return orig.Invoke(self, skillSlot); } return (GenericSkill)((ExtraSkillSlot)(int)skillSlot switch { ExtraSkillSlot.ExtraFirst => component.extraFirst, ExtraSkillSlot.ExtraSecond => component.extraSecond, ExtraSkillSlot.ExtraThird => component.extraThird, ExtraSkillSlot.ExtraFourth => component.extraFourth, _ => orig.Invoke(self, skillSlot), }); } internal static SkillSlot FindSkillSlotOverrideHook(orig_FindSkillSlot orig, SkillLocator self, GenericSkill skillComponent) { //IL_0012: 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) ExtraSkillLocator component = ((Component)self).GetComponent<ExtraSkillLocator>(); if (!Object.op_Implicit((Object)(object)component)) { return orig.Invoke(self, skillComponent); } if (!Object.op_Implicit((Object)(object)skillComponent)) { return (SkillSlot)(-1); } if ((Object)(object)skillComponent == (Object)(object)component.extraFirst) { return (SkillSlot)11; } if ((Object)(object)skillComponent == (Object)(object)component.extraSecond) { return (SkillSlot)12; } if ((Object)(object)skillComponent == (Object)(object)component.extraThird) { return (SkillSlot)13; } if ((Object)(object)skillComponent == (Object)(object)component.extraFourth) { return (SkillSlot)14; } return orig.Invoke(self, skillComponent); } } internal enum ExtraSkillSlot { None = -1, Primary = 0, Secondary = 1, Utility = 2, Special = 3, ExtraFirst = 11, ExtraSecond = 12, ExtraThird = 13, ExtraFourth = 14 } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.KingEnderBrine.ExtraSkillSlots", "Extra Skill Slots", "1.6.4")] public class ExtraSkillSlotsPlugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Action<Action<UserData>, UserData> <0>__AddCustomActions; public static hook_LoadDefaultProfile <1>__OnLoadDefaultProfile; public static hook_LoadUserProfiles <2>__OnLoadUserProfiles; public static hook_FillDefaultJoystickMaps <3>__OnFillDefaultJoystickMaps; public static hook_Start <4>__SettingsPanelControllerStart; public static hook_Awake <5>__HUDAwake; public static hook_GetSkill <6>__GetSkillOverrideHook; public static hook_FindSkillSlot <7>__FindSkillSlotOverrideHook; public static hook_CheckAnyButtonDown <8>__CheckAnyButtonDownOverrideHook; public static hook_PerformInputs <9>__PerformInputsOverrideHook; public static hook_GatherInputs <10>__GatherInputsOverrideHook; public static Manipulator <11>__IsKeyDownAuthorityILHook; public static hook_Awake <12>__AwakeHook; public static hook_SetBody <13>__SetBodyOverrideHook; public static Manipulator <14>__RecalculateStatsILHook; public static Manipulator <15>__LoadoutPanelControllerFromSkillSlot; } public const string GUID = "com.KingEnderBrine.ExtraSkillSlots"; public const string Name = "Extra Skill Slots"; public const string Version = "1.6.4"; internal static ExtraSkillSlotsPlugin Instance { get; private set; } internal static ManualLogSource InstanceLogger { get { ExtraSkillSlotsPlugin instance = Instance; if (instance == null) { return null; } return ((BaseUnityPlugin)instance).Logger; } } private void Start() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0071: 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_007c: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_0131: 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_013c: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown Instance = this; ExtraInputs.AddActionsToInputCatalog(); HookEndpointManager.Add((MethodBase)typeof(UserData).GetMethod("gLOOAxUFAvrvUufkVjaYyZoeLbLE", BindingFlags.Instance | BindingFlags.NonPublic), (Delegate)new Action<Action<UserData>, UserData>(ExtraInputs.AddCustomActions)); object obj = <>O.<1>__OnLoadDefaultProfile; if (obj == null) { hook_LoadDefaultProfile val = ExtraInputs.OnLoadDefaultProfile; <>O.<1>__OnLoadDefaultProfile = val; obj = (object)val; } UserProfile.LoadDefaultProfile += (hook_LoadDefaultProfile)obj; object obj2 = <>O.<2>__OnLoadUserProfiles; if (obj2 == null) { hook_LoadUserProfiles val2 = ExtraInputs.OnLoadUserProfiles; <>O.<2>__OnLoadUserProfiles = val2; obj2 = (object)val2; } SaveSystem.LoadUserProfiles += (hook_LoadUserProfiles)obj2; object obj3 = <>O.<3>__OnFillDefaultJoystickMaps; if (obj3 == null) { hook_FillDefaultJoystickMaps val3 = ExtraInputs.OnFillDefaultJoystickMaps; <>O.<3>__OnFillDefaultJoystickMaps = val3; obj3 = (object)val3; } UserProfile.FillDefaultJoystickMaps += (hook_FillDefaultJoystickMaps)obj3; object obj4 = <>O.<4>__SettingsPanelControllerStart; if (obj4 == null) { hook_Start val4 = UIHooks.SettingsPanelControllerStart; <>O.<4>__SettingsPanelControllerStart = val4; obj4 = (object)val4; } SettingsPanelController.Start += (hook_Start)obj4; object obj5 = <>O.<5>__HUDAwake; if (obj5 == null) { hook_Awake val5 = UIHooks.HUDAwake; <>O.<5>__HUDAwake = val5; obj5 = (object)val5; } HUD.Awake += (hook_Awake)obj5; object obj6 = <>O.<6>__GetSkillOverrideHook; if (obj6 == null) { hook_GetSkill val6 = ExtraSkillLocator.GetSkillOverrideHook; <>O.<6>__GetSkillOverrideHook = val6; obj6 = (object)val6; } SkillLocator.GetSkill += (hook_GetSkill)obj6; object obj7 = <>O.<7>__FindSkillSlotOverrideHook; if (obj7 == null) { hook_FindSkillSlot val7 = ExtraSkillLocator.FindSkillSlotOverrideHook; <>O.<7>__FindSkillSlotOverrideHook = val7; obj7 = (object)val7; } SkillLocator.FindSkillSlot += (hook_FindSkillSlot)obj7; object obj8 = <>O.<8>__CheckAnyButtonDownOverrideHook; if (obj8 == null) { hook_CheckAnyButtonDown val8 = ExtraInputBankTest.CheckAnyButtonDownOverrideHook; <>O.<8>__CheckAnyButtonDownOverrideHook = val8; obj8 = (object)val8; } InputBankTest.CheckAnyButtonDown += (hook_CheckAnyButtonDown)obj8; object obj9 = <>O.<9>__PerformInputsOverrideHook; if (obj9 == null) { hook_PerformInputs val9 = ExtraGenericCharacterMain.PerformInputsOverrideHook; <>O.<9>__PerformInputsOverrideHook = val9; obj9 = (object)val9; } GenericCharacterMain.PerformInputs += (hook_PerformInputs)obj9; object obj10 = <>O.<10>__GatherInputsOverrideHook; if (obj10 == null) { hook_GatherInputs val10 = ExtraGenericCharacterMain.GatherInputsOverrideHook; <>O.<10>__GatherInputsOverrideHook = val10; obj10 = (object)val10; } GenericCharacterMain.GatherInputs += (hook_GatherInputs)obj10; object obj11 = <>O.<11>__IsKeyDownAuthorityILHook; if (obj11 == null) { Manipulator val11 = ExtraBaseSkillState.IsKeyDownAuthorityILHook; <>O.<11>__IsKeyDownAuthorityILHook = val11; obj11 = (object)val11; } SkillStateMethods.IsKeyDownAuthority += (Manipulator)obj11; object obj12 = <>O.<12>__AwakeHook; if (obj12 == null) { hook_Awake val12 = ExtraPlayerCharacterMasterController.AwakeHook; <>O.<12>__AwakeHook = val12; obj12 = (object)val12; } PlayerCharacterMasterController.Awake += (hook_Awake)obj12; object obj13 = <>O.<13>__SetBodyOverrideHook; if (obj13 == null) { hook_SetBody val13 = ExtraPlayerCharacterMasterController.SetBodyOverrideHook; <>O.<13>__SetBodyOverrideHook = val13; obj13 = (object)val13; } PlayerCharacterMasterController.SetBody += (hook_SetBody)obj13; object obj14 = <>O.<14>__RecalculateStatsILHook; if (obj14 == null) { Manipulator val14 = ExtraCharacterBody.RecalculateStatsILHook; <>O.<14>__RecalculateStatsILHook = val14; obj14 = (object)val14; } CharacterBody.RecalculateStats += (Manipulator)obj14; object obj15 = <>O.<15>__LoadoutPanelControllerFromSkillSlot; if (obj15 == null) { Manipulator val15 = UIHooks.LoadoutPanelControllerFromSkillSlot; <>O.<15>__LoadoutPanelControllerFromSkillSlot = val15; obj15 = (object)val15; } Row.FromSkillSlot += (Manipulator)obj15; Language.collectLanguageRootFolders += CollectLanguageRootFolders; NetworkModCompatibilityHelper.networkModList = NetworkModCompatibilityHelper.networkModList.Append("com.KingEnderBrine.ExtraSkillSlots;1.6.4"); } private void CollectLanguageRootFolders(List<string> folders) { folders.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Language")); } } public static class LanguageConsts { public static readonly string EXTRA_SKILL_SLOTS_FIRST_EXTRA_SKILL = "EXTRA_SKILL_SLOTS_FIRST_EXTRA_SKILL"; public static readonly string EXTRA_SKILL_SLOTS_SECOND_EXTRA_SKILL = "EXTRA_SKILL_SLOTS_SECOND_EXTRA_SKILL"; public static readonly string EXTRA_SKILL_SLOTS_THIRD_EXTRA_SKILL = "EXTRA_SKILL_SLOTS_THIRD_EXTRA_SKILL"; public static readonly string EXTRA_SKILL_SLOTS_FOURTH_EXTRA_SKILL = "EXTRA_SKILL_SLOTS_FOURTH_EXTRA_SKILL"; } public class RewiredAction { private InputAction inputAction; private ActionElementMap _defaultJoystickMap; private ActionElementMap _defaultKeyboardMap; public static RewiredAction FirstExtraSkill { get; } public static RewiredAction SecondExtraSkill { get; } public static RewiredAction ThirdExtraSkill { get; } public static RewiredAction FourthExtraSkill { get; } public int ActionId { get; private set; } public string Name { get; private set; } public string DisplayToken { get; private set; } public KeyboardKeyCode DefaultKeyboardKey { get; private set; } public int DefaultJoystickKey { get; private set; } public ActionElementMap DefaultJoystickMap { get { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown ActionElementMap obj = _defaultJoystickMap; if (obj == null) { ActionElementMap val = new ActionElementMap(ActionId, (ControllerElementType)1, DefaultJoystickKey, (Pole)0, (AxisRange)1); ActionElementMap val2 = val; _defaultJoystickMap = val; obj = val2; } return obj; } } public ActionElementMap DefaultKeyboardMap { get { //IL_0013: 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_0020: Expected I4, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0033: Expected O, but got Unknown ActionElementMap obj = _defaultKeyboardMap; if (obj == null) { ActionElementMap val = new ActionElementMap(ActionId, (ControllerElementType)1, DefaultKeyboardKey - 21) { _keyboardKeyCode = DefaultKeyboardKey }; ActionElementMap val2 = val; _defaultKeyboardMap = val; obj = val2; } return obj; } } static RewiredAction() { FirstExtraSkill = new RewiredAction { ActionId = 100, Name = "FirstExtraSkill", DisplayToken = LanguageConsts.EXTRA_SKILL_SLOTS_FIRST_EXTRA_SKILL, DefaultKeyboardKey = (KeyboardKeyCode)49, DefaultJoystickKey = 16 }; SecondExtraSkill = new RewiredAction { ActionId = 101, Name = "SecondExtraSkill", DisplayToken = LanguageConsts.EXTRA_SKILL_SLOTS_SECOND_EXTRA_SKILL, DefaultKeyboardKey = (KeyboardKeyCode)50, DefaultJoystickKey = 17 }; ThirdExtraSkill = new RewiredAction { ActionId = 102, Name = "ThirdExtraSkill", DisplayToken = LanguageConsts.EXTRA_SKILL_SLOTS_THIRD_EXTRA_SKILL, DefaultKeyboardKey = (KeyboardKeyCode)51, DefaultJoystickKey = 18 }; FourthExtraSkill = new RewiredAction { ActionId = 103, Name = "FourthExtraSkill", DisplayToken = LanguageConsts.EXTRA_SKILL_SLOTS_FOURTH_EXTRA_SKILL, DefaultKeyboardKey = (KeyboardKeyCode)52, DefaultJoystickKey = 19 }; } public static implicit operator ActionAxisPair(RewiredAction action) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return new ActionAxisPair(action.Name, (AxisRange)0); } public static implicit operator InputAction(RewiredAction action) { //IL_000d: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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: Expected O, but got Unknown //IL_0059: Expected O, but got Unknown InputAction obj = action.inputAction; if (obj == null) { InputAction val = new InputAction(); val.QurFqcdYtHIEpCpYBddZfQQtnImHA(action.ActionId); val.LEWtVuPGPZtPpCUSAMYCEbPqyAuf(action.Name); val.nLGCfekdjaMIxCLlcjdYgcEjEDxz((InputActionType)1); val.nfWwbfSEwQCdVSicPaIBIPkMqJfu(action.Name); val.MFwTFVDRoziRWNJMARlSUXIebtLw(0); val.BSFQAxJApIZsVFnOmINQEGShHPvFb(true); val.REsRGcKFtjbUwlqUSreCTUubayPb(0); InputAction val2 = val; action.inputAction = val; obj = val2; } return obj; } } internal static class UIHooks { internal static void HUDAwake(orig_Awake orig, HUD self) { orig.Invoke(self); ((Component)self).gameObject.AddComponent<ExtraHud>(); } internal static void SettingsPanelControllerStart(orig_Start orig, SettingsPanelController self) { orig.Invoke(self); if (((Object)self).name == "SettingsSubPanel, Controls (M&KB)" || ((Object)self).name == "SettingsSubPanel, Controls (Gamepad)") { Transform buttonToCopy = ((Component)self).transform.Find("Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Binding (Jump)"); AddActionBindingToSettings(RewiredAction.FirstExtraSkill.Name, buttonToCopy); AddActionBindingToSettings(RewiredAction.SecondExtraSkill.Name, buttonToCopy); AddActionBindingToSettings(RewiredAction.ThirdExtraSkill.Name, buttonToCopy); AddActionBindingToSettings(RewiredAction.FourthExtraSkill.Name, buttonToCopy); } } internal static void AddActionBindingToSettings(string actionName, Transform buttonToCopy) { InputBindingControl component = ((Component)Object.Instantiate<Transform>(buttonToCopy, buttonToCopy.parent)).GetComponent<InputBindingControl>(); component.actionName = actionName; component.Awake(); } internal static void LoadoutPanelControllerFromSkillSlot(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int skillSlotIndex = -1; int titleTokenIndex = -1; int addWIPIconsIndex = -1; val.GotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<SkillLocator>(x, "FindSkillSlot"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref skillSlotIndex) }); string text = default(string); val.GotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, ref text), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref titleTokenIndex) }); int num = default(int); val.GotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref addWIPIconsIndex) }); val.GotoNext(new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchNewobj<ArgumentOutOfRangeException>(x), (Instruction x) => ILPatternMatchingExt.MatchThrow(x) }); val.Index += 1; val.Remove(); val.Previous.OpCode = OpCodes.Nop; val.Previous.Operand = null; val.Emit(OpCodes.Ldloc, skillSlotIndex); val.Emit(OpCodes.Call, (MethodBase)typeof(UIHooks).GetMethod("GetSkillSlotName", BindingFlags.Static | BindingFlags.NonPublic)); val.Emit(OpCodes.Stloc, titleTokenIndex); val.Emit(OpCodes.Ldc_I4_0); val.Emit(OpCodes.Stloc, addWIPIconsIndex); } private static string GetSkillSlotName(SkillSlot skillSlot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Expected I4, but got Unknown return (ExtraSkillSlot)(int)skillSlot switch { ExtraSkillSlot.ExtraFirst => LanguageConsts.EXTRA_SKILL_SLOTS_FIRST_EXTRA_SKILL, ExtraSkillSlot.ExtraSecond => LanguageConsts.EXTRA_SKILL_SLOTS_SECOND_EXTRA_SKILL, ExtraSkillSlot.ExtraThird => LanguageConsts.EXTRA_SKILL_SLOTS_THIRD_EXTRA_SKILL, ExtraSkillSlot.ExtraFourth => LanguageConsts.EXTRA_SKILL_SLOTS_FOURTH_EXTRA_SKILL, _ => throw new ArgumentOutOfRangeException(), }; } } }