2022-06-23 16:33:25 +12:00
|
|
|
using Content.Shared.Drunk;
|
|
|
|
|
using Robust.Client.Graphics;
|
|
|
|
|
using Robust.Client.Player;
|
2023-11-11 13:08:10 +11:00
|
|
|
using Robust.Shared.Player;
|
2022-06-23 16:33:25 +12:00
|
|
|
|
|
|
|
|
namespace Content.Client.Drunk;
|
|
|
|
|
|
|
|
|
|
public sealed class DrunkSystem : SharedDrunkSystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
|
|
|
|
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
|
|
|
|
|
|
|
|
|
private DrunkOverlay _overlay = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<DrunkComponent, ComponentInit>(OnDrunkInit);
|
|
|
|
|
SubscribeLocalEvent<DrunkComponent, ComponentShutdown>(OnDrunkShutdown);
|
|
|
|
|
|
2023-10-28 09:59:53 +11:00
|
|
|
SubscribeLocalEvent<DrunkComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
|
|
|
|
|
SubscribeLocalEvent<DrunkComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
|
2022-06-23 16:33:25 +12:00
|
|
|
|
|
|
|
|
_overlay = new();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-28 09:59:53 +11:00
|
|
|
private void OnPlayerAttached(EntityUid uid, DrunkComponent component, LocalPlayerAttachedEvent args)
|
2022-06-23 16:33:25 +12:00
|
|
|
{
|
|
|
|
|
_overlayMan.AddOverlay(_overlay);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-28 09:59:53 +11:00
|
|
|
private void OnPlayerDetached(EntityUid uid, DrunkComponent component, LocalPlayerDetachedEvent args)
|
2022-06-23 16:33:25 +12:00
|
|
|
{
|
|
|
|
|
_overlay.CurrentBoozePower = 0;
|
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDrunkInit(EntityUid uid, DrunkComponent component, ComponentInit args)
|
|
|
|
|
{
|
2024-02-13 22:48:39 +01:00
|
|
|
if (_player.LocalEntity == uid)
|
2022-06-23 16:33:25 +12:00
|
|
|
_overlayMan.AddOverlay(_overlay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDrunkShutdown(EntityUid uid, DrunkComponent component, ComponentShutdown args)
|
|
|
|
|
{
|
2024-02-13 22:48:39 +01:00
|
|
|
if (_player.LocalEntity == uid)
|
2022-06-23 16:33:25 +12:00
|
|
|
{
|
|
|
|
|
_overlay.CurrentBoozePower = 0;
|
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|