Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No vocal emotes when muzzled #1101

Closed
24 changes: 24 additions & 0 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
using Robust.Shared.Replays;
using Robust.Shared.Utility;
using Robust.Shared.Timing;
using Content.Shared.Bed.Sleep;
using Content.Shared.Dataset;

namespace Content.Server.Chat.Systems;

Expand All @@ -59,6 +61,9 @@ public sealed partial class ChatSystem : SharedChatSystem
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly ReplacementAccentSystem _wordreplacement = default!;
[Dependency] private readonly IEntityManager _entities = default!;// SS220 No vocal emotes when muzzled
[Dependency] private readonly IPrototypeManager _proto = default!;// SS220 No vocal emotes when muzzled

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

на это пометки можно не ставить



public const int VoiceRange = 10; // how far voice goes in world units
public const int WhisperClearRange = 2; // how far whisper goes while still being understandable, in world units
Expand Down Expand Up @@ -556,6 +561,8 @@ private void SendEntityEmote(
var ent = Identity.Entity(source, EntityManager);
string name = FormattedMessage.EscapeText(nameOverride ?? Name(ent));

CheckForEmoteAbility(source, ref action);//SS220 emote

// Emotes use Identity.Name, since it doesn't actually involve your voice at all.
var wrappedMessage = Loc.GetString("chat-manager-entity-me-wrap-message",
("entityName", name),
Expand All @@ -579,6 +586,23 @@ private void SendEntityEmote(
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user}: {action}");
}

//SS220 No_vocal_emotes_when_muzzled start
private void CheckForEmoteAbility(EntityUid uid,ref String action)
{
if (_entities.TryGetComponent<SleepingComponent>(uid, out var sleeping))
{
action = PickEmote(sleeping.SleepingEmotes);
return;
}
}

private string PickEmote(string name)
{
var dataset = _proto.Index<DatasetPrototype>(name);
return _random.Pick(dataset.Values);
}
//SS220 No_vocal_emotes_when_muzzled end

// ReSharper disable once InconsistentNaming
private void SendLOOC(EntityUid source, ICommonSession player, string message, bool hideChat)
{
Expand Down
11 changes: 11 additions & 0 deletions Content.Server/SS220/Muzzle/MuzzleSystem.cs
DexlerXD marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Shared.SS220.Muzzle;

namespace Content.Server.SS220.Muzzle;
public sealed class MuzzleSystem : SharedMuzzleSystem
{
public override void Initialize()
{
base.Initialize();
}
}
10 changes: 7 additions & 3 deletions Content.Server/Speech/EntitySystems/VocalSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Content.Shared.SS220.Speech;// SS220 Chat-Special-Emote
using Content.Shared.SS220.Speech;
using Content.Shared.SS220.Muzzle;// SS220 No_vocal_emotes_when_muzzled

namespace Content.Server.Speech.EntitySystems;

Expand Down Expand Up @@ -60,10 +61,13 @@ private void OnEmote(EntityUid uid, VocalComponent component, ref EmoteEvent arg
{
if (args.Handled || !args.Emote.Category.HasFlag(EmoteCategory.Vocal))
return;


if (HasComp<MuzzledComponent>(uid))// SS220 No_vocal_emotes_when_muzzled
return;

// SS220 Chat-Special-Emote begin
//Will play special emote if it exists
if(CheckSpecialSounds(uid, component, args.Emote))
if (CheckSpecialSounds(uid, component, args.Emote))
{
args.Handled = true;
return;
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/Bed/Sleep/SleepingComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ public sealed partial class SleepingComponent : Component
public TimeSpan CoolDownEnd;

[DataField("wakeAction")] public EntityUid? WakeAction;

//SS220 No vocal emotes when muzzled
[DataField("sleepingEmotes")] public string SleepingEmotes = "SleepingEmotesSS220";//Name of the dataset, that will replace regular emote
}
14 changes: 14 additions & 0 deletions Content.Shared/SS220/Muzzle/MuzzleComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.SS220.Muzzle;

[RegisterComponent, NetworkedComponent()]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[RegisterComponent, NetworkedComponent()]
[RegisterComponent, NetworkedComponent]

[Access(typeof(SharedMuzzleSystem))]
/// <summary>
/// Added to entities when they have to block entityes vocal emotions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Added to entities when they have to block entityes vocal emotions
/// Added to entities that are blocking other entity's vocal emotions

/// </summary>
public sealed partial class MuzzleComponent : Component
{
}
13 changes: 13 additions & 0 deletions Content.Shared/SS220/Muzzle/MuzzledComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.SS220.Muzzle;

[RegisterComponent, NetworkedComponent()]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[RegisterComponent, NetworkedComponent()]
[RegisterComponent, NetworkedComponent]

/// <summary>
/// Added to entities when if entity should have blocked vocal emotions
/// </summary>
public sealed partial class MuzzledComponent : Component
{
}
26 changes: 26 additions & 0 deletions Content.Shared/SS220/Muzzle/SharedMuzzleSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Shared.Clothing;

namespace Content.Shared.SS220.Muzzle;

public abstract class SharedMuzzleSystem : EntitySystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<MuzzleComponent, ClothingGotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<MuzzleComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
}

private void OnGotUnequipped(EntityUid uid, MuzzleComponent component, ref ClothingGotUnequippedEvent args)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

по новой форме обработки ивентов оформь
т. е.

private void Func(Entity<Comp> ent, ref EventClass args) {}

{
_entityManager.RemoveComponent<MuzzledComponent>(args.Wearer);
}

private void OnGotEquipped(EntityUid uid, MuzzleComponent component, ref ClothingGotEquippedEvent args)
{
_entityManager.AddComponent<MuzzledComponent>(args.Wearer);
}
}
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Clothing/Masks/masks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@
- type: Construction
graph: Muzzle
node: muzzle
- type: Muzzle #SS220 No vocal emotes when muzzled

- type: entity
parent: ClothingMaskPullableBase
Expand Down
11 changes: 11 additions & 0 deletions Resources/Prototypes/SS220/Datasets/sleepingEmotes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Нужно для генерации эмоций во сне
- type: dataset
id: SleepingEmotesSS220
values:
- ворчит
- бормочет
- ворочается
- подергивается
- строит физиономии
- активно жестикулирует
- морщится
Loading