Skip to content

📦 Character

Character-facing components that provide access to inventory containers for a GameObject.

This folder contains convenience wrappers, not core inventory logic. Containers are owned and managed by the inventory service.


🎯 Purpose

Provide a per-entity access layer for interacting with inventory containers.


🧩 What Lives Here

CharacterInventory

A convenience MonoBehaviour that binds a single container to a GameObject.

Typical usage:

  • Binds a named container (default "Backpack")
  • Resolves containers through the inventory service
  • Caches the resolved container for reuse

⚠️ Important Notes

  • Containers are not created or owned by this component
  • Container lifecycle and orchestration are handled by the inventory service
  • Direct mutation through this component bypasses authority checks

🧠 Usage Guidance

Service-bound container

Containers are resolved through the inventory service.

This component does not create or manage container instances.


Lazy binding

  • Binding occurs on first access or enable
  • Resolution may retry if the service is not yet available
  • Resolved containers are cached

Read surface

Provides read access to container state:

  • Capacity
  • Slots
  • Peek(index)

These mirror the underlying container without exposing mutation internals.


Direct mutation

Mutation methods forward directly to the container:

  • TryAdd
  • TryAddAllResult
  • AddMaxResult
  • TryRemoveResult
  • TryRemoveFromSlotResult
  • TrySplitResult
  • TryMergeSlotsResult
  • TrySwapSlotsResult
  • TryMergeThenSwapResult

These operations do not consult authority.

Use the inventory service when authority enforcement is required.


Change events

OnChanged forwards container-level change events.

Event behaviour depends on the underlying container implementation.


Inspector view

Provides a read-only runtime view of container state for debugging.


🚫 Not for Production Use

This folder does not:

  • Own container lifecycle
  • Enforce authority
  • Provide service-level deltas
  • Replace the inventory service API

Use the inventory service for authoritative or system-level logic.