fixed plant bag double dump problem (#10188)
Co-authored-by: fooberticus <fooberticus@protonmail.com>
This commit is contained in:
committed by
GitHub
parent
564f6cc40c
commit
fafd541349
@@ -42,9 +42,9 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
if (HasComp<DisposalUnitComponent>(args.Target) || HasComp<PlaceableSurfaceComponent>(args.Target))
|
if (HasComp<DisposalUnitComponent>(args.Target) || HasComp<PlaceableSurfaceComponent>(args.Target))
|
||||||
{
|
{
|
||||||
StartDoAfter(uid, args.Target.Value, args.User, component, storage);
|
StartDoAfter(uid, args.Target.Value, args.User, component, storage);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddDumpVerb(EntityUid uid, DumpableComponent dumpable, GetVerbsEvent<AlternativeVerb> args)
|
private void AddDumpVerb(EntityUid uid, DumpableComponent dumpable, GetVerbsEvent<AlternativeVerb> args)
|
||||||
{
|
{
|
||||||
if (!args.CanAccess || !args.CanInteract)
|
if (!args.CanAccess || !args.CanInteract)
|
||||||
@@ -105,11 +105,7 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
public void StartDoAfter(EntityUid storageUid, EntityUid? targetUid, EntityUid userUid, DumpableComponent dumpable, ServerStorageComponent storage, float multiplier = 1)
|
public void StartDoAfter(EntityUid storageUid, EntityUid? targetUid, EntityUid userUid, DumpableComponent dumpable, ServerStorageComponent storage, float multiplier = 1)
|
||||||
{
|
{
|
||||||
if (dumpable.CancelToken != null)
|
if (dumpable.CancelToken != null)
|
||||||
{
|
|
||||||
dumpable.CancelToken.Cancel();
|
|
||||||
dumpable.CancelToken = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (storage.StoredEntities == null)
|
if (storage.StoredEntities == null)
|
||||||
return;
|
return;
|
||||||
@@ -119,7 +115,7 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
dumpable.CancelToken = new CancellationTokenSource();
|
dumpable.CancelToken = new CancellationTokenSource();
|
||||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(userUid, delay, dumpable.CancelToken.Token, target: targetUid)
|
_doAfterSystem.DoAfter(new DoAfterEventArgs(userUid, delay, dumpable.CancelToken.Token, target: targetUid)
|
||||||
{
|
{
|
||||||
BroadcastFinishedEvent = new DumpCompletedEvent(userUid, targetUid, storage.StoredEntities),
|
BroadcastFinishedEvent = new DumpCompletedEvent(dumpable, userUid, targetUid, storage.StoredEntities),
|
||||||
BroadcastCancelledEvent = new DumpCancelledEvent(dumpable.Owner),
|
BroadcastCancelledEvent = new DumpCancelledEvent(dumpable.Owner),
|
||||||
BreakOnTargetMove = true,
|
BreakOnTargetMove = true,
|
||||||
BreakOnUserMove = true,
|
BreakOnUserMove = true,
|
||||||
@@ -131,6 +127,8 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
|
|
||||||
private void OnDumpCompleted(DumpCompletedEvent args)
|
private void OnDumpCompleted(DumpCompletedEvent args)
|
||||||
{
|
{
|
||||||
|
args.Component.CancelToken = null;
|
||||||
|
|
||||||
Queue<EntityUid> dumpQueue = new();
|
Queue<EntityUid> dumpQueue = new();
|
||||||
foreach (var entity in args.StoredEntities)
|
foreach (var entity in args.StoredEntities)
|
||||||
{
|
{
|
||||||
@@ -160,7 +158,6 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
{
|
{
|
||||||
Transform(entity).LocalPosition = Transform(args.Target.Value).LocalPosition + _random.NextVector2Box() / 4;
|
Transform(entity).LocalPosition = Transform(args.Target.Value).LocalPosition + _random.NextVector2Box() / 4;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,12 +178,14 @@ namespace Content.Server.Storage.EntitySystems
|
|||||||
|
|
||||||
private sealed class DumpCompletedEvent : EntityEventArgs
|
private sealed class DumpCompletedEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
|
public DumpableComponent Component { get; }
|
||||||
public EntityUid User { get; }
|
public EntityUid User { get; }
|
||||||
public EntityUid? Target { get; }
|
public EntityUid? Target { get; }
|
||||||
public IReadOnlyList<EntityUid> StoredEntities { get; }
|
public IReadOnlyList<EntityUid> StoredEntities { get; }
|
||||||
|
|
||||||
public DumpCompletedEvent(EntityUid user, EntityUid? target, IReadOnlyList<EntityUid> storedEntities)
|
public DumpCompletedEvent(DumpableComponent component, EntityUid user, EntityUid? target, IReadOnlyList<EntityUid> storedEntities)
|
||||||
{
|
{
|
||||||
|
Component = component;
|
||||||
User = user;
|
User = user;
|
||||||
Target = target;
|
Target = target;
|
||||||
StoredEntities = storedEntities;
|
StoredEntities = storedEntities;
|
||||||
|
|||||||
Reference in New Issue
Block a user