Table of Contents

Class NPCInventory

Namespace
S1API.Entities
Assembly
S1API.dll

Modder-facing inventory wrapper for an S1API.Entities.NPCInventory.NPC. Provides helpers to query capacity and insert items safely.

public sealed class NPCInventory
Inheritance
NPCInventory
Inherited Members
Extension Methods

Methods

CanItemFit(string, int)

Returns true if an item with the given ID and quantity can fit in this NPC's inventory.

public bool CanItemFit(string itemId, int quantity = 1)

Parameters

itemId string
quantity int

Returns

bool

EnsureInitialized()

Ensures the underlying ScheduleOne.NPCs.NPCInventory exists and has slots. Some custom NPCs added at runtime may not have had their slots populated yet. This method properly initializes slots without duplication, handling the fact that ScheduleOne.ItemFramework.ItemSlot.SetSlotOwner(ScheduleOne.ItemFramework.IItemSlotOwner) automatically adds slots to the owner's ItemSlots list.

public void EnsureInitialized()

GetCapacityForItem(string, int)

Returns how many units of the given item ID could fit right now.

public int GetCapacityForItem(string itemId, int quantity = 1)

Parameters

itemId string
quantity int

Returns

int

TryInsert(string, int, bool)

Attempts to insert an item created from the ID and quantity. Returns true if insertion was performed (fit was sufficient).

public bool TryInsert(string itemId, int quantity = 1, bool network = true)

Parameters

itemId string
quantity int
network bool

Returns

bool