2024-04-21 11:00:50 -04:00
|
|
|
using Content.Shared.Clothing;
|
2023-01-12 15:33:57 +03:00
|
|
|
|
|
|
|
|
namespace Content.Shared.Chat.TypingIndicator;
|
2022-05-17 12:55:19 +03:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sync typing indicator icon between client and server.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract class SharedTypingIndicatorSystem : EntitySystem
|
|
|
|
|
{
|
2023-01-12 15:33:57 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Default ID of <see cref="TypingIndicatorPrototype"/>
|
|
|
|
|
/// </summary>
|
2023-08-13 20:26:59 -04:00
|
|
|
[ValidatePrototypeId<TypingIndicatorPrototype>]
|
2023-01-12 15:33:57 +03:00
|
|
|
public const string InitialIndicatorId = "default";
|
2023-08-13 20:26:59 -04:00
|
|
|
|
2023-01-12 15:33:57 +03:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2024-04-21 11:00:50 -04:00
|
|
|
SubscribeLocalEvent<TypingIndicatorClothingComponent, ClothingGotEquippedEvent>(OnGotEquipped);
|
|
|
|
|
SubscribeLocalEvent<TypingIndicatorClothingComponent, ClothingGotUnequippedEvent>(OnGotUnequipped);
|
2023-01-12 15:33:57 +03:00
|
|
|
}
|
|
|
|
|
|
2024-04-21 11:00:50 -04:00
|
|
|
private void OnGotEquipped(EntityUid uid, TypingIndicatorClothingComponent component, ClothingGotEquippedEvent args)
|
2023-01-12 15:33:57 +03:00
|
|
|
{
|
2024-04-21 11:00:50 -04:00
|
|
|
if (!TryComp<TypingIndicatorComponent>(args.Wearer, out var indicator))
|
2023-01-12 15:33:57 +03:00
|
|
|
return;
|
2023-08-13 20:26:59 -04:00
|
|
|
|
2023-01-12 15:33:57 +03:00
|
|
|
indicator.Prototype = component.Prototype;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-21 11:00:50 -04:00
|
|
|
private void OnGotUnequipped(EntityUid uid, TypingIndicatorClothingComponent component, ClothingGotUnequippedEvent args)
|
2023-01-12 15:33:57 +03:00
|
|
|
{
|
2024-04-21 11:00:50 -04:00
|
|
|
if (!TryComp<TypingIndicatorComponent>(args.Wearer, out var indicator))
|
2023-01-12 15:33:57 +03:00
|
|
|
return;
|
2022-05-17 12:55:19 +03:00
|
|
|
|
2023-01-12 15:33:57 +03:00
|
|
|
indicator.Prototype = SharedTypingIndicatorSystem.InitialIndicatorId;
|
|
|
|
|
}
|
2022-05-17 12:55:19 +03:00
|
|
|
}
|