* add haloperidol, potassium iodide * review fixes * review and tuning * add: translation * new mutations * translation string fix * holymelons are holy now * add: translation * rename holymelon * Tomato killers don't kill the server anymore. (#28173) * tomato killer auto death * fix * Update miscellaneous.yml --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using Content.Shared.Drowsiness;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Client.Drowsiness;
|
|
|
|
public sealed class DrowsinessSystem : SharedDrowsinessSystem
|
|
{
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
|
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
|
|
|
private DrowsinessOverlay _overlay = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DrowsinessComponent, ComponentInit>(OnDrowsinessInit);
|
|
SubscribeLocalEvent<DrowsinessComponent, ComponentShutdown>(OnDrowsinessShutdown);
|
|
|
|
SubscribeLocalEvent<DrowsinessComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
|
|
SubscribeLocalEvent<DrowsinessComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
_overlay = new();
|
|
}
|
|
|
|
private void OnPlayerAttached(EntityUid uid, DrowsinessComponent component, LocalPlayerAttachedEvent args)
|
|
{
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void OnPlayerDetached(EntityUid uid, DrowsinessComponent component, LocalPlayerDetachedEvent args)
|
|
{
|
|
_overlay.CurrentPower = 0;
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnDrowsinessInit(EntityUid uid, DrowsinessComponent component, ComponentInit args)
|
|
{
|
|
if (_player.LocalEntity == uid)
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void OnDrowsinessShutdown(EntityUid uid, DrowsinessComponent component, ComponentShutdown args)
|
|
{
|
|
if (_player.LocalEntity == uid)
|
|
{
|
|
_overlay.CurrentPower = 0;
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
}
|
|
}
|