Storage Component ECS (#7530)

Co-authored-by: fishfish458 <fishfish458>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Fishfish458
2022-04-28 06:11:15 -06:00
committed by GitHub
parent f403311641
commit 4c9e45a480
38 changed files with 892 additions and 1163 deletions

View File

@@ -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);