using System.Collections.Generic;
namespace Robust.Shared.Input
{
///
/// Contains a mapping of to their current .
///
public interface IPlayerCommandStates
{
///
/// Indexer access to the Get/Set functions.
///
BoundKeyState this[BoundKeyFunction function] { get; set; }
///
/// Gets the current state of a function.
///
/// Function to get the state of.
/// Current state of the function.
BoundKeyState GetState(BoundKeyFunction function);
///
/// Sets the current state of a function.
///
/// Function to change.
/// State value to set.
void SetState(BoundKeyFunction function, BoundKeyState state);
}
///
public sealed class PlayerCommandStates : IPlayerCommandStates
{
private readonly Dictionary _functionStates = new();
///
public BoundKeyState this[BoundKeyFunction function]
{
get => GetState(function);
set => SetState(function, value);
}
///
public BoundKeyState GetState(BoundKeyFunction function)
{
return _functionStates.TryGetValue(function, out var state) ? state : BoundKeyState.Up;
}
///
public void SetState(BoundKeyFunction function, BoundKeyState state)
{
_functionStates[function] = state;
}
}
}