jotunn 2.30 compatibility + minor bugs
This commit is contained in:
parent
6193b3ee2d
commit
ce671e7124
14 changed files with 107 additions and 49 deletions
|
|
@ -99,6 +99,49 @@ namespace RacesOfValheim
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Gamepad counterparts of the three mouse buttons, indexed like Input.GetMouseButton.
|
||||
// Not a free choice: ZInput.ResetKBMButtons binds Attack to Mouse0, Block to Mouse1 and
|
||||
// SecondaryAttack to Mouse2, so each form attack lands on the pad button vanilla already
|
||||
// pairs with the same mouse button - and does whatever that button does in vanilla at the
|
||||
// same time, exactly as the mouse already did. Going through ZInput rather than raw
|
||||
// joystick buttons also follows the pad layout picked in the game settings.
|
||||
private static readonly string[] PadAttackButtons = { "JoyAttack", "JoyBlock", "JoySecondaryAttack" };
|
||||
|
||||
/// <summary>
|
||||
/// Transformed-form attack input: the mouse button, or its gamepad counterpart. Forms read
|
||||
/// the device directly instead of going through Humanoid.StartAttack, so before this a
|
||||
/// gamepad player had no way to attack in any of them.
|
||||
/// </summary>
|
||||
public static bool AttackDown(int mouseButton)
|
||||
{
|
||||
return Input.GetMouseButtonDown(mouseButton) || PadAttackDown(mouseButton);
|
||||
}
|
||||
|
||||
/// <summary>Held-down counterpart of <see cref="AttackDown"/>.</summary>
|
||||
public static bool AttackHeld(int mouseButton)
|
||||
{
|
||||
return Input.GetMouseButton(mouseButton) || PadAttackHeld(mouseButton);
|
||||
}
|
||||
|
||||
/// <summary>The gamepad half of <see cref="AttackDown"/> alone, for attacks whose mouse
|
||||
/// side is a rebindable KeyboardShortcut rather than a fixed button.</summary>
|
||||
public static bool PadAttackDown(int mouseButton)
|
||||
{
|
||||
string button = PadButton(mouseButton);
|
||||
return button != null && ZInput.GetButtonDown(button);
|
||||
}
|
||||
|
||||
public static bool PadAttackHeld(int mouseButton)
|
||||
{
|
||||
string button = PadButton(mouseButton);
|
||||
return button != null && ZInput.GetButton(button);
|
||||
}
|
||||
|
||||
private static string PadButton(int mouseButton)
|
||||
{
|
||||
return mouseButton >= 0 && mouseButton < PadAttackButtons.Length ? PadAttackButtons[mouseButton] : null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "ActivateGuardianPower")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue