Files
wwdpublic/Content.Client/NPC/Systems/NpcFactionSpriteStateSetterSystem.cs
Timfa 0df12ec24a Gladiabot (#1548)
Co-authored-by: stellar-novas <stellar_novas@riseup.net>
Co-authored-by: RedFoxIV <38788538+RedFoxIV@users.noreply.github.com>
(cherry picked from commit 01d1ec4d4b04f6d76f239ec0da0970dc705736ef)
2025-01-23 08:03:54 +03:00

29 lines
1007 B
C#

using Content.Shared.NPC.Components;
using Content.Shared.NPC.Events;
using Robust.Client.GameObjects;
using Robust.Shared.Reflection;
namespace Content.Client.NPC.Systems;
public sealed partial class NpcFactionSpriteStateSetterSystem : EntitySystem
{
[Dependency] private readonly SpriteSystem _spriteSystem = default!;
[Dependency] private readonly EntityManager _entityManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NpcFactionMemberComponent, NpcFactionAddedEvent>(OnFactionAdded);
}
private void OnFactionAdded(Entity<NpcFactionMemberComponent > entity, ref NpcFactionAddedEvent args)
{
if (!_entityManager.HasComponent(entity, typeof(NpcFactionSpriteStateSetterComponent)))
return;
SpriteComponent spriteComponent = _entityManager.GetComponent<SpriteComponent>(entity);
spriteComponent.LayerSetState(0, new Robust.Client.Graphics.RSI.StateId(args.FactionID));
}
}