A few trait fixes (#16062)

This commit is contained in:
Scribbles0
2023-05-04 12:02:30 -07:00
committed by GitHub
parent e4b0f6e5a7
commit e6bd21e184
5 changed files with 62 additions and 55 deletions

View File

@@ -15,6 +15,7 @@ using Content.Server.Chat.Systems;
using Content.Server.Speech.Components;
using Content.Shared.Chat.Prototypes;
using Content.Server.Speech.EntitySystems;
using Content.Server.Speech.Muting;
namespace Content.Server.Abilities.Mime
{
@@ -30,10 +31,7 @@ namespace Content.Server.Abilities.Mime
{
base.Initialize();
SubscribeLocalEvent<MimePowersComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<MimePowersComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<MimePowersComponent, InvisibleWallActionEvent>(OnInvisibleWall);
SubscribeLocalEvent<MimePowersComponent, EmoteEvent>(OnEmote, before: new[] { typeof(VocalSystem) });
SubscribeLocalEvent<MimePowersComponent, ScreamActionEvent>(OnScreamAction, before: new[] { typeof(VocalSystem) });
}
public override void Update(float frameTime)
{
@@ -54,36 +52,10 @@ namespace Content.Server.Abilities.Mime
private void OnComponentInit(EntityUid uid, MimePowersComponent component, ComponentInit args)
{
EnsureComp<MutedComponent>(uid);
_actionsSystem.AddAction(uid, component.InvisibleWallAction, uid);
_alertsSystem.ShowAlert(uid, AlertType.VowOfSilence);
}
private void OnSpeakAttempt(EntityUid uid, MimePowersComponent component, SpeakAttemptEvent args)
{
if (!component.Enabled)
return;
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
args.Cancel();
}
private void OnEmote(EntityUid uid, MimePowersComponent component, ref EmoteEvent args)
{
if (!component.Enabled || args.Handled)
return;
//still leaves the text so it looks like they are pantomiming a laugh
if (args.Emote.Category.HasFlag(EmoteCategory.Vocal))
args.Handled = true;
}
private void OnScreamAction(EntityUid uid, MimePowersComponent component, ScreamActionEvent args)
{
if (!component.Enabled || args.Handled)
return;
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
args.Handled = true;
}
/// <summary>
/// Creates an invisible wall in a free space after some checks.
@@ -130,6 +102,7 @@ namespace Content.Server.Abilities.Mime
mimePowers.Enabled = false;
mimePowers.VowBroken = true;
mimePowers.VowRepentTime = _timing.CurTime + mimePowers.VowCooldown;
RemComp<MutedComponent>(uid);
_alertsSystem.ClearAlert(uid, AlertType.VowOfSilence);
_alertsSystem.ShowAlert(uid, AlertType.VowBroken);
_actionsSystem.RemoveAction(uid, mimePowers.InvisibleWallAction);
@@ -152,6 +125,7 @@ namespace Content.Server.Abilities.Mime
mimePowers.Enabled = true;
mimePowers.ReadyToRepent = false;
mimePowers.VowBroken = false;
AddComp<MutedComponent>(uid);
_alertsSystem.ClearAlert(uid, AlertType.VowBroken);
_alertsSystem.ShowAlert(uid, AlertType.VowOfSilence);
_actionsSystem.AddAction(uid, mimePowers.InvisibleWallAction, uid);

View File

@@ -1,4 +1,4 @@
namespace Content.Shared.Speech.Muting
namespace Content.Server.Speech.Muting
{
[RegisterComponent]
public sealed class MutedComponent : Component

View File

@@ -0,0 +1,54 @@
using Content.Server.Abilities.Mime;
using Content.Server.Chat.Systems;
using Content.Server.Popups;
using Content.Server.Speech.Components;
using Content.Server.Speech.EntitySystems;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Speech;
namespace Content.Server.Speech.Muting
{
public sealed class MutingSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MutedComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<MutedComponent, EmoteEvent>(OnEmote, before: new[] { typeof(VocalSystem) });
SubscribeLocalEvent<MutedComponent, ScreamActionEvent>(OnScreamAction, before: new[] { typeof(VocalSystem) });
}
private void OnEmote(EntityUid uid, MutedComponent component, ref EmoteEvent args)
{
if (args.Handled)
return;
//still leaves the text so it looks like they are pantomiming a laugh
if (args.Emote.Category.HasFlag(EmoteCategory.Vocal))
args.Handled = true;
}
private void OnScreamAction(EntityUid uid, MutedComponent component, ScreamActionEvent args)
{
if (args.Handled)
return;
if (HasComp<MimePowersComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
else
_popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);
args.Handled = true;
}
private void OnSpeakAttempt(EntityUid uid, MutedComponent component, SpeakAttemptEvent args)
{
if (HasComp<MimePowersComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
else
_popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);
args.Cancel();
}
}
}

View File

@@ -17,14 +17,14 @@ public abstract class SharedDrunkSystem : EntitySystem
if (!Resolve(uid, ref status, false))
return;
if (TryComp<LightweightDrunkComponent>(uid, out var trait))
boozePower *= trait.BoozeStrengthMultiplier;
if (applySlur)
{
_slurredSystem.DoSlur(uid, TimeSpan.FromSeconds(boozePower), status);
}
if (TryComp<LightweightDrunkComponent>(uid, out var trait))
boozePower *= trait.BoozeStrengthMultiplier;
if (!_statusEffectsSystem.HasStatusEffect(uid, DrunkKey, status))
{
_statusEffectsSystem.TryAddStatusEffect<DrunkComponent>(uid, DrunkKey, TimeSpan.FromSeconds(boozePower), true, status);

View File

@@ -1,21 +0,0 @@
using Content.Shared.Popups;
using Robust.Shared.Player;
namespace Content.Shared.Speech.Muting
{
public sealed class MutingSystem : EntitySystem
{
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MutedComponent, SpeakAttemptEvent>(OnSpeakAttempt);
}
private void OnSpeakAttempt(EntityUid uid, MutedComponent component, SpeakAttemptEvent args)
{
_popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);
args.Cancel();
}
}
}