Ignore race ability input while a GUI has focus
UnityEngine.Input reads the device directly, so abilities bound to keys or mouse buttons kept firing with the map, the inventory, a chest, the chat or a menu open - clicking an item in a container also swung the transformed attack. Route that input through Player.TakeInput, which is what Valheim runs its own controls through and already reports false for those states (InventoryGui covers the backpack and chests alike). Aswid's transform keys were the only place already doing this; the shared helper replaces that one-off and covers Skadi's cold spell, form keys, flight toggle, form attacks and flight boost, Fenrir's form keys and the attacks of all four form behaviors, Trol's rock throw and true form, and Aswid's devour toggle. Cultist fire is a held button, so it is gated per read rather than around the block: opening a GUI mid-stream now falls through to StopFire() instead of leaving the flames running.
This commit is contained in:
parent
16275d6abc
commit
bca47beda6
9 changed files with 67 additions and 20 deletions
|
|
@ -67,7 +67,7 @@ namespace RacesOfValheim
|
|||
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
|
||||
|
||||
// Handle Flight Toggle (RMB) - Disabled for Fader
|
||||
if (Input.GetMouseButtonDown(1) && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
|
||||
if (RaceInput.Allowed && Input.GetMouseButtonDown(1) && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
|
||||
{
|
||||
if (!isFlying && !isLanding)
|
||||
{
|
||||
|
|
@ -122,7 +122,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
// Handle Attack
|
||||
if (CanAttackNow())
|
||||
if (CanAttackNow() && RaceInput.Allowed)
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ namespace RacesOfValheim
|
|||
|
||||
var traverse = Traverse.Create(__instance);
|
||||
Vector3 lookDir = Player.m_localPlayer.GetLookDir();
|
||||
bool boost = Input.GetKey(KeyCode.W);
|
||||
bool boost = RaceInput.Allowed && Input.GetKey(KeyCode.W);
|
||||
bool onGround = __instance.IsOnGround();
|
||||
|
||||
traverse.Field("m_run").SetValue(boost);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
if (rules.ColdSpell)
|
||||
if (rules.ColdSpell && RaceInput.Allowed)
|
||||
{
|
||||
HandleColdSpell(rules);
|
||||
}
|
||||
|
|
@ -167,6 +167,9 @@ namespace RacesOfValheim
|
|||
return;
|
||||
}
|
||||
|
||||
// Form keys and the debug dump are ability input: they stay inert while a GUI has focus.
|
||||
if (!RaceInput.Allowed) return;
|
||||
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(SkadiProgression.GetGKeyRules(state)); return; }
|
||||
if (Input.GetKeyDown(KeyCode.H)) { TryTransformWithRules(SkadiProgression.GetHKeyRules(state)); return; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue