* Item and clothes prefix toggler Handles Item.HeldPrefix and ClothingComponent.EquippedPrefix respectively * stunbaton and magboots sprites activations to Toggler yml * review --------- Co-authored-by: Milon <milonpl.git@proton.me>
26 lines
815 B
C#
26 lines
815 B
C#
using Content.Shared.Clothing.Components;
|
|
using Content.Shared.Item.ItemToggle.Components;
|
|
|
|
namespace Content.Shared.Clothing.EntitySystems;
|
|
|
|
/// <summary>
|
|
/// On toggle handles the changes to ItemComponent.HeldPrefix. <see cref="ToggleClothingPrefixComponent"/>.
|
|
/// </summary>
|
|
public sealed class ToggleClothingPrefixSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly ClothingSystem _clothing = default!;
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ToggleClothingPrefixComponent, ItemToggledEvent>(OnToggled);
|
|
}
|
|
|
|
private void OnToggled(Entity<ToggleClothingPrefixComponent> ent, ref ItemToggledEvent args)
|
|
{
|
|
_clothing.SetEquippedPrefix(ent, args.Activated ? ent.Comp.PrefixOn : ent.Comp.PrefixOff);
|
|
}
|
|
}
|