03 — Search & Sort¶
Goal¶
Learn how to find and order inventory items through the service, then display the result in a live container grid.
What This Scene Demonstrates¶
The core discovery and ordering flow:
Seed items → sort/search request → service result or search hits → live grid view
Seed and sort mutate through SceneInventoryService.
Search reads through SceneInventoryService.
The panel only displays the returned outcomes.
Search and sort rules belong to the service, not the UI layer.
What To Look For¶
- Seed Items uses
GiveExact(...)to add varied items through the service - Sort builds an
InventorySortSpecand callsSort(...) - Sort keys shown in the panel are Name, Rarity, Category, and Qty
- Asc / Desc changes sort direction
- Empty → End / Empty → Mix changes how empty slots are handled
- Search calls
Search(...)with the current query - Search hits are returned as slot indices and highlighted in the grid
- Clear removes highlights without changing inventory contents
- Backpack reads the live container through
Get(...)
Sort operations report through Last Result using InvOpResult. Search operations report through a Search Summary.
Sample Scope¶
This scene focuses only on:
- Seeding varied items
- Sorting the live container
- Searching the live container
- Highlighting returned search slot indices
- Inspecting the refreshed backpack grid
This scene does NOT cover:
- Stack splitting or merging
- Equipment integration
- Transfers between owners
- Snapshots
- Production inventory UI
- Networking or replication
Those behaviours belong in dedicated teachable scenes or project-specific implementations.
Authority Note¶
This scene may include a permissive sample authority setup. If no authority is resolved, mutations are allowed for demonstration purposes.
Networking Reminder¶
No networking is included. Multiplayer authority and synchronization are the developer’s responsibility.
How To Use¶
- Assign varied ItemDefinitions in Quick Items
- Press Give in Seed Items to populate the backpack
- Choose a sort key in Sort: Name, Rarity, Category, or Qty
- Toggle Asc / Desc if needed
- Toggle Empty → End / Empty → Mix if needed
- Press Apply Sort
- Inspect the updated order in Backpack
- Type a query in Search
- Press Find, or let the query field trigger search while editing
- Read the highlighted slots in Backpack
- Press Clear to remove search highlights
- Check Last Result or Search Summary for the latest outcome
Failure Behaviour¶
Failures and empty outcomes are surfaced through InvOpResult, Search Summary, or live feedback.
Common patterns:
-
Give fails → item assignment, container setup, capacity, filters, or authority → Check the assigned ItemDefinition, container id, available space, filters, or authority setup
-
Sort fails → container id, service setup, authority, or sort support issue → Check the container id, service assignment, authority setup, and selected sort configuration
-
Search query is empty → highlights are cleared → Type a query, then press Find
-
Search returns zero hits → no matching slots were returned by the service → Try another item name, category, or tag
-
No Inventory View → the panel cannot read the configured container → Check that
CharacterInventoryhas the configured container id
The panel does not duplicate search or sort rules. It shows what the service returns.
Behind The Scenes¶
This panel uses only public service APIs and public data types:
SceneInventoryService.GiveExact(...)SceneInventoryService.Sort(...)SceneInventoryService.Search(...)SceneInventoryService.Get(...)InventorySortSpecInventorySortKeyIReadOnlyInventoryContainerItemStackContainerIdInvOpResult
Sort mutates through the service. Search returns matching slot indices. The grid remains a viewer and highlighter.
Key Takeaway¶
Discovery belongs behind the service seam. The UI sends seed, sort, and search requests. The service applies the rules and returns results or hits. The panel displays those outcomes without inventing its own logic.