Lawyer badge changes typing indicator (#13445)
This commit is contained in:
@@ -9,15 +9,9 @@ public sealed class TypingIndicatorVisualizerSystem : VisualizerSystem<TypingInd
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
protected override void OnAppearanceChange(EntityUid uid, TypingIndicatorComponent component, ref AppearanceChangeEvent args)
|
||||||
{
|
{
|
||||||
base.Initialize();
|
if (args.Sprite == null)
|
||||||
SubscribeLocalEvent<TypingIndicatorComponent, ComponentInit>(OnInit);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnInit(EntityUid uid, TypingIndicatorComponent component, ComponentInit args)
|
|
||||||
{
|
|
||||||
if (!TryComp(uid, out SpriteComponent? sprite))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!_prototypeManager.TryIndex<TypingIndicatorPrototype>(component.Prototype, out var proto))
|
if (!_prototypeManager.TryIndex<TypingIndicatorPrototype>(component.Prototype, out var proto))
|
||||||
@@ -26,25 +20,15 @@ public sealed class TypingIndicatorVisualizerSystem : VisualizerSystem<TypingInd
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var layer = sprite.LayerMapReserveBlank(TypingIndicatorLayers.Base);
|
|
||||||
sprite.LayerSetRSI(layer, proto.SpritePath);
|
|
||||||
sprite.LayerSetState(layer, proto.TypingState);
|
|
||||||
sprite.LayerSetShader(layer, proto.Shader);
|
|
||||||
sprite.LayerSetOffset(layer, proto.Offset);
|
|
||||||
sprite.LayerSetVisible(layer, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnAppearanceChange(EntityUid uid, TypingIndicatorComponent component, ref AppearanceChangeEvent args)
|
|
||||||
{
|
|
||||||
base.OnAppearanceChange(uid, component, ref args);
|
|
||||||
|
|
||||||
if (!TryComp(uid, out SpriteComponent? sprite))
|
|
||||||
return;
|
|
||||||
|
|
||||||
args.Component.TryGetData(TypingIndicatorVisuals.IsTyping, out bool isTyping);
|
args.Component.TryGetData(TypingIndicatorVisuals.IsTyping, out bool isTyping);
|
||||||
if (sprite.LayerMapTryGet(TypingIndicatorLayers.Base, out var layer))
|
var layerExists = args.Sprite.LayerMapTryGet(TypingIndicatorLayers.Base, out var layer);
|
||||||
{
|
if (!layerExists)
|
||||||
sprite.LayerSetVisible(layer, isTyping);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Chat.TypingIndicator;
|
using Content.Shared.Chat.TypingIndicator;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Players;
|
|
||||||
|
|
||||||
namespace Content.Server.Chat.TypingIndicator;
|
namespace Content.Server.Chat.TypingIndicator;
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
/// <summary>
|
||||||
/// Sync typing indicator icon between client and server.
|
/// Sync typing indicator icon between client and server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SharedTypingIndicatorSystem : EntitySystem
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
|
namespace Content.Shared.Chat.TypingIndicator;
|
||||||
|
|
||||||
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
[Access(typeof(SharedTypingIndicatorSystem))]
|
||||||
|
public sealed class TypingIndicatorClothingComponent : Component
|
||||||
|
{
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("proto", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<TypingIndicatorPrototype>))]
|
||||||
|
public string Prototype = default!;
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ public sealed class TypingIndicatorComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prototype id that store all visual info about typing indicator.
|
/// Prototype id that store all visual info about typing indicator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("proto", customTypeSerializer: typeof(PrototypeIdSerializer<TypingIndicatorPrototype>))]
|
[DataField("proto", customTypeSerializer: typeof(PrototypeIdSerializer<TypingIndicatorPrototype>))]
|
||||||
public string Prototype = "default";
|
public string Prototype = SharedTypingIndicatorSystem.InitialIndicatorId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,3 +42,5 @@
|
|||||||
sprite: Clothing/Neck/Misc/lawyerbadge.rsi
|
sprite: Clothing/Neck/Misc/lawyerbadge.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
sprite: Clothing/Neck/Misc/lawyerbadge.rsi
|
sprite: Clothing/Neck/Misc/lawyerbadge.rsi
|
||||||
|
- type: TypingIndicatorClothing
|
||||||
|
proto: lawyer
|
||||||
|
|||||||
@@ -17,3 +17,7 @@
|
|||||||
- type: typingIndicator
|
- type: typingIndicator
|
||||||
id: holo
|
id: holo
|
||||||
typingState: holo0
|
typingState: holo0
|
||||||
|
|
||||||
|
- type: typingIndicator
|
||||||
|
id: lawyer
|
||||||
|
typingState: lawyer0
|
||||||
|
|||||||
Reference in New Issue
Block a user