[TEST MERGE] Slot-based Storage (#21212)

This commit is contained in:
Nemanja
2023-10-25 18:53:38 -04:00
committed by GitHub
parent 6b04aaf964
commit 41795720da
234 changed files with 1052 additions and 1008 deletions

View File

@@ -187,7 +187,7 @@ namespace Content.Server.Chemistry.EntitySystems
}
// Ensure the number is valid.
if (message.Number == 0 || message.Number > storage.StorageCapacityMax - storage.StorageUsed)
if (message.Number == 0 || _storageSystem.HasSpace((chemMaster, storage)))
return;
// Ensure the amount is valid.
@@ -345,7 +345,7 @@ namespace Content.Server.Chemistry.EntitySystems
}
}
if (!TryComp(container, out StorageComponent? storage))
if (!TryComp(container, out StorageComponent? storage) || storage.Container == null)
return null;
var pills = storage.Container?.ContainedEntities.Select((Func<EntityUid, (string, FixedPoint2 quantity)>) (pill =>
@@ -358,7 +358,7 @@ namespace Content.Server.Chemistry.EntitySystems
if (pills == null)
return null;
return new ContainerInfo(name, storage.StorageUsed, storage.StorageCapacityMax)
return new ContainerInfo(name, storage.Container!.ContainedEntities.Count, storage.MaxSlots)
{
Entities = pills
};

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Inventory;
@@ -122,7 +123,7 @@ public sealed class FoodSystem : EntitySystem
return (false, false);
// Check for used storage on the food item
if (TryComp<StorageComponent>(food, out var storageState) && storageState.StorageUsed != 0)
if (TryComp<StorageComponent>(food, out var storageState) && storageState.Container.ContainedEntities.Any())
{
_popup.PopupEntity(Loc.GetString("food-has-used-storage", ("food", food)), user, user);
return (false, true);

View File

@@ -19,7 +19,7 @@ namespace Content.Server.Storage.Components
/// Max item size that can be fitted into secret stash.
/// </summary>
[DataField("maxItemSize")]
public int MaxItemSize = (int) ReferenceSizes.Pocket;
public ItemSize MaxItemSize = ItemSize.Small;
/// <summary>
/// IC secret stash name. For example "the toilet cistern".

View File

@@ -1,7 +1,6 @@
using Content.Shared.Rounding;
using Content.Shared.Storage;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
namespace Content.Server.Storage.EntitySystems;
@@ -13,12 +12,12 @@ public sealed class StorageFillVisualizerSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StorageFillVisualizerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<StorageFillVisualizerComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<StorageFillVisualizerComponent, EntInsertedIntoContainerMessage>(OnInserted);
SubscribeLocalEvent<StorageFillVisualizerComponent, EntRemovedFromContainerMessage>(OnRemoved);
}
private void OnInit(EntityUid uid, StorageFillVisualizerComponent component, ComponentInit args)
private void OnStartup(EntityUid uid, StorageFillVisualizerComponent component, ComponentStartup args)
{
UpdateAppearance(uid, component: component);
}
@@ -42,7 +41,7 @@ public sealed class StorageFillVisualizerSystem : EntitySystem
if (component.MaxFillLevels < 1)
return;
var level = ContentHelpers.RoundToEqualLevels(storage.StorageUsed, storage.StorageCapacityMax, component.MaxFillLevels);
var level = ContentHelpers.RoundToEqualLevels(storage.Container.ContainedEntities.Count, storage.MaxSlots, component.MaxFillLevels);
_appearance.SetData(uid, StorageFillVisuals.FillLevel, level, appearance);
}
}

View File

@@ -98,7 +98,7 @@ public sealed class EnergySwordSystem : EntitySystem
{
if (TryComp(uid, out ItemComponent? item))
{
_item.SetSize(uid, 5, item);
_item.SetSize(uid, ItemSize.Small, item);
}
if (TryComp<DisarmMalusComponent>(uid, out var malus))
@@ -125,7 +125,7 @@ public sealed class EnergySwordSystem : EntitySystem
{
if (TryComp(uid, out ItemComponent? item))
{
_item.SetSize(uid, 9999, item);
_item.SetSize(uid, ItemSize.Huge, item);
}
if (comp.IsSharp)