2023-09-27 16:41:07 -07:00
|
|
|
using Content.Shared.Morgue.Components;
|
2022-10-23 00:46:28 +02:00
|
|
|
using Content.Shared.Standing;
|
2023-02-11 20:12:29 -05:00
|
|
|
using Content.Shared.Storage.Components;
|
2022-07-13 19:11:59 -04:00
|
|
|
|
2023-09-27 16:41:07 -07:00
|
|
|
namespace Content.Shared.Morgue;
|
2022-07-13 19:11:59 -04:00
|
|
|
|
|
|
|
|
public sealed class EntityStorageLayingDownOverrideSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
[Dependency] private readonly StandingStateSystem _standing = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<EntityStorageLayingDownOverrideComponent, StorageBeforeCloseEvent>(OnBeforeClose);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-11 20:12:29 -05:00
|
|
|
private void OnBeforeClose(EntityUid uid, EntityStorageLayingDownOverrideComponent component, ref StorageBeforeCloseEvent args)
|
2022-07-13 19:11:59 -04:00
|
|
|
{
|
|
|
|
|
foreach (var ent in args.Contents)
|
2023-02-11 20:12:29 -05:00
|
|
|
{
|
2025-08-06 15:01:20 -04:00
|
|
|
// Explicitly check for standing state component, as entities without it will return false for IsDown()
|
|
|
|
|
// which prevents inserting any kind of non-mobs into this container (which is unintended)
|
2025-08-20 04:08:31 -07:00
|
|
|
if (TryComp<StandingStateComponent>(ent, out var standingState) && !_standing.IsDown((ent, standingState)))
|
2022-07-13 19:11:59 -04:00
|
|
|
args.Contents.Remove(ent);
|
2023-02-11 20:12:29 -05:00
|
|
|
}
|
2022-07-13 19:11:59 -04:00
|
|
|
}
|
|
|
|
|
}
|