Kick mines (real) (#8056)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Pieter-Jan Briers
2022-05-18 06:07:35 +02:00
committed by GitHub
parent 2f604ce05c
commit ebfe5e888f
29 changed files with 635 additions and 220 deletions

View File

@@ -0,0 +1,40 @@
using Content.Shared.GhostKick;
using Robust.Client;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
namespace Content.Client.GhostKick;
public sealed class GhostKickManager
{
private bool _fakeLossEnabled;
[Dependency] private readonly IBaseClient _baseClient = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
public void Initialize()
{
_netManager.RegisterNetMessage<MsgGhostKick>(RxCallback);
_baseClient.RunLevelChanged += BaseClientOnRunLevelChanged;
}
private void BaseClientOnRunLevelChanged(object? sender, RunLevelChangedEventArgs e)
{
if (_fakeLossEnabled && e.OldLevel == ClientRunLevel.InGame)
{
_cfg.SetCVar(CVars.NetFakeLoss, 0);
_fakeLossEnabled = false;
}
}
private void RxCallback(MsgGhostKick message)
{
_fakeLossEnabled = true;
_cfg.SetCVar(CVars.NetFakeLoss, 1);
}
}