Files
Delta-v/Content.Client/Chat/TypingIndicator/TypingIndicatorVisualizerSystem.cs
T
OxdeceptionandOxdeception 04c7e4d633 Adds a typing indicator to the AAC (#3595)
* Adds a typing indicator to the AAC

* Removes duplicate TypingChangedEvent constructor

* Updates sprite attribution

* Corrects fork addition comment style

* Moves typing indicator override from Appearance to TypingIndicatorComponent

* Reduces retrievals of TypingIndicatorSystem in the AAC BUI

* Moves ClientAlternateTyping to _DV

* Adds missing comment

* Sets TypingIndicatorComponent Dirty

* Caches ShowTypingIndicator in AlternateTypingIndicator

* Removes unnecessary default assignment

---------

Co-authored-by: Oxdeception <9624-oxdeception@users.noreply.gitgud.io>
2025-05-03 23:36:13 +01:00

57 lines
2.1 KiB
C#

using Content.Shared.Chat.TypingIndicator;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Prototypes;
using Content.Shared.Inventory;
namespace Content.Client.Chat.TypingIndicator;
public sealed class TypingIndicatorVisualizerSystem : VisualizerSystem<TypingIndicatorComponent>
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
protected override void OnAppearanceChange(EntityUid uid, TypingIndicatorComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
var currentTypingIndicator = component.TypingIndicatorPrototype;
var evt = new BeforeShowTypingIndicatorEvent();
if (TryComp<InventoryComponent>(uid, out var inventoryComp))
_inventory.RelayEvent((uid, inventoryComp), ref evt);
var overrideIndicator = evt.GetMostRecentIndicator();
if (overrideIndicator != null)
currentTypingIndicator = overrideIndicator.Value;
// Begin DeltaV Additions - AAC TypingIndicator Override
if (component.TypingIndicatorOverridePrototype != null)
{
currentTypingIndicator = component.TypingIndicatorOverridePrototype.Value;
}
// End DeltaV Additions
if (!_prototypeManager.TryIndex(currentTypingIndicator, out var proto))
{
Log.Error($"Unknown typing indicator id: {component.TypingIndicatorPrototype}");
return;
}
AppearanceSystem.TryGetData<bool>(uid, TypingIndicatorVisuals.IsTyping, out var isTyping, args.Component);
var layerExists = args.Sprite.LayerMapTryGet(TypingIndicatorLayers.Base, out var layer);
if (!layerExists)
layer = args.Sprite.LayerMapReserveBlank(TypingIndicatorLayers.Base);
args.Sprite.LayerSetRSI(layer, proto.SpritePath);
args.Sprite.LayerSetState(layer, proto.TypingState);
args.Sprite.LayerSetShader(layer, proto.Shader);
args.Sprite.LayerSetOffset(layer, proto.Offset);
args.Sprite.LayerSetVisible(layer, isTyping);
}
}