Predict StorageComponent (#19682)
This commit is contained in:
@@ -2,7 +2,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Construction;
|
||||
@@ -30,7 +29,6 @@ namespace Content.Server.Construction
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
|
||||
[Dependency] private readonly StorageSystem _storageSystem = default!;
|
||||
|
||||
// --- WARNING! LEGACY CODE AHEAD! ---
|
||||
// This entire file contains the legacy code for initial construction.
|
||||
@@ -51,9 +49,9 @@ namespace Content.Server.Construction
|
||||
{
|
||||
foreach (var item in _handsSystem.EnumerateHeld(user))
|
||||
{
|
||||
if (TryComp(item, out ServerStorageComponent? storage))
|
||||
if (TryComp(item, out StorageComponent? storage))
|
||||
{
|
||||
foreach (var storedEntity in storage.StoredEntities!)
|
||||
foreach (var storedEntity in storage.Container.ContainedEntities!)
|
||||
{
|
||||
yield return storedEntity;
|
||||
}
|
||||
@@ -66,10 +64,12 @@ namespace Content.Server.Construction
|
||||
{
|
||||
while (containerSlotEnumerator.MoveNext(out var containerSlot))
|
||||
{
|
||||
if(!containerSlot.ContainedEntity.HasValue) continue;
|
||||
if (EntityManager.TryGetComponent(containerSlot.ContainedEntity.Value, out ServerStorageComponent? storage))
|
||||
if(!containerSlot.ContainedEntity.HasValue)
|
||||
continue;
|
||||
|
||||
if (EntityManager.TryGetComponent(containerSlot.ContainedEntity.Value, out StorageComponent? storage))
|
||||
{
|
||||
foreach (var storedEntity in storage.StoredEntities!)
|
||||
foreach (var storedEntity in storage.Container.ContainedEntities)
|
||||
{
|
||||
yield return storedEntity;
|
||||
}
|
||||
@@ -207,12 +207,9 @@ namespace Content.Server.Construction
|
||||
continue;
|
||||
|
||||
// Dump out any stored entities in used entity
|
||||
if (TryComp<ServerStorageComponent>(entity, out var storage) && storage.StoredEntities != null)
|
||||
if (TryComp<StorageComponent>(entity, out var storage))
|
||||
{
|
||||
foreach (var storedEntity in storage.StoredEntities.ToList())
|
||||
{
|
||||
_storageSystem.RemoveAndDrop(entity, storedEntity, storage);
|
||||
}
|
||||
_container.EmptyContainer(storage.Container);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(arbitraryStep.Store))
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Server.Storage.EntitySystems;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Exchanger;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.Wires;
|
||||
@@ -41,13 +41,13 @@ public sealed class PartExchangerSystem : EntitySystem
|
||||
if (args.Handled || args.Args.Target == null)
|
||||
return;
|
||||
|
||||
if (!TryComp<ServerStorageComponent>(uid, out var storage) || storage.Storage == null)
|
||||
if (!TryComp<StorageComponent>(uid, out var storage) || storage.Container == null)
|
||||
return; //the parts are stored in here
|
||||
|
||||
var machinePartQuery = GetEntityQuery<MachinePartComponent>();
|
||||
var machineParts = new List<(EntityUid, MachinePartComponent)>();
|
||||
|
||||
foreach (var item in storage.Storage.ContainedEntities) //get parts in RPED
|
||||
foreach (var item in storage.Container.ContainedEntities) //get parts in RPED
|
||||
{
|
||||
if (machinePartQuery.TryGetComponent(item, out var part))
|
||||
machineParts.Add((item, part));
|
||||
@@ -96,7 +96,7 @@ public sealed class PartExchangerSystem : EntitySystem
|
||||
//put the unused parts back into rped. (this also does the "swapping")
|
||||
foreach (var (unused, _) in machineParts)
|
||||
{
|
||||
_storage.Insert(storageUid, unused, null, false);
|
||||
_storage.Insert(storageUid, unused, playSound: false);
|
||||
}
|
||||
_construction.RefreshParts(uid, machine);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public sealed class PartExchangerSystem : EntitySystem
|
||||
//put the unused parts back into rped. (this also does the "swapping")
|
||||
foreach (var (unused, _) in machineParts)
|
||||
{
|
||||
_storage.Insert(storageEnt, unused, null, false);
|
||||
_storage.Insert(storageEnt, unused, playSound: false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user