protected override void OnSubModuleLoad() { base.OnSubModuleLoad(); var category = HotKeyManager.GetCategory("CombatHotKeyCategory") as CombatHotKeyCategory; var method = category.GetType().BaseType.GetMethod("RegisterGameKey", BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.NonPublic); var list = category.PrivateValue <List <GameKey> >("_registeredGameKeys", typeof(GameKeyContext)); list.AddRange(Enumerable.Repeat <GameKey>(null, 64)); var nameText = Module.CurrentModule.GlobalTextManager.GetGameText("str_key_name"); var descriptionText = Module.CurrentModule.GlobalTextManager.GetGameText("str_key_description"); foreach (var key in DirectionalAttackKeys.AllKeys) { nameText.AddVariationWithId(nameof(CombatHotKeyCategory) + "_" + (int)key, new TextObject(DirectionalAttackKeys.NameFor(key)), new List <GameTextManager.ChoiceTag>()); descriptionText.AddVariationWithId(nameof(CombatHotKeyCategory) + "_" + (int)key, new TextObject(DirectionalAttackKeys.NameFor(key)), new List <GameTextManager.ChoiceTag>()); method.Invoke(category, new object[] { new GameKey( (int)key, DirectionalAttackKeys.NameFor(key), "CombatHotKeyCategory", InputKey.Numpad8 + ((int)key - (int)DirectionalAttackKeys.Key.AttackUp), InputKey.Invalid, GameKeyMainCategories.ActionCategory ), true }); } new Harmony("net.shdw.BannerlordPlayerControlsMod").PatchAll(); HotKeyManager.Load(); }
public static void Postfix(MissionMainAgentController __instance) { var agent = __instance.Mission.MainAgent; foreach (var key in DirectionalAttackKeys.AllKeys) { if (__instance.Input.IsGameKeyDown((int)key)) { agent.MovementFlags |= agent.AttackDirectionToMovementFlag(DirectionalAttackKeys.UsageDirectionFrom(key)); } } }