Files
tbd-station-14/Content.Client/Flash/FlashSystem.cs
slarticodefast eb4ce85354 Remove imagesharp and StatusEffectAddedEvent from FlashOverlay (#28930)
remove imagesharp and StatusEffectAddedEvent from FlashOverlay
2024-07-13 16:10:04 +10:00

60 lines
1.8 KiB
C#

using Content.Shared.Flash;
using Content.Shared.Flash.Components;
using Content.Shared.StatusEffect;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;
namespace Content.Client.Flash;
public sealed class FlashSystem : SharedFlashSystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;
private FlashOverlay _overlay = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FlashedComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<FlashedComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<FlashedComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<FlashedComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
_overlay = new();
}
private void OnPlayerAttached(EntityUid uid, FlashedComponent component, LocalPlayerAttachedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}
private void OnPlayerDetached(EntityUid uid, FlashedComponent component, LocalPlayerDetachedEvent args)
{
_overlay.ScreenshotTexture = null;
_overlay.RequestScreenTexture = false;
_overlayMan.RemoveOverlay(_overlay);
}
private void OnInit(EntityUid uid, FlashedComponent component, ComponentInit args)
{
if (_player.LocalEntity == uid)
{
_overlay.RequestScreenTexture = true;
_overlayMan.AddOverlay(_overlay);
}
}
private void OnShutdown(EntityUid uid, FlashedComponent component, ComponentShutdown args)
{
if (_player.LocalEntity == uid)
{
_overlay.ScreenshotTexture = null;
_overlay.RequestScreenTexture = false;
_overlayMan.RemoveOverlay(_overlay);
}
}
}