using Content.Shared.Damage;
using Content.Shared.Hands;
using Robust.Shared.Containers;
namespace Content.Server.Mail.Systems;
///
/// A placeholder for another entity, spawned when taken out of a container, with the placeholder deleted shortly after.
/// Useful for storing instant effect entities, e.g. smoke, in the mail.
///
public sealed class DelayedItemSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnDropAttempt);
SubscribeLocalEvent(OnHandEquipped);
SubscribeLocalEvent(OnDamageChanged);
SubscribeLocalEvent(OnRemovedFromContainer);
}
private void OnRemovedFromContainer(EntityUid uid, Components.DelayedItemComponent component, ContainerModifiedMessage args)
{
Spawn(component.Item, Transform(uid).Coordinates);
}
private void OnHandEquipped(EntityUid uid, Components.DelayedItemComponent component, EquippedHandEvent args)
{
EntityManager.DeleteEntity(uid);
}
private void OnDropAttempt(EntityUid uid, Components.DelayedItemComponent component, DropAttemptEvent args)
{
EntityManager.DeleteEntity(uid);
}
private void OnDamageChanged(EntityUid uid, Components.DelayedItemComponent component, DamageChangedEvent args)
{
Spawn(component.Item, Transform(uid).Coordinates);
EntityManager.DeleteEntity(uid);
}
}