Co-authored-by: Kara D <lunarautomaton6@gmail.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
30 lines
1019 B
C#
30 lines
1019 B
C#
using Content.Shared.Speech.EntitySystems;
|
|
using Content.Shared.StatusEffect;
|
|
|
|
namespace Content.Shared.Drunk;
|
|
|
|
public abstract class SharedDrunkSystem : EntitySystem
|
|
{
|
|
public const string DrunkKey = "Drunk";
|
|
|
|
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
|
[Dependency] private readonly SharedSlurredSystem _slurredSystem = default!;
|
|
|
|
public void TryApplyDrunkenness(EntityUid uid, float boozePower,
|
|
StatusEffectsComponent? status = null)
|
|
{
|
|
if (!Resolve(uid, ref status, false))
|
|
return;
|
|
|
|
_slurredSystem.DoSlur(uid, TimeSpan.FromSeconds(boozePower), status);
|
|
if (!_statusEffectsSystem.HasStatusEffect(uid, DrunkKey, status))
|
|
{
|
|
_statusEffectsSystem.TryAddStatusEffect<DrunkComponent>(uid, DrunkKey, TimeSpan.FromSeconds(boozePower), true, status);
|
|
}
|
|
else
|
|
{
|
|
_statusEffectsSystem.TryAddTime(uid, DrunkKey, TimeSpan.FromSeconds(boozePower), status);
|
|
}
|
|
}
|
|
}
|