CatStation/Content.Client/GhostKick/GhostKickManager.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

40 lines
1 KiB
C#

using Content.Shared.GhostKick;
using Robust.Client;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
namespace Content.Client.GhostKick;
public sealed partial class GhostKickManager
{
private bool _fakeLossEnabled;
[Dependency] private IBaseClient _baseClient = default!;
[Dependency] private IClientNetManager _netManager = default!;
[Dependency] private 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);
}
}