Predict StorageComponent (#19682)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Storage;
|
||||
using Content.Shared.Storage.Components;
|
||||
|
||||
namespace Content.Server.Storage.EntitySystems;
|
||||
|
||||
@@ -7,32 +8,33 @@ public sealed partial class StorageSystem
|
||||
{
|
||||
private void OnStorageFillMapInit(EntityUid uid, StorageFillComponent component, MapInitEvent args)
|
||||
{
|
||||
if (component.Contents.Count == 0) return;
|
||||
if (component.Contents.Count == 0)
|
||||
return;
|
||||
|
||||
TryComp<ServerStorageComponent>(uid, out var serverStorageComp);
|
||||
TryComp<StorageComponent>(uid, out var storageComp);
|
||||
TryComp<EntityStorageComponent>(uid, out var entityStorageComp);
|
||||
|
||||
if (entityStorageComp == null && serverStorageComp == null)
|
||||
if (entityStorageComp == null && storageComp == null)
|
||||
{
|
||||
Logger.Error($"StorageFillComponent couldn't find any StorageComponent ({uid})");
|
||||
Log.Error($"StorageFillComponent couldn't find any StorageComponent ({uid})");
|
||||
return;
|
||||
}
|
||||
|
||||
var coordinates = Transform(uid).Coordinates;
|
||||
|
||||
var spawnItems = EntitySpawnCollection.GetSpawns(component.Contents, _random);
|
||||
var spawnItems = EntitySpawnCollection.GetSpawns(component.Contents, Random);
|
||||
foreach (var item in spawnItems)
|
||||
{
|
||||
var ent = EntityManager.SpawnEntity(item, coordinates);
|
||||
|
||||
// handle depending on storage component, again this should be unified after ECS
|
||||
if (entityStorageComp != null && _entityStorage.Insert(ent, uid))
|
||||
continue;
|
||||
|
||||
if (serverStorageComp != null && Insert(uid, ent, serverStorageComp, false))
|
||||
if (entityStorageComp != null && EntityStorage.Insert(ent, uid))
|
||||
continue;
|
||||
|
||||
Logger.ErrorS("storage", $"Tried to StorageFill {item} inside {ToPrettyString(uid)} but can't.");
|
||||
if (storageComp != null && Insert(uid, ent, storageComp: storageComp, playSound: false))
|
||||
continue;
|
||||
|
||||
Log.Error($"Tried to StorageFill {item} inside {ToPrettyString(uid)} but can't.");
|
||||
EntityManager.DeleteEntity(ent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user