perf: Check If Inputs Have Been Listened On
This commit is contained in:
parent
d60537f940
commit
44bee2df08
|
@ -59,17 +59,27 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IKeyboardInputs
|
||||||
for (int i = 0; i < cachePressedCurrentlyCount; i++)
|
for (int i = 0; i < cachePressedCurrentlyCount; i++)
|
||||||
{
|
{
|
||||||
Keys currentlyPressedKey = cachePressedCurrently[i];
|
Keys currentlyPressedKey = cachePressedCurrently[i];
|
||||||
if (!WasPressed(currentlyPressedKey))
|
|
||||||
if (OnPressed.TryGetValue(currentlyPressedKey, out var action))
|
if (!OnPressed.TryGetValue(currentlyPressedKey, out var action))
|
||||||
action.Invoke(this, currentlyPressedKey);
|
continue;
|
||||||
|
|
||||||
|
if (WasPressed(currentlyPressedKey))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
action.Invoke(this, currentlyPressedKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < cachePressedPreviouslyCount; i++)
|
for (int i = 0; i < cachePressedPreviouslyCount; i++)
|
||||||
{
|
{
|
||||||
Keys previouslyPressedKey = cachePressedPreviously[i];
|
Keys previouslyPressedKey = cachePressedPreviously[i];
|
||||||
if (!IsPressed(previouslyPressedKey))
|
|
||||||
if (OnReleased.TryGetValue(previouslyPressedKey, out var action))
|
if (!OnReleased.TryGetValue(previouslyPressedKey, out var action))
|
||||||
action.Invoke(this, previouslyPressedKey);
|
continue;
|
||||||
|
|
||||||
|
if (IsPressed(previouslyPressedKey))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
action.Invoke(this, previouslyPressedKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array.Copy(cachePressedCurrently, cachePressedPreviously, cachePressedCurrentlyCount);
|
Array.Copy(cachePressedCurrently, cachePressedPreviously, cachePressedCurrentlyCount);
|
||||||
|
|
Loading…
Reference in New Issue