2022-06-23 16:33:25 +12:00
|
|
|
using Content.Shared.Drunk;
|
2025-08-18 13:26:29 -07:00
|
|
|
using Content.Shared.StatusEffectNew;
|
2022-06-23 16:33:25 +12:00
|
|
|
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();
|
|
|
|
|
|
2025-08-18 13:26:29 -07:00
|
|
|
SubscribeLocalEvent<DrunkStatusEffectComponent, StatusEffectAppliedEvent>(OnStatusApplied);
|
|
|
|
|
SubscribeLocalEvent<DrunkStatusEffectComponent, StatusEffectRemovedEvent>(OnStatusRemoved);
|
2022-06-23 16:33:25 +12:00
|
|
|
|
2025-08-18 13:26:29 -07:00
|
|
|
SubscribeLocalEvent<DrunkStatusEffectComponent, StatusEffectRelayedEvent<LocalPlayerAttachedEvent>>(OnPlayerAttached);
|
|
|
|
|
SubscribeLocalEvent<DrunkStatusEffectComponent, StatusEffectRelayedEvent<LocalPlayerDetachedEvent>>(OnPlayerDetached);
|
2022-06-23 16:33:25 +12:00
|
|
|
|
|
|
|
|
_overlay = new();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-18 13:26:29 -07:00
|
|
|
private void OnStatusApplied(Entity<DrunkStatusEffectComponent> entity, ref StatusEffectAppliedEvent args)
|
2022-06-23 16:33:25 +12:00
|
|
|
{
|
2025-08-18 13:26:29 -07:00
|
|
|
if (!_overlayMan.HasOverlay<DrunkOverlay>())
|
|
|
|
|
_overlayMan.AddOverlay(_overlay);
|
2022-06-23 16:33:25 +12:00
|
|
|
}
|
|
|
|
|
|
2025-08-18 13:26:29 -07:00
|
|
|
private void OnStatusRemoved(Entity<DrunkStatusEffectComponent> entity, ref StatusEffectRemovedEvent args)
|
2022-06-23 16:33:25 +12:00
|
|
|
{
|
2025-08-18 13:26:29 -07:00
|
|
|
if (Status.HasEffectComp<DrunkStatusEffectComponent>(args.Target))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (_player.LocalEntity != args.Target)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-06-23 16:33:25 +12:00
|
|
|
_overlay.CurrentBoozePower = 0;
|
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-18 13:26:29 -07:00
|
|
|
private void OnPlayerAttached(Entity<DrunkStatusEffectComponent> entity, ref StatusEffectRelayedEvent<LocalPlayerAttachedEvent> args)
|
2022-06-23 16:33:25 +12:00
|
|
|
{
|
2025-08-18 13:26:29 -07:00
|
|
|
_overlayMan.AddOverlay(_overlay);
|
2022-06-23 16:33:25 +12:00
|
|
|
}
|
|
|
|
|
|
2025-08-18 13:26:29 -07:00
|
|
|
private void OnPlayerDetached(Entity<DrunkStatusEffectComponent> entity, ref StatusEffectRelayedEvent<LocalPlayerDetachedEvent> args)
|
2022-06-23 16:33:25 +12:00
|
|
|
{
|
2025-08-18 13:26:29 -07:00
|
|
|
_overlay.CurrentBoozePower = 0;
|
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
2022-06-23 16:33:25 +12:00
|
|
|
}
|
|
|
|
|
}
|