Files
tbd-station-14/Content.Client/Revenant/RevenantSystem.cs

40 lines
1.3 KiB
C#

using Content.Shared.Revenant;
using Content.Shared.Revenant.Components;
using Robust.Client.GameObjects;
namespace Content.Client.Revenant;
public sealed class RevenantSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RevenantComponent, AppearanceChangeEvent>(OnAppearanceChange);
}
private void OnAppearanceChange(EntityUid uid, RevenantComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
if (_appearance.TryGetData<bool>(uid, RevenantVisuals.Harvesting, out var harvesting, args.Component) && harvesting)
{
args.Sprite.LayerSetState(0, component.HarvestingState);
}
else if (_appearance.TryGetData<bool>(uid, RevenantVisuals.Stunned, out var stunned, args.Component) && stunned)
{
args.Sprite.LayerSetState(0, component.StunnedState);
}
else if (_appearance.TryGetData<bool>(uid, RevenantVisuals.Corporeal, out var corporeal, args.Component))
{
if (corporeal)
args.Sprite.LayerSetState(0, component.CorporealState);
else
args.Sprite.LayerSetState(0, component.State);
}
}
}