mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-06-09 10:06:49 +02:00
54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using Content.Shared.Genetics;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Client.Genetics.System;
|
|
|
|
public sealed partial class DizzySystem : EntitySystem
|
|
{
|
|
[Dependency] private IPlayerManager _player = default!;
|
|
[Dependency] private IOverlayManager _overlayMan = default!;
|
|
|
|
private DizzyOverlay _overlay = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DizzyEffectComponent, ComponentInit>(OnInit);
|
|
SubscribeLocalEvent<DizzyEffectComponent, ComponentShutdown>(OnShutdown);
|
|
|
|
SubscribeLocalEvent<DizzyEffectComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
|
|
SubscribeLocalEvent<DizzyEffectComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
_overlay = new();
|
|
}
|
|
|
|
private void OnPlayerAttached(EntityUid uid, DizzyEffectComponent component, LocalPlayerAttachedEvent args)
|
|
{
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void OnPlayerDetached(EntityUid uid, DizzyEffectComponent component, LocalPlayerDetachedEvent args)
|
|
{
|
|
_overlay.CurrentIntensity = 0;
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnInit(EntityUid uid, DizzyEffectComponent component, ComponentInit args)
|
|
{
|
|
if (_player.LocalEntity == uid)
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void OnShutdown(EntityUid uid, DizzyEffectComponent component, ComponentShutdown args)
|
|
{
|
|
if (_player.LocalEntity == uid)
|
|
{
|
|
_overlay.CurrentIntensity = 0;
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
}
|
|
}
|