2024-09-21 17:10:02 +03:00
|
|
|
using Robust.Shared.Timing;
|
|
|
|
|
using Content.Shared.Inventory.Events;
|
2024-09-21 18:09:12 +03:00
|
|
|
|
2024-09-25 23:11:01 +03:00
|
|
|
namespace Content.Shared._White._Engi.DamageableClothing;
|
2024-09-21 17:10:02 +03:00
|
|
|
|
2024-09-21 18:09:12 +03:00
|
|
|
/// <summary>
|
2024-11-24 21:44:35 +03:00
|
|
|
/// WD
|
2024-09-21 18:09:12 +03:00
|
|
|
/// </summary>
|
2024-09-21 17:10:02 +03:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|