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

@@ -3,7 +3,6 @@ using System.Linq;
using Content.Server.Chemistry.Components;
using Content.Server.Labels;
using Content.Server.Popups;
using Content.Server.Storage.Components;
using Content.Server.Storage.EntitySystems;
using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry;
@@ -12,6 +11,7 @@ using Content.Shared.Chemistry.Reagent;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Storage;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -174,8 +174,8 @@ namespace Content.Server.Chemistry.EntitySystems
var user = message.Session.AttachedEntity;
var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster.Owner, SharedChemMaster.OutputSlotName);
if (maybeContainer is not { Valid: true } container
|| !TryComp(container, out ServerStorageComponent? storage)
|| storage.Storage is null)
|| !TryComp(container, out StorageComponent? storage)
|| storage.Container is null)
{
return; // output can't fit pills
}
@@ -201,7 +201,7 @@ namespace Content.Server.Chemistry.EntitySystems
for (var i = 0; i < message.Number; i++)
{
var item = Spawn(PillPrototypeId, Transform(container).Coordinates);
_storageSystem.Insert(container, item, storage);
_storageSystem.Insert(container, item, user, storage);
_labelSystem.Label(item, message.Label);
var itemSolution = _solutionContainerSystem.EnsureSolution(item, SharedChemMaster.PillSolutionName);
@@ -340,10 +340,10 @@ namespace Content.Server.Chemistry.EntitySystems
}
}
if (!TryComp(container, out ServerStorageComponent? storage))
if (!TryComp(container, out StorageComponent? storage))
return null;
var pills = storage.Storage?.ContainedEntities.Select((Func<EntityUid, (string, FixedPoint2 quantity)>) (pill =>
var pills = storage.Container?.ContainedEntities.Select((Func<EntityUid, (string, FixedPoint2 quantity)>) (pill =>
{
_solutionContainerSystem.TryGetSolution(pill, SharedChemMaster.PillSolutionName, out var solution);
var quantity = solution?.Volume ?? FixedPoint2.Zero;