CanPickupWorldItem
(item)
bool
Is this an item lying in the world that we could take right now? It's valid, it isn't in an
inventory, it doesn't refuse us (Sandbox.BaseInventoryItem.OnCanPickup(Sandbox.InventoryComponent)), and it isn't
something we dropped a moment ago. Runs on the host for routed pickup requests, making it
the place to validate them - the base deliberately has no range check (like shot claims,
what's plausible is game policy), so override to add range or line-of-sight rules.
GetBestItem
()
BaseInventoryItem
Returns the highest Sandbox.BaseInventoryItem.Value item we're allowed to switch to, or
null if there's nothing switchable. Items flagged Sandbox.BaseInventoryItem.ShouldAvoid
(e.g. empty guns) are only picked when nothing better exists. Override for game-specific
priority - runs on the host for engine-driven switches (remove, drop, pickup, loadout), so
per-player preference data must be host-available.
Pickup
(prefab, slot)
BaseInventoryItem
Spawns an item from a prefab and adds it to the inventory in the given slot (-1 picks one,
see Sandbox.InventoryComponent.Add(Sandbox.BaseInventoryItem,System.Int32)). Host only. Returns the spawned item, or null if it couldn't be added
(no room, no Sandbox.BaseInventoryItem on the prefab, slot taken).
Transfer
(item, to, slot)
bool
Moves an item from this inventory into another - no world drop, no destroy. The usual gates
get a say (Sandbox.InventoryComponent.OnRemoving(Sandbox.BaseInventoryItem) here, Sandbox.InventoryComponent.OnAdding(Sandbox.BaseInventoryItem,System.Int32) and the item's own say
there); any refusal leaves everything as it was. Reserve ammo stays behind - the pool lives
on the inventory, not the item. The destination doesn't auto-deploy (it may be a chest).
Host only - who may move items between which inventories is game policy, so games route
their own requests here. Returns whether the item moved.