Skip to content

Feature/item stacking#1501

Open
worldreboot wants to merge 2 commits into
RE-SS3D:developfrom
worldreboot:feature/item-stacking
Open

Feature/item stacking#1501
worldreboot wants to merge 2 commits into
RE-SS3D:developfrom
worldreboot:feature/item-stacking

Conversation

@worldreboot
Copy link
Copy Markdown
Contributor

Summary

Adds stackable inventory items for containers, addressing #1258.

Each stackable item type can define its own per-slot stack limit. Stacked items keep their hidden
item instances in an internal stack container, support adding/removing items from the bundle, merge
when dropped onto matching stacks, and show stack counts in container UI.

This PR includes:

  • Stackable item logic with merge, split, and take-one support.
  • Container transfer support for stacking into compatible occupied slots.
  • Inventory UI stack count labels.
  • Toolbox/container stacking behavior for steel sheets.
  • A “Take one” interaction for stacks.
  • Tests for stack logic, container transfers, UI count updates, and multiplayer client stacking.

This PR does not broadly convert every stackable candidate item. Steel sheets are the initial
configured stackable item.

PR checklist

  • The game builds properly without errors.
  • No unrelated changes are present.
  • No "trash" files are committed.
  • Relevant code is documented.
  • Update the related GitBook document, or create a new one if needed.

Pictures/Videos

stacking.webm

Testing

Automated tests run:

  • Focused EditMode stacking suite passed:

    • EditorTests.StackableTests
    • EditorTests.ContainerTests
    • EditorTests.ItemDisplayTests
  • Multiplayer PlayMode test passed:

    • SS3D.Tests.ClientStackingActions.ClientCanStackSteelSheetsInsideToolbox

Manual/expected behavior to test:

  • Put a steel sheet into a toolbox.
  • Add another steel sheet to the same toolbox slot.
  • The toolbox UI should show stack count 2.
  • A hand should still only hold one item and should not become a stack.
  • Empty-hand click on a stack should take one item.
  • Dragging a matching steel sheet onto another steel sheet should stack.
  • Dragging an item to an empty slot should still move normally.
  • Reopen the toolbox and verify the UI still matches the container state.

Networking checklist

  • Works from host in host mode.
  • Works from server in server mode.
  • Works on server in client mode.
  • Works and is syncronized across different clients.
  • Is persistent.

Changes

Major changes:

  • Added Stackable support for item stacks using a hidden internal stack container.
  • Added per-item stack limits through the Stackable component.
  • Updated container transfer logic to merge compatible stackable items into occupied slots.
  • Prevented stacks from forming in hand containers.
  • Added take-one behavior for splitting one item from a stack.
  • Added stack count display support to inventory UI slots/grid items.
  • Configured SteelSheet.prefab as the first stackable item.
  • Added regression handling for:
    • source container removal restrictions during stack merge/take-one
    • newly spawned stack items merging into a full container with stack space
    • hidden items stored inside stacks staying hidden when the outer stack item is shown
    • rejected drag/drop restoring item display visibility/state

Test/support changes:

  • Added EditMode tests for stack merge/split behavior, container stacking transfers, and UI count
    labels.
  • Added a PlayMode multiplayer test for stacking steel sheets inside a toolbox.
  • Hardened PlayMode test cleanup so built test executables are cleaned up during test runs only.

Known notes:

  • Steel sheets are the only item configured as stackable in this PR.
  • Broader stackable item rollout should be handled separately.

Related issues/PRs

Closes #1258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stacking items

1 participant