refactor: made the input reader expandable

This commit is contained in:
Gerard Gascón 2024-04-14 18:50:25 +02:00
parent 12304c6bb4
commit 59a3d96b5b
10 changed files with 72 additions and 24 deletions

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using Domain.Input;
namespace Domain {
public class CustomInput {
private readonly Dictionary<Type, InputReader> _readers = new();
public CustomInput() {
_readers.Add(typeof(CedillaReader), new CedillaReader());
}
public void UpdateInput() {
foreach (KeyValuePair<Type, InputReader> reader in _readers) {
reader.Value.UpdateInput();
}
}
public bool KeyDown(Type key) => _readers[key].KeyDown();
public bool KeyPressed(Type key) => _readers[key].KeyPressed();
public bool KeyUp(Type key) => _readers[key].KeyUp();
}
}