Сортировка эксклюзива енги + респрайт деревянных столов и дверей (#12)

* Massive

* Чейндлок

(cherry picked from commit 4dc165e4c1aa75e8fd22f14db95ac72bf50c77f5)
This commit is contained in:
BIGZi0348
2024-09-25 23:11:01 +03:00
committed by keslik
parent 79c22c1d81
commit 3b8cb7a398
45 changed files with 78 additions and 29 deletions

View File

@@ -0,0 +1,46 @@
using Robust.Shared.Timing;
using Content.Shared.Inventory.Events;
namespace Content.Shared._White._Engi.DamageableClothing;
/// <summary>
/// WD Engi Exclusive.
/// </summary>
public sealed partial class DamageableClothingSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void Initialize()
{
base.Initialize();
InitializeUser();
SubscribeLocalEvent<DamageableClothingComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<DamageableClothingComponent, GotUnequippedEvent>(OnUnequipped);
SubscribeLocalEvent<DamageableClothingComponent, ComponentShutdown>(OnShutdown);
}
private void OnEquipped(EntityUid uid, DamageableClothingComponent component, GotEquippedEvent args)
{
if (_gameTiming.ApplyingState)
return;
component.User = args.Equipee;
var userComp = EnsureComp<DamageableClothingUserComponent>(args.Equipee);
userComp.ItemId = args.Equipment;
}
private void OnUnequipped(EntityUid uid, DamageableClothingComponent component, GotUnequippedEvent args)
{
RemCompDeferred<DamageableClothingUserComponent>(args.Equipee);
component.User = null;
}
private void OnShutdown(EntityUid uid, DamageableClothingComponent component, ComponentShutdown args)
{
if (component.User != null)
{
RemCompDeferred<DamageableClothingUserComponent>(component.User.Value);
component.User = null;
}
}
}