Lawyer badge changes typing indicator (#13445)
This commit is contained in:
@@ -1,9 +1,42 @@
|
||||
namespace Content.Shared.Chat.TypingIndicator;
|
||||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.Inventory.Events;
|
||||
|
||||
namespace Content.Shared.Chat.TypingIndicator;
|
||||
|
||||
/// <summary>
|
||||
/// Sync typing indicator icon between client and server.
|
||||
/// </summary>
|
||||
public abstract class SharedTypingIndicatorSystem : EntitySystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ID of <see cref="TypingIndicatorPrototype"/>
|
||||
/// </summary>
|
||||
public const string InitialIndicatorId = "default";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<TypingIndicatorClothingComponent, GotEquippedEvent>(OnGotEquipped);
|
||||
SubscribeLocalEvent<TypingIndicatorClothingComponent, GotUnequippedEvent>(OnGotUnequipped);
|
||||
}
|
||||
|
||||
private void OnGotEquipped(EntityUid uid, TypingIndicatorClothingComponent component, GotEquippedEvent args)
|
||||
{
|
||||
if (!TryComp<ClothingComponent>(uid, out var clothing) ||
|
||||
!TryComp<TypingIndicatorComponent>(args.Equipee, out var indicator))
|
||||
return;
|
||||
|
||||
var isCorrectSlot = clothing.Slots.HasFlag(args.SlotFlags);
|
||||
if (!isCorrectSlot) return;
|
||||
|
||||
indicator.Prototype = component.Prototype;
|
||||
}
|
||||
|
||||
private void OnGotUnequipped(EntityUid uid, TypingIndicatorClothingComponent component, GotUnequippedEvent args)
|
||||
{
|
||||
if (!TryComp<TypingIndicatorComponent>(args.Equipee, out var indicator))
|
||||
return;
|
||||
|
||||
indicator.Prototype = SharedTypingIndicatorSystem.InitialIndicatorId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user