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

Add clothing special emotes #1846

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Content.Client/Chat/UI/EmotesMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public EmotesMenu()

if (!emote.Available &&
_entManager.TryGetComponent<SpeechComponent>(player.Value, out var speech) &&
!speech.AllowedEmotes.Contains(emote.ID))
!speech.AllowedEmotes.Contains(emote.ID) &&
!speech.ClothingEmotes.Contains(emote.ID)) //SS220 Clothing special emotes
continue;

var parent = FindControl<RadialContainer>(emote.Category.ToString());
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Chat/Systems/ChatSystem.Emote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ private bool AllowedToUseEmote(EntityUid source, EmotePrototype emote)

if (!emote.Available &&
TryComp<SpeechComponent>(source, out var speech) &&
!speech.AllowedEmotes.Contains(emote.ID))
!speech.AllowedEmotes.Contains(emote.ID) &&
!speech.ClothingEmotes.Contains(emote.ID)) //SS220 Clothing special emotes
return false;

return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// © 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.Chat.Prototypes;
using Robust.Shared.Prototypes;

namespace Content.Server.SS220.Speech.Components;

/// <summary>
/// Allows you to use some emotions when equipped clothing with this component.
/// Must be used with <see cref="Shared.Speech.Components.VocalComponent"/> in order for emotions to be voiced.
/// </summary>
[RegisterComponent]
public sealed partial class ClothingSpecialEmotesComponent : Component
{
/// <summary>
/// List of emotions that can be used with these clothing
/// </summary>
[DataField]
public List<ProtoId<EmotePrototype>> Emotes = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Server.SS220.Speech.Components;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Speech;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Server.SS220.Speech.EntitySystems;

public sealed partial class ClothingSpecialEmotesSystem : EntitySystem
{
[Dependency] private readonly InventorySystem _inventory = default!;

private Dictionary<EntityUid, List<ProtoId<EmotePrototype>>> _temporaryEmotes = new();

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ClothingSpecialEmotesComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<ClothingSpecialEmotesComponent, GotUnequippedEvent>(OnUnequipped);
}

private void OnEquipped(Entity<ClothingSpecialEmotesComponent> entity, ref GotEquippedEvent args)
{
if (entity.Comp.Emotes.Count <= 0 ||
!TryComp<SpeechComponent>(args.Equipee, out var speech))
return;

foreach (var newEmote in entity.Comp.Emotes)
{
if (speech.AllowedEmotes.Contains(newEmote))
continue;

_temporaryEmotes.GetOrNew(entity.Owner).Add(newEmote);
if (!speech.ClothingEmotes.Contains(newEmote))
speech.ClothingEmotes.Add(newEmote);
}
Dirty(args.Equipee, speech);
}

private void OnUnequipped(Entity<ClothingSpecialEmotesComponent> entity, ref GotUnequippedEvent args)
{
if (!_temporaryEmotes.TryGetValue(entity.Owner, out var toRemove) ||
!TryComp<SpeechComponent>(args.Equipee, out var speech))
return;

//doesn't remove emotion if equipee has other clothes that give it
var slotEnumerator = _inventory.GetSlotEnumerator(args.Equipee);
while (slotEnumerator.NextItem(out var item))
{
if (item == entity.Owner ||
!_temporaryEmotes.TryGetValue(item, out var itemEmotes))
continue;

foreach (var itemEmote in itemEmotes)
{
toRemove.Remove(itemEmote);
}
}

foreach (var emote in toRemove)
{
speech.ClothingEmotes.Remove(emote);
}

_temporaryEmotes.Remove(entity.Owner);
Dirty(args.Equipee, speech);
}
}
9 changes: 9 additions & 0 deletions Content.Shared/Speech/SpeechComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public sealed partial class SpeechComponent : Component
[DataField]
public List<ProtoId<EmotePrototype>> AllowedEmotes = new();

//SS220 Clothing special emotes begin
/// <summary>
/// What emotions allowed to use with special clothing
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField, AutoNetworkedField]
public List<ProtoId<EmotePrototype>> ClothingEmotes = new();
//SS220 Clothing special emotes end

/// <summary>
/// A mapping from chat suffixes loc strings to speech verb prototypes that should be conditionally used.
/// For things like '?' changing to 'asks' or '!!' making text bold and changing to 'yells'. Can be overridden if necessary.
Expand Down
5 changes: 5 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Head/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
Female: FemaleFelinid
Unsexed: MaleFelinid
#ss220 special_sounds end
#SS220 clothing special emotes begin
- type: ClothingSpecialEmotes
emotes: ['Meow', 'Mew', 'Growl', 'Purr', 'Hiss']
#SS220 clothing special emotes end


- type: entity
parent: [ClothingHeadHatCatEars, BaseToggleClothing]
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Neck/cloaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
Female: UnisexMoth
Unsexed: UnisexMoth
#ss220 special_sounds end
#SS220 clothing special emotes begin
- type: ClothingSpecialEmotes
emotes: ['Chitter', 'Squeak']
#SS220 clothing special emotes end

- type: entity
parent: ClothingNeckBase
Expand Down
Loading