EntityStorage ECS (#9291)

This commit is contained in:
Nemanja
2022-07-13 19:11:59 -04:00
committed by GitHub
parent a655891a8d
commit 5edf2ccad5
46 changed files with 1057 additions and 1126 deletions

View File

@@ -8,10 +8,12 @@ public sealed partial class StorageSystem
private void OnStorageFillMapInit(EntityUid uid, StorageFillComponent component, MapInitEvent args)
{
if (component.Contents.Count == 0) return;
// ServerStorageComponent needs to rejoin IStorageComponent when other storage components are ECS'd
TryComp<IStorageComponent>(uid, out var storage);
if (!EntityManager.EntitySysManager.TryGetEntitySystem<EntityStorageSystem>(out var entityStorage)) return;
TryComp<ServerStorageComponent>(uid, out var serverStorageComp);
if (storage == null && serverStorageComp == null)
TryComp<EntityStorageComponent>(uid, out var entityStorageComp);
if (entityStorageComp == null && serverStorageComp == null)
{
Logger.Error($"StorageFillComponent couldn't find any StorageComponent ({uid})");
return;
@@ -25,7 +27,7 @@ public sealed partial class StorageSystem
var ent = EntityManager.SpawnEntity(item, coordinates);
// handle depending on storage component, again this should be unified after ECS
if (storage != null && storage.Insert(ent))
if (entityStorageComp != null && entityStorage.Insert(ent, uid))
continue;
if (serverStorageComp != null && Insert(uid, ent, serverStorageComp))