Fix griddrag and tethergun (#10510)

This commit is contained in:
metalgearsloth
2022-09-01 13:11:45 +10:00
committed by GitHub
parent a44c5a447e
commit a0f2e7ac92
9 changed files with 126 additions and 18 deletions

View File

@@ -1,6 +1,8 @@
using Content.Shared.Maps;
using Robust.Server.Console;
using Robust.Server.Player;
using Robust.Shared.Players;
using Robust.Shared.Utility;
namespace Content.Server.Maps;
@@ -9,6 +11,8 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
{
[Dependency] private readonly IConGroupController _admin = default!;
private readonly HashSet<ICommonSession> _draggers = new();
public override void Initialize()
{
base.Initialize();
@@ -16,6 +20,31 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
SubscribeNetworkEvent<GridDragVelocityRequest>(OnRequestVelocity);
}
public bool IsEnabled(ICommonSession session) => _draggers.Contains(session);
public void Toggle(ICommonSession session)
{
if (session is not IPlayerSession pSession)
return;
DebugTools.Assert(_admin.CanCommand(pSession, CommandName));
// Weird but it's a toggle
if (_draggers.Add(session))
{
}
else
{
_draggers.Remove(session);
}
RaiseNetworkEvent(new GridDragToggleMessage()
{
Enabled = _draggers.Contains(session),
}, session.ConnectedClient);
}
private void OnRequestVelocity(GridDragVelocityRequest ev, EntitySessionEventArgs args)
{
if (args.SenderSession is not IPlayerSession playerSession ||