Predict StorageComponent (#19682)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Disposal;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Placeable;
|
||||
@@ -49,7 +49,7 @@ public sealed class DumpableSystem : EntitySystem
|
||||
if (!args.CanAccess || !args.CanInteract)
|
||||
return;
|
||||
|
||||
if (!TryComp<SharedStorageComponent>(uid, out var storage) || storage.StoredEntities == null || storage.StoredEntities.Count == 0)
|
||||
if (!TryComp<StorageComponent>(uid, out var storage) || !storage.Container.ContainedEntities.Any())
|
||||
return;
|
||||
|
||||
AlternativeVerb verb = new()
|
||||
@@ -69,7 +69,7 @@ public sealed class DumpableSystem : EntitySystem
|
||||
if (!args.CanAccess || !args.CanInteract)
|
||||
return;
|
||||
|
||||
if (!TryComp<SharedStorageComponent>(uid, out var storage) || storage.StoredEntities == null || storage.StoredEntities.Count == 0)
|
||||
if (!TryComp<StorageComponent>(uid, out var storage) || !storage.Container.ContainedEntities.Any())
|
||||
return;
|
||||
|
||||
if (_disposalUnitSystem.HasDisposals(args.Target))
|
||||
@@ -103,10 +103,10 @@ public sealed class DumpableSystem : EntitySystem
|
||||
|
||||
public void StartDoAfter(EntityUid storageUid, EntityUid? targetUid, EntityUid userUid, DumpableComponent dumpable)
|
||||
{
|
||||
if (!TryComp<SharedStorageComponent>(storageUid, out var storage) || storage.StoredEntities == null)
|
||||
if (!TryComp<StorageComponent>(storageUid, out var storage))
|
||||
return;
|
||||
|
||||
float delay = storage.StoredEntities.Count * (float) dumpable.DelayPerItem.TotalSeconds * dumpable.Multiplier;
|
||||
float delay = storage.Container.ContainedEntities.Count * (float) dumpable.DelayPerItem.TotalSeconds * dumpable.Multiplier;
|
||||
|
||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, userUid, delay, new DumpableDoAfterEvent(), storageUid, target: targetUid, used: storageUid)
|
||||
{
|
||||
@@ -118,11 +118,11 @@ public sealed class DumpableSystem : EntitySystem
|
||||
|
||||
private void OnDoAfter(EntityUid uid, DumpableComponent component, DoAfterEvent args)
|
||||
{
|
||||
if (args.Handled || args.Cancelled || !TryComp<SharedStorageComponent>(uid, out var storage) || storage.StoredEntities == null)
|
||||
if (args.Handled || args.Cancelled || !TryComp<StorageComponent>(uid, out var storage))
|
||||
return;
|
||||
|
||||
Queue<EntityUid> dumpQueue = new();
|
||||
foreach (var entity in storage.StoredEntities)
|
||||
foreach (var entity in storage.Container.ContainedEntities)
|
||||
{
|
||||
dumpQueue.Enqueue(entity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user