diff --git a/Game/Behaviours/KeyboardInputsBehaviour.cs b/Game/Behaviours/KeyboardInputsBehaviour.cs index 86d9351..19ac30d 100644 --- a/Game/Behaviours/KeyboardInputsBehaviour.cs +++ b/Game/Behaviours/KeyboardInputsBehaviour.cs @@ -9,8 +9,8 @@ namespace Pong.Behaviours; public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs { - private readonly Dictionary, Keys>> OnPressed = new(256); - private readonly Dictionary, Keys>> OnReleased = new(256); + private readonly Dictionary, Keys>?> OnPressed = new(256); + private readonly Dictionary, Keys>?> OnReleased = new(256); private int cachePressedCurrentlyCount = 0; private readonly Keys[] cachePressedCurrently = new Keys[256]; @@ -68,7 +68,7 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs if (WasPressed(currentlyPressedKey)) continue; - action.Invoke(this, currentlyPressedKey); + action?.Invoke(this, currentlyPressedKey); } for (int i = 0; i < cachePressedPreviouslyCount; i++) @@ -81,7 +81,7 @@ public class KeyboardInputsBehaviour : BehaviourOverride, IButtonInputs if (IsPressed(previouslyPressedKey)) continue; - action.Invoke(this, previouslyPressedKey); + action?.Invoke(this, previouslyPressedKey); } Array.Copy(cachePressedCurrently, cachePressedPreviously, cachePressedCurrentlyCount);