using System.Collections.Generic; using UnityEngine; namespace Domain.Input { public abstract class InputReader { private readonly KeyHistory _history; private readonly List _desiredSequence; private readonly bool _useSpecial; private readonly int _specialKey; private readonly bool _mustContain; private bool _wasPressed; private bool _isPressed; public bool KeyDown() => _isPressed && !_wasPressed; protected InputReader(KeyHistory history, List desiredSequence) { _useSpecial = false; _history = history; _desiredSequence = desiredSequence; } protected InputReader(KeyHistory history, List desiredSequence, int specialKey, bool mustContain) { _useSpecial = true; _history = history; _desiredSequence = desiredSequence; _specialKey = specialKey; _mustContain = mustContain; } public void UpdateInput() { _wasPressed = _isPressed; if (_useSpecial) _isPressed = _history.ContainsSequence(_desiredSequence, _specialKey, _mustContain); else _isPressed = _history.ContainsSequence(_desiredSequence); } } }