Predict StorageComponent (#19682)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Light.Components;
|
||||
@@ -101,7 +100,7 @@ public sealed class LightReplacerSystem : EntitySystem
|
||||
if (TryComp<LightBulbComponent>(usedUid, out var bulb))
|
||||
eventArgs.Handled = TryInsertBulb(uid, usedUid, eventArgs.User, true, component, bulb);
|
||||
// add bulbs from storage?
|
||||
else if (TryComp<ServerStorageComponent>(usedUid, out var storage))
|
||||
else if (TryComp<StorageComponent>(usedUid, out var storage))
|
||||
eventArgs.Handled = TryInsertBulbsFromStorage(uid, usedUid, eventArgs.User, component, storage);
|
||||
}
|
||||
|
||||
@@ -205,23 +204,23 @@ public sealed class LightReplacerSystem : EntitySystem
|
||||
/// which was successfully inserted inside light replacer
|
||||
/// </returns>
|
||||
public bool TryInsertBulbsFromStorage(EntityUid replacerUid, EntityUid storageUid, EntityUid? userUid = null,
|
||||
LightReplacerComponent? replacer = null, ServerStorageComponent? storage = null)
|
||||
LightReplacerComponent? replacer = null, StorageComponent? storage = null)
|
||||
{
|
||||
if (!Resolve(replacerUid, ref replacer))
|
||||
return false;
|
||||
if (!Resolve(storageUid, ref storage))
|
||||
return false;
|
||||
|
||||
if (storage.StoredEntities == null)
|
||||
return false;
|
||||
|
||||
var insertedBulbs = 0;
|
||||
var storagedEnts = storage.StoredEntities.ToArray();
|
||||
var storagedEnts = storage.Container.ContainedEntities.ToArray();
|
||||
|
||||
foreach (var ent in storagedEnts)
|
||||
{
|
||||
if (TryComp<LightBulbComponent>(ent, out var bulb) &&
|
||||
TryInsertBulb(replacerUid, ent, userUid, false, replacer, bulb))
|
||||
{
|
||||
insertedBulbs++;
|
||||
}
|
||||
}
|
||||
|
||||
// show some message if success
|
||||
|
||||
Reference in New Issue
Block a user