Dumpable component to use a doafter to empty storage into a disposal unit, placeable surface, or the ground (#7792)
This commit is contained in:
@@ -175,19 +175,6 @@ namespace Content.Server.Storage.EntitySystems
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
// if the target is a disposal unit, add a verb to transfer storage into the unit (e.g., empty a trash bag).
|
||||
if (!TryComp(args.Target, out DisposalUnitComponent? disposal))
|
||||
return;
|
||||
|
||||
UtilityVerb dispose = new()
|
||||
{
|
||||
Text = Loc.GetString("storage-component-dispose-verb"),
|
||||
IconEntity = args.Using,
|
||||
Act = () => DisposeEntities(args.User, uid, args.Target, component, lockComponent, disposal)
|
||||
};
|
||||
|
||||
args.Verbs.Add(dispose);
|
||||
}
|
||||
|
||||
|
||||
@@ -446,35 +433,6 @@ namespace Content.Server.Storage.EntitySystems
|
||||
UpdateStorageUI(source, sourceComp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move entities from storage into a disposal unit.
|
||||
/// </summary>
|
||||
public void DisposeEntities(EntityUid user, EntityUid source, EntityUid target,
|
||||
ServerStorageComponent? sourceComp = null, LockComponent? sourceLock = null,
|
||||
DisposalUnitComponent? disposalComp = null)
|
||||
{
|
||||
if (!Resolve(source, ref sourceComp) || !Resolve(target, ref disposalComp))
|
||||
return;
|
||||
|
||||
var entities = sourceComp.Storage?.ContainedEntities;
|
||||
if (entities == null || entities.Count == 0)
|
||||
return;
|
||||
|
||||
if (Resolve(source, ref sourceLock, false) && sourceLock.Locked)
|
||||
return;
|
||||
|
||||
foreach (var entity in entities.ToList())
|
||||
{
|
||||
if (_disposalSystem.CanInsert(disposalComp, entity)
|
||||
&& disposalComp.Container.Insert(entity))
|
||||
{
|
||||
_disposalSystem.AfterInsert(disposalComp, entity);
|
||||
}
|
||||
}
|
||||
RecalculateStorageUsed(sourceComp);
|
||||
UpdateStorageUI(source, sourceComp);
|
||||
}
|
||||
|
||||
public void HandleRemoveEntity(EntityUid uid, EntityUid player, EntityUid itemToRemove, ServerStorageComponent? storageComp = null)
|
||||
{
|
||||
if (!Resolve(uid, ref storageComp))
|
||||
|
||||
Reference in New Issue
Block a user