2022-06-23 16:33:25 +12:00
|
|
|
using Content.Shared.Speech.EntitySystems;
|
|
|
|
|
using Content.Shared.StatusEffect;
|
2023-03-04 19:44:13 -08:00
|
|
|
using Content.Shared.Traits.Assorted;
|
2022-06-23 16:33:25 +12:00
|
|
|
|
|
|
|
|
namespace Content.Shared.Drunk;
|
|
|
|
|
|
|
|
|
|
public abstract class SharedDrunkSystem : EntitySystem
|
|
|
|
|
{
|
2023-08-13 20:26:59 -04:00
|
|
|
[ValidatePrototypeId<StatusEffectPrototype>]
|
2022-06-23 16:33:25 +12:00
|
|
|
public const string DrunkKey = "Drunk";
|
|
|
|
|
|
|
|
|
|
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
|
|
|
|
[Dependency] private readonly SharedSlurredSystem _slurredSystem = default!;
|
|
|
|
|
|
2022-07-30 22:24:24 -04:00
|
|
|
public void TryApplyDrunkenness(EntityUid uid, float boozePower, bool applySlur = true,
|
2022-06-23 16:33:25 +12:00
|
|
|
StatusEffectsComponent? status = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref status, false))
|
|
|
|
|
return;
|
|
|
|
|
|
2023-05-04 12:02:30 -07:00
|
|
|
if (TryComp<LightweightDrunkComponent>(uid, out var trait))
|
|
|
|
|
boozePower *= trait.BoozeStrengthMultiplier;
|
|
|
|
|
|
2022-07-30 22:24:24 -04:00
|
|
|
if (applySlur)
|
2023-04-29 04:34:19 -04:00
|
|
|
{
|
2022-07-30 22:24:24 -04:00
|
|
|
_slurredSystem.DoSlur(uid, TimeSpan.FromSeconds(boozePower), status);
|
2023-04-29 04:34:19 -04:00
|
|
|
}
|
2022-07-30 22:24:24 -04:00
|
|
|
|
2022-06-23 16:33:25 +12:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-18 23:09:22 -04:00
|
|
|
|
|
|
|
|
public void TryRemoveDrunkenness(EntityUid uid)
|
|
|
|
|
{
|
|
|
|
|
_statusEffectsSystem.TryRemoveStatusEffect(uid, DrunkKey);
|
|
|
|
|
}
|
|
|
|
|
public void TryRemoveDrunkenessTime(EntityUid uid, double timeRemoved)
|
|
|
|
|
{
|
|
|
|
|
_statusEffectsSystem.TryRemoveTime(uid, DrunkKey, TimeSpan.FromSeconds(timeRemoved));
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-23 16:33:25 +12:00
|
|
|
}
|