* The only commit that matters * I had to stop playing with my cat to push this change * Yaml removal * Proper drunk status effect and remove shitcode * Review changes * whoops * Whoops x2 * Update master fix merge conflicts * Fix merge conflicts * Dunk Component kill * MORE RELAYS * Holy fucking breaking changes * Ough * 46 file diff * Fix bad commits * Erm what the test fail? * Fix those last two * Merge conflicts * Me when I fix the merge conflicts --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using Content.Shared.Drunk;
|
|
using Content.Shared.StatusEffectNew;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Player;
|
|
|
|
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<DrunkStatusEffectComponent, StatusEffectAppliedEvent>(OnStatusApplied);
|
|
SubscribeLocalEvent<DrunkStatusEffectComponent, StatusEffectRemovedEvent>(OnStatusRemoved);
|
|
|
|
SubscribeLocalEvent<DrunkStatusEffectComponent, StatusEffectRelayedEvent<LocalPlayerAttachedEvent>>(OnPlayerAttached);
|
|
SubscribeLocalEvent<DrunkStatusEffectComponent, StatusEffectRelayedEvent<LocalPlayerDetachedEvent>>(OnPlayerDetached);
|
|
|
|
_overlay = new();
|
|
}
|
|
|
|
private void OnStatusApplied(Entity<DrunkStatusEffectComponent> entity, ref StatusEffectAppliedEvent args)
|
|
{
|
|
if (!_overlayMan.HasOverlay<DrunkOverlay>())
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void OnStatusRemoved(Entity<DrunkStatusEffectComponent> entity, ref StatusEffectRemovedEvent args)
|
|
{
|
|
if (Status.HasEffectComp<DrunkStatusEffectComponent>(args.Target))
|
|
return;
|
|
|
|
if (_player.LocalEntity != args.Target)
|
|
return;
|
|
|
|
_overlay.CurrentBoozePower = 0;
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnPlayerAttached(Entity<DrunkStatusEffectComponent> entity, ref StatusEffectRelayedEvent<LocalPlayerAttachedEvent> args)
|
|
{
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void OnPlayerDetached(Entity<DrunkStatusEffectComponent> entity, ref StatusEffectRelayedEvent<LocalPlayerDetachedEvent> args)
|
|
{
|
|
_overlay.CurrentBoozePower = 0;
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
}
|