Project Page

Networked Item & Inventory Architecture

Server-authoritative item system with pure C# data models, delta-synchronized containers, equipped-item controllers, and decoupled view models.

C#UnityNetworkingDistributed Systems

Inventory Overview

Key Highlights

  • Server-authoritative containers replicate only to players who have them open, not to every connected client
  • Predicted inventory slot interactions reconcile against version-stamped server state, with full-state correction on mismatch
  • First and third-person view models per item, with safe late-joiner recovery for active equipment

Networked Container Core

Container replication

  • Per-container observer list narrows replication to players who actually have the container open, keeping idle inventories off the wire
  • Two delta types — full item change and quantity-only change — keep snapshot payloads as small as the actual mutation
  • Rate-limited full-state requests stop a misbehaving or out-of-sync peer from flooding the server with resync calls

Predicted Slot Interactions

Predicted slot flow

  • Slot clicks (swap, stack-merge, split, shift-move) run locally on the client for instant feedback, then a Cmd carries the predicted container version to the server
  • Server accepts only commands stamped with the correct interaction id and a version that matches server + 1, rejecting stale or replayed inputs cleanly
  • Mismatched state triggers a single TargetRpc that resyncs both containers and the carried item in one full-state payload

Per-Instance Item Attributes

  • Attributes such as ammo, colors, and counters attach to individual item instances and sync through their own granular RPC, so the same item type can carry different runtime state without reserializing the slot
  • Active-item attributes broadcast to non-observer clients too, since visible state like tool color needs to render for spectators

Active Item & View Model Split

  • Owning client preemptively creates first and third-person view models when the active hotbar slot changes, so swapping reads as instant on the local screen
  • An equip-id version tag drops late-arriving server RPCs once the player has moved on, so stale view models can’t bind to a slot the player already left
  • Non-owning clients receive a third-person view model only, and late joiners reconstruct it from a resolvable reference embedded in the initial network state

Carried Item & World Conversion

  • Slot-to-slot moves use a transient cursor carried item; on disconnect or close, the server reinserts it or ejects it as a world pickup so items are never silently lost
  • Dropped world items carry their backing item through initial-state serialization, so late joiners see the correct contents the moment they spawn

Why This Matters

  • Delivers a complete server-authoritative replication story — observer scoping, version-stamped prediction, attribute-level granularity, late-join recovery — built on top of a transport rather than offloaded to one
  • Clean split between pure-C# item data, networked controllers, and presentation view models keeps the system extensible without hopping back to base classes per new item type
  • Same architecture supports stackable resources, ammo-bearing weapons, and tool-style items with no special-case code