Class NPCInventory
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
Returns
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
Returns
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)