refactor: made the input reader expandable
This commit is contained in:
parent
12304c6bb4
commit
59a3d96b5b
10 changed files with 72 additions and 24 deletions
23
Assets/Scripts/Domain/CustomInput.cs
Normal file
23
Assets/Scripts/Domain/CustomInput.cs
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue