Skip to content

Add Stackable component for item stacking#1512

Closed
JakubIwicki wants to merge 2 commits into
RE-SS3D:developfrom
JakubIwicki:fix/1258-stacking-items
Closed

Add Stackable component for item stacking#1512
JakubIwicki wants to merge 2 commits into
RE-SS3D:developfrom
JakubIwicki:fix/1258-stacking-items

Conversation

@JakubIwicki

Copy link
Copy Markdown

Closes #1258

Items of the same type now stack together in containers. A Stackable component tracks max stack size and current count, and same-type items merge automatically when stored or dropped near each other.

Changes

  • Stackable.cs — new component with SyncVar'd maxStack/amountInStack, overflow handling, type matching, visual copy toggling, and examine integration
  • Item.cs — added IsStackable property
  • AttachedContainer.cs — TryStackWithExisting merges incoming items into existing stacks during AddItem; fully-consumed items are despawned
  • Hand.cs — TryStackWithNearbyItem merges dropped items with nearby same-type stacks in world space
  • SingleItemContainerSlot.cs — stack count label displayed on container slot UI
  • ExamineUI.cs — examine hover text shows current stack count
  • StackableTests.cs — 21 edit mode tests covering stacking, overflow, type matching, and edge cases

Verification

  • Stackable_IsNotStackableOnRegularItem: IsStackable returns false without Stackable component
  • Stackable_CanAddToStack_WhenUnderMax_ReturnsTrue: capacity check works
  • Stackable_AddToStack_ReturnsOverflow: overflow correctly returned
  • Stackable_RemoveFromStack_DecreasesCount: removal works
  • Stackable_IsFull_WhenAtMax: full detection
  • Container_MergeSameTypeStacks: items of same type merge in container
  • Stackable_RemoveFromStack_WhenRequestingZero_ReturnsZero: edge case documented
  • Container_PartialStack_UpdatesIncomingItemAmount: partial consumption preserves remainder

- Uncomment and complete Stackable.cs with SyncVar'd maxStack/amountInStack
- Add IsStackable property to Item.cs
- Add TryStackWithExisting to AttachedContainer for stack merging
- Add world-space drop stacking via TryStackWithNearbyItem in Hand.cs
- Add UI stack count display in SingleItemContainerSlot
- Add examine hover text showing stack count in ExamineUI
- Add 21 edit mode tests covering stacking logic
- Add [Server] guards on all stack mutators
- Ghost items properly despawned on full consumption

Closes RE-SS3D#1258
@Alainx277

Copy link
Copy Markdown
Collaborator

PRs by AI agents are not allowed

@Alainx277 Alainx277 closed this Jun 6, 2026
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

2 participants