* Grid Inventory * oh boy we keep cracking on * auto insertion is kinda working? gross, too! * pieces and proper layouts * fix the sprites * mousing over grid pieces... finally * dragging deez nuts all over the screen * eek! * dragging is 90% less horrendous * auto-rotating * flatten * Rotation at last * fix rotation and change keybind for removing items. * rebinding and keybinding * wow! look at that! configurable with a button! cool! * dragging is a bit cooler, eh? * hover insert, my beloved * add some grids for storage, fix 1x1 storages, fix multiple inputs at once * el navigation * oh yeah some stuff i forgor * more fixes and QOL stuff * the griddening * the last of it (yippee) * sloth review :)
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using Robust.Shared.Containers;
|
|
|
|
using Content.Shared.Item;
|
|
using Content.Shared.Storage;
|
|
using Content.Shared.Storage.EntitySystems;
|
|
using Content.Shared.Toggleable;
|
|
|
|
namespace Content.Shared.ContainerHeld;
|
|
|
|
public sealed class ContainerHeldSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedItemSystem _item = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SharedStorageSystem _storage = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ContainerHeldComponent, EntInsertedIntoContainerMessage>(OnContainerModified);
|
|
SubscribeLocalEvent<ContainerHeldComponent, EntRemovedFromContainerMessage>(OnContainerModified);
|
|
}
|
|
|
|
private void OnContainerModified(EntityUid uid, ContainerHeldComponent comp, ContainerModifiedMessage args)
|
|
{
|
|
if (!(TryComp<StorageComponent>(uid, out var storage)
|
|
&& TryComp<AppearanceComponent>(uid, out var appearance)
|
|
&& TryComp<ItemComponent>(uid, out var item)))
|
|
{
|
|
return;
|
|
}
|
|
if (_storage.GetCumulativeItemAreas(uid) >= comp.Threshold)
|
|
{
|
|
_item.SetHeldPrefix(uid, "full", item);
|
|
_appearance.SetData(uid, ToggleVisuals.Toggled, true, appearance);
|
|
}
|
|
else
|
|
{
|
|
_item.SetHeldPrefix(uid, "empty", item);
|
|
_appearance.SetData(uid, ToggleVisuals.Toggled, false, appearance);
|
|
}
|
|
}
|
|
}
|