Predict StorageComponent (#19682)

This commit is contained in:
metalgearsloth
2023-09-11 21:20:46 +10:00
committed by GitHub
parent 99b77bc2d3
commit d5bd1c6f86
68 changed files with 1124 additions and 1121 deletions

View File

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