Remove IDestroyAct, IBreakAct (#7876)
This commit is contained in:
40
Content.Server/Storage/EntitySystems/EntityStorageSystem.cs
Normal file
40
Content.Server/Storage/EntitySystems/EntityStorageSystem.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Destructible;
|
||||
using Robust.Shared.Physics;
|
||||
|
||||
namespace Content.Server.Storage.EntitySystems;
|
||||
|
||||
public sealed class EntityStorageSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestroy);
|
||||
}
|
||||
|
||||
private void OnDestroy(EntityUid uid, EntityStorageComponent component, DestructionEventArgs args)
|
||||
{
|
||||
component.Open = true;
|
||||
EmptyContents(uid, component);
|
||||
}
|
||||
|
||||
public void EmptyContents(EntityUid uid, EntityStorageComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
var containedArr = component.Contents.ContainedEntities.ToArray();
|
||||
foreach (var contained in containedArr)
|
||||
{
|
||||
if (component.Contents.Remove(contained))
|
||||
{
|
||||
Transform(contained).WorldPosition = component.ContentsDumpPosition();
|
||||
if (TryComp(contained, out IPhysBody? physics))
|
||||
{
|
||||
physics.CanCollide = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Item;
|
||||
|
||||
@@ -17,7 +17,6 @@ using Robust.Shared.Utility;
|
||||
using System.Threading;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Placeable;
|
||||
@@ -28,6 +27,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Server.Containers;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Destructible;
|
||||
using static Content.Shared.Storage.SharedStorageComponent;
|
||||
|
||||
namespace Content.Server.Storage.EntitySystems
|
||||
|
||||
Reference in New Issue
Block a user