* Fixes #4114 Disposals now drop their contents if destroyed or if unwrenched * Update DisposalUnitSystem.cs * Update DisposalUnitSystem.cs
This commit is contained in:
@@ -14,6 +14,7 @@ using Content.Server.Interfaces;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.DragDrop;
|
||||
@@ -42,7 +43,7 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
[ComponentReference(typeof(SharedDisposalUnitComponent))]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(IInteractUsing))]
|
||||
public class DisposalUnitComponent : SharedDisposalUnitComponent, IInteractHand, IActivate, IInteractUsing, IThrowCollide, IGasMixtureHolder
|
||||
public class DisposalUnitComponent : SharedDisposalUnitComponent, IInteractHand, IActivate, IInteractUsing, IThrowCollide, IGasMixtureHolder, IDestroyAct
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
@@ -304,7 +305,7 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
private void TryEjectContents()
|
||||
public void TryEjectContents()
|
||||
{
|
||||
foreach (var entity in _container.ContainedEntities.ToArray())
|
||||
{
|
||||
@@ -690,5 +691,10 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
component.TryFlush();
|
||||
}
|
||||
}
|
||||
|
||||
void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs)
|
||||
{
|
||||
TryEjectContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.Construction.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
@@ -9,15 +10,19 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DisposalUnitComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, AnchoredEvent>(OnAnchored);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, UnanchoredEvent>(OnUnanchored);
|
||||
}
|
||||
|
||||
private static void BodyTypeChanged(
|
||||
EntityUid uid,
|
||||
DisposalUnitComponent component,
|
||||
PhysicsBodyTypeChangedEvent args)
|
||||
private static void OnAnchored(EntityUid uid, DisposalUnitComponent component, AnchoredEvent args)
|
||||
{
|
||||
component.UpdateVisualState();
|
||||
}
|
||||
|
||||
private static void OnUnanchored(EntityUid uid, DisposalUnitComponent component, UnanchoredEvent args)
|
||||
{
|
||||
component.UpdateVisualState();
|
||||
component.TryEjectContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user