* Added ClothingGotEquipped/ClothingGotUnequipped events * Better version * Implemented in a few places * More implementations * Add ClothingDidEquipped/ClothingDidUnequipped events
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using Content.Shared.Clothing;
|
|
|
|
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>
|
|
[ValidatePrototypeId<TypingIndicatorPrototype>]
|
|
public const string InitialIndicatorId = "default";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<TypingIndicatorClothingComponent, ClothingGotEquippedEvent>(OnGotEquipped);
|
|
SubscribeLocalEvent<TypingIndicatorClothingComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
|
|
}
|
|
|
|
private void OnGotEquipped(EntityUid uid, TypingIndicatorClothingComponent component, ClothingGotEquippedEvent args)
|
|
{
|
|
if (!TryComp<TypingIndicatorComponent>(args.Wearer, out var indicator))
|
|
return;
|
|
|
|
indicator.Prototype = component.Prototype;
|
|
}
|
|
|
|
private void OnGotUnequipped(EntityUid uid, TypingIndicatorClothingComponent component, ClothingGotUnequippedEvent args)
|
|
{
|
|
if (!TryComp<TypingIndicatorComponent>(args.Wearer, out var indicator))
|
|
return;
|
|
|
|
indicator.Prototype = SharedTypingIndicatorSystem.InitialIndicatorId;
|
|
}
|
|
}
|