Files
tbd-station-14/Content.Shared/Clothing/EntitySystems/ToggleClothingPrefixSystem.cs
Token ace3682de3 Item HeldPrefix and Clothing EquippedPrefix toggler (#33054)
* 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>
2025-04-14 15:50:21 -07:00

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);
}
}