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,8 +1,8 @@
using System.Linq;
using System.Numerics;
using Content.Server.Popups;
using Content.Server.Pulling;
using Content.Server.Stack;
using Content.Server.Storage.Components;
using Content.Server.Storage.EntitySystems;
using Content.Server.Stunnable;
using Content.Shared.ActionBlocker;
@@ -16,6 +16,7 @@ using Content.Shared.Inventory;
using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components;
using Content.Shared.Stacks;
using Content.Shared.Storage;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Server.Player;
@@ -30,8 +31,7 @@ using Robust.Shared.Utility;
namespace Content.Server.Hands.Systems
{
[UsedImplicitly]
internal sealed class HandsSystem : SharedHandsSystem
public sealed class HandsSystem : SharedHandsSystem
{
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly StackSystem _stackSystem = default!;
@@ -252,7 +252,7 @@ namespace Content.Server.Hands.Systems
return;
if (!_inventorySystem.TryGetSlotEntity(plyEnt, equipmentSlot, out var slotEntity) ||
!TryComp(slotEntity, out ServerStorageComponent? storageComponent))
!TryComp(slotEntity, out StorageComponent? storageComponent))
{
if (_inventorySystem.HasSlot(plyEnt, equipmentSlot))
{
@@ -287,16 +287,17 @@ namespace Content.Server.Hands.Systems
{
_storageSystem.PlayerInsertHeldEntity(slotEntity.Value, plyEnt, storageComponent);
}
else if (storageComponent.StoredEntities != null)
else
{
if (storageComponent.StoredEntities.Count == 0)
if (!storageComponent.Container.ContainedEntities.Any())
{
_popupSystem.PopupEntity(Loc.GetString("hands-system-empty-equipment-slot", ("slotName", equipmentSlot)), plyEnt, session);
}
else
{
var lastStoredEntity = storageComponent.StoredEntities[^1];
if (storageComponent.Remove(lastStoredEntity))
var lastStoredEntity = storageComponent.Container.ContainedEntities[^1];
if (storageComponent.Container.Remove(lastStoredEntity))
{
PickupOrDrop(plyEnt, lastStoredEntity, animateUser: true, handsComp: hands);
}