Storage Component ECS (#7530)
Co-authored-by: fishfish458 <fishfish458> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using Content.Server.Storage.Components;
|
||||
using Robust.Shared.Random;
|
||||
using System.Linq;
|
||||
using Content.Shared.Storage;
|
||||
|
||||
namespace Content.Server.Storage.EntitySystems;
|
||||
@@ -10,8 +8,10 @@ public sealed partial class StorageSystem
|
||||
private void OnStorageFillMapInit(EntityUid uid, StorageFillComponent component, MapInitEvent args)
|
||||
{
|
||||
if (component.Contents.Count == 0) return;
|
||||
|
||||
if (!TryComp<IStorageComponent>(uid, out var storage))
|
||||
// ServerStorageComponent needs to rejoin IStorageComponent when other storage components are ECS'd
|
||||
TryComp<IStorageComponent>(uid, out var storage);
|
||||
TryComp<ServerStorageComponent>(uid, out var serverStorageComp);
|
||||
if (storage == null && serverStorageComp == null)
|
||||
{
|
||||
Logger.Error($"StorageFillComponent couldn't find any StorageComponent ({uid})");
|
||||
return;
|
||||
@@ -24,7 +24,12 @@ public sealed partial class StorageSystem
|
||||
{
|
||||
var ent = EntityManager.SpawnEntity(item, coordinates);
|
||||
|
||||
if (storage.Insert(ent)) continue;
|
||||
// handle depending on storage component, again this should be unified after ECS
|
||||
if (storage != null && storage.Insert(ent))
|
||||
continue;
|
||||
|
||||
if (serverStorageComp != null && Insert(uid, ent, serverStorageComp))
|
||||
continue;
|
||||
|
||||
Logger.ErrorS("storage", $"Tried to StorageFill {item} inside {uid} but can't.");
|
||||
EntityManager.DeleteEntity(ent);
|
||||
|
||||
Reference in New Issue
Block a user