Skip to content

Commit

Permalink
don't add the scream action
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Mar 10, 2024
1 parent 4bb19f0 commit 6403503
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Content.Server/Speech/Components/VocalComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public sealed partial class VocalComponent : Component
[DataField("wilhelmProbability")]
public float WilhelmProbability = 0.0002f;

[DataField("screamAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string ScreamAction = "ActionScream";

[DataField("screamActionEntity")]
public EntityUid? ScreamActionEntity;

/// <summary>
/// Currently loaded emote sounds prototype, based on entity sex.
/// Null if no valid prototype for entity sex was found.
Expand Down
22 changes: 22 additions & 0 deletions Content.Server/Speech/EntitySystems/VocalSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,28 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<VocalComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<VocalComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<VocalComponent, SexChangedEvent>(OnSexChanged);
SubscribeLocalEvent<VocalComponent, EmoteEvent>(OnEmote);
SubscribeLocalEvent<VocalComponent, ScreamActionEvent>(OnScreamAction);
}

private void OnMapInit(EntityUid uid, VocalComponent component, MapInitEvent args)
{
// try to add scream action when vocal comp added
// _actions.AddAction(uid, ref component.ScreamActionEntity, component.ScreamAction); // Parkstation-RemoveScreamAction
LoadSounds(uid, component);
}

private void OnShutdown(EntityUid uid, VocalComponent component, ComponentShutdown args)
{
// remove scream action when component removed
if (component.ScreamActionEntity != null)
{
_actions.RemoveAction(uid, component.ScreamActionEntity);
}
}

private void OnSexChanged(EntityUid uid, VocalComponent component, SexChangedEvent args)
{
LoadSounds(uid, component);
Expand All @@ -54,6 +67,15 @@ private void OnEmote(EntityUid uid, VocalComponent component, ref EmoteEvent arg
args.Handled = _chat.TryPlayEmoteSound(uid, component.EmoteSounds, args.Emote);
}

private void OnScreamAction(EntityUid uid, VocalComponent component, ScreamActionEvent args)
{
if (args.Handled)
return;

_chat.TryEmoteWithChat(uid, component.ScreamId);
args.Handled = true;
}

private bool TryPlayScreamSound(EntityUid uid, VocalComponent component)
{
if (_random.Prob(component.WilhelmProbability))
Expand Down
14 changes: 14 additions & 0 deletions Content.Server/Speech/Muting/MutingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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)
Expand All @@ -29,6 +30,19 @@ private void OnEmote(EntityUid uid, MutedComponent component, ref EmoteEvent arg
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)
{
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/Speech/ScreamActionEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Content.Shared.Actions;

namespace Content.Shared.Speech;

public sealed partial class ScreamActionEvent : InstantActionEvent
{
}
12 changes: 12 additions & 0 deletions Resources/Prototypes/Actions/types.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
- type: entity
id: ActionScream
name: Scream
description: AAAAAAAAAAAAAAAAAAAAAAAAA
noSpawn: true
components:
- type: InstantAction
useDelay: 10
icon: Interface/Actions/scream.png
event: !type:ScreamActionEvent
checkCanInteract: false

- type: entity
id: ActionTurnUndead
name: Turn Undead
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Catalog/catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
id: DebugListing4
name: debug name 4
description: debug desc 4
productAction: ActionSleep
productAction: ActionScream
categories:
- Debug
cost:
Expand Down

0 comments on commit 6403503

Please sign in to comment.