2023-09-25 01:44:44 +03:00
|
|
|
|
using Content.Shared.GameTicking;
|
2024-01-28 18:37:24 +07:00
|
|
|
|
using Content.Shared._White.Overlays;
|
2023-09-25 01:44:44 +03:00
|
|
|
|
using Robust.Client.Graphics;
|
|
|
|
|
|
using Robust.Client.Player;
|
|
|
|
|
|
using Robust.Shared.Player;
|
|
|
|
|
|
|
2024-01-28 17:32:55 +07:00
|
|
|
|
namespace Content.Client._White.Overlays;
|
2023-09-25 01:44:44 +03:00
|
|
|
|
|
|
|
|
|
|
public sealed class SaturationScaleSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
|
|
|
|
|
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
|
|
|
|
|
[Dependency] private readonly ILightManager _lightManager = default!;
|
|
|
|
|
|
|
|
|
|
|
|
private SaturationScaleOverlay _overlay = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<SaturationScaleComponent, ComponentInit>(OnInit);
|
|
|
|
|
|
SubscribeLocalEvent<SaturationScaleComponent, ComponentShutdown>(OnShutdown);
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<SaturationScaleComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
|
|
|
|
|
SubscribeLocalEvent<SaturationScaleComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);
|
|
|
|
|
|
|
|
|
|
|
|
_overlay = new();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RoundRestartCleanup(RoundRestartCleanupEvent ev)
|
|
|
|
|
|
{
|
|
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPlayerDetached(EntityUid uid, SaturationScaleComponent component, PlayerDetachedEvent args)
|
|
|
|
|
|
{
|
2024-01-28 11:06:48 +03:00
|
|
|
|
if (_player.LocalSession != args.Player)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2023-09-25 01:44:44 +03:00
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPlayerAttached(EntityUid uid, SaturationScaleComponent component, PlayerAttachedEvent args)
|
|
|
|
|
|
{
|
2024-01-28 11:06:48 +03:00
|
|
|
|
if (_player.LocalSession != args.Player)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2023-09-25 01:44:44 +03:00
|
|
|
|
_overlayMan.AddOverlay(_overlay);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnShutdown(EntityUid uid, SaturationScaleComponent component, ComponentShutdown args)
|
|
|
|
|
|
{
|
2024-01-28 11:06:48 +03:00
|
|
|
|
if (_player.LocalSession?.AttachedEntity != uid)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
2023-09-25 01:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnInit(EntityUid uid, SaturationScaleComponent component, ComponentInit args)
|
|
|
|
|
|
{
|
2024-01-28 11:06:48 +03:00
|
|
|
|
if (_player.LocalSession?.AttachedEntity != uid)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
_overlayMan.AddOverlay(_overlay);
|
2023-09-25 01:44:44 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|