diff --git a/OpenDreamRuntime/Input/DreamCommandSystem.cs b/OpenDreamRuntime/Input/DreamCommandSystem.cs index e37207a98d..cd87e8ee0f 100644 --- a/OpenDreamRuntime/Input/DreamCommandSystem.cs +++ b/OpenDreamRuntime/Input/DreamCommandSystem.cs @@ -1,43 +1,43 @@ using OpenDreamShared.Input; using Robust.Server.Player; -namespace OpenDreamRuntime.Input { - sealed class DreamCommandSystem : SharedDreamCommandSystem { - [Dependency] private readonly DreamManager _dreamManager = default!; +namespace OpenDreamRuntime.Input; - private readonly List<(string Command, IPlayerSession session)> _repeatingCommands = new(); +internal sealed class DreamCommandSystem : SharedDreamCommandSystem { + [Dependency] private readonly DreamManager _dreamManager = default!; - public override void Initialize() { - SubscribeNetworkEvent(OnCommandEvent); - SubscribeNetworkEvent(OnRepeatCommandEvent); - SubscribeNetworkEvent(OnStopRepeatCommandEvent); - } + private readonly HashSet<(string Command, IPlayerSession session)> _repeatingCommands = new(); - public void RunRepeatingCommands() { - foreach (var (command, session) in _repeatingCommands) { - RunCommand(command, session); - } - } + public override void Initialize() { + SubscribeNetworkEvent(OnCommandEvent); + SubscribeNetworkEvent(OnRepeatCommandEvent); + SubscribeNetworkEvent(OnStopRepeatCommandEvent); + } - private void OnCommandEvent(CommandEvent e, EntitySessionEventArgs sessionEvent) { - RunCommand(e.Command, (IPlayerSession)sessionEvent.SenderSession); + public void RunRepeatingCommands() { + foreach (var (command, session) in _repeatingCommands) { + RunCommand(command, session); } + } - private void OnRepeatCommandEvent(RepeatCommandEvent e, EntitySessionEventArgs sessionEvent) { - var tuple = (e.Command, (IPlayerSession)sessionEvent.SenderSession); + private void OnCommandEvent(CommandEvent e, EntitySessionEventArgs sessionEvent) { + RunCommand(e.Command, (IPlayerSession)sessionEvent.SenderSession); + } - _repeatingCommands.Add(tuple); - } + private void OnRepeatCommandEvent(RepeatCommandEvent e, EntitySessionEventArgs sessionEvent) { + var tuple = (e.Command, (IPlayerSession)sessionEvent.SenderSession); - private void OnStopRepeatCommandEvent(StopRepeatCommandEvent e, EntitySessionEventArgs sessionEvent) { - var tuple = (e.Command, (IPlayerSession)sessionEvent.SenderSession); + _repeatingCommands.Add(tuple); + } - _repeatingCommands.Remove(tuple); - } + private void OnStopRepeatCommandEvent(StopRepeatCommandEvent e, EntitySessionEventArgs sessionEvent) { + var tuple = (e.Command, (IPlayerSession)sessionEvent.SenderSession); - private void RunCommand(string command, IPlayerSession session) { - var connection = _dreamManager.GetConnectionBySession(session); - connection.HandleCommand(command); - } + _repeatingCommands.Remove(tuple); + } + + private void RunCommand(string command, IPlayerSession session) { + var connection = _dreamManager.GetConnectionBySession(session); + connection.HandleCommand(command); } }