# Sandbox.BaseInventoryItem

Base for anything that can live in an [Sandbox.BaseInventoryComponent](/api/Sandbox.BaseInventoryComponent). Handles the basics every
item needs - a networked slot, editor metadata, and overridable equip/holster lifecycle - so
deriving an item is almost no boilerplate. Usable as-is for a simple no-code pickup, or derive
from it for weapons, tools, etc.

- Kind: class
- Namespace: `Sandbox`
- Assembly: `Sandbox.Engine`
- Inherits: [Sandbox.Component](/api/Sandbox.Component)

## Constructors

- [`BaseInventoryItem`](/api/Sandbox.BaseInventoryItem/.ctor)

## Properties

- [`DisplayIcon`](/api/Sandbox.BaseInventoryItem/DisplayIcon): Icon shown in inventory UI.
- [`DisplayName`](/api/Sandbox.BaseInventoryItem/DisplayName): Display name shown in inventory UI.
- [`Inventory`](/api/Sandbox.BaseInventoryItem/Inventory): The inventory this item currently belongs to, or null if it isn't in one. Derived from the hierarchy so it's correct on every peer. The nearest ancestor, never this item's own GameObject - an item that is itself an inventory (a backpack) belongs to its holder.
- [`IsActive`](/api/Sandbox.BaseInventoryItem/IsActive): True when this is the active (deployed) item in its inventory.
- [`PreferredSlot`](/api/Sandbox.BaseInventoryItem/PreferredSlot): The slot this item wants when added without an explicit one (GMod's SWEP.Slot). In a hotbar inventory it falls back to the first empty slot when taken, with -1 for no preference; in a buckets inventory the preference always wins.
- [`ShouldAvoid`](/api/Sandbox.BaseInventoryItem/ShouldAvoid): True when the inventory should avoid auto-switching to this item - e.g. a gun with nothing to fire. [Sandbox.BaseInventoryComponent.GetBestItem](/api/Sandbox.BaseInventoryComponent/GetBestItem) falls back to avoided items only when there's nothing better.
- [`Slot`](/api/Sandbox.BaseInventoryItem/Slot): The slot this item occupies, or -1 if unassigned. Set by the inventory.
- [`SlotOrder`](/api/Sandbox.BaseInventoryItem/SlotOrder): Fixed sort position among items sharing a slot, lowest first (GMod's SWEP.SlotPos). Only matters in a buckets inventory - hotbar slots hold one item.
- [`Value`](/api/Sandbox.BaseInventoryItem/Value): Relative worth of this item. Used as the priority when the inventory has to pick a "best" item to fall back to (e.g. after the active item is removed). Higher wins.

## Methods

- [`CanPickup`](/api/Sandbox.BaseInventoryItem/CanPickup): True when the given inventory is allowed to pick this item up (see [Sandbox.BaseInventoryItem.OnCanPickup](/api/Sandbox.BaseInventoryItem/OnCanPickup)). Queryable by UI - a pure check, nothing happens.
- [`CanSwitchTo`](/api/Sandbox.BaseInventoryItem/CanSwitchTo): True when the inventory is allowed to make this the active item (see [Sandbox.BaseInventoryItem.OnCanSwitchTo](/api/Sandbox.BaseInventoryItem/OnCanSwitchTo)). Queryable by UI - a pure check, nothing happens.
