Skip to main content

Item

A class in Root.Township, Alta.Inventory.

The item asset behind a pickup: tags, weight, stacking, dock placement, sounds, loot value and extra ItemComponents. A hashed value loaded from Items/Items; a pickup reaches it through Pickup.Item.

Constructors​

MemberWhat it is
Item()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

31 private and internal fields
MemberWhat it is
private List<ItemComponent> componentsBacking list for Components. GetComponent returns the first entry matching the type and physical material.
private Item.CustomDockPositioning[] customPositionsPer dock type positions used by GetPositioning; an entry with no dock settings is the fallback.
private Item.CustomDockPositioning[] customPositionsWhenCraftedLike customPositions, but checked first when the item is a crafted assembly.
private bool destroyWhenDockedBacking field for IsDestroyWhenDocked.
private int dockedStackSizeBacking field for DockedStackSize: how many fit in one stack (30 by default). Docks multiply it by their max stacks.
private Glyph glyphBacking field for Glyph, the item's symbol used on pages.
private bool isAssistGrabBlockedBacking field for IsAssistGrabBlocked. When true, grab assist never picks this item.
private bool isDisabledOnSimpleServerBacking field for IsDisabledOnSimpleServer. Progress commands skip such items on simple servers.
private bool isOverridingDefaultShrunkenScaleBacking field for IsOverridingDefaultShrunkenScale.
private bool isOverridingDefaultVisualScaleBacking field for IsOverridingDefaultVisualScale.
private bool isPlayingSoundBacking field for IsPlayingSound.
private bool isScalingOnGrabBacking field for IsScalingOnGrab, read by PickupInteractionScaler and Pickup.
private bool isSnappingToHandBacking field for IsSnappingToHand. Read by Pickup when deciding how a grab moves the item to the hand.
private bool isStackableBacking field for IsStackable.
private bool isStackableWhenCraftedBacking field for IsStackableWhenCrafted. Docks check it for crafted items.
private bool isUsingShrunkenVisualBacking field for IsUsingShrunkenVisual (true by default).
private float lastCalculatedScaleRead-only inspector value written through CalculatedScale by PickupInteractionScaler.
private Category lootCategoryBacking field for LootCategory, the loot category used for weighted loot picks.
private LootValue lootValueBacking field for LootValue.
private Item.DockPositioning normalPositioningDock position and rotation used when no custom entry matches and the dock doesn't scale items.
private SoundEffect overrideLetGoSoundEffectTypeBacking field for OverrideLetGoSoundEffectType; None means the default sound.
private SoundEffect overridePickUpSoundEffectTypeBacking field for OverridePickUpSoundEffectType; None means the default sound.
private float overrideScaleInsideVisualBacking field for OverrideScaleInsideVisual.
private float overrideShrunkenScaleBacking field for OverrideShrunkenScale.
private uint prefabHashNetwork prefab hash behind Prefab. A zero hash logs a warning when read.
private Item.DockPositioning scaledPositioningDock position and rotation used when no custom entry matches and the dock scales items down.
private PooledObjectDefinition shrunkenVisualBacking field for ShrunkenVisual.
private int sizeBacking field for Size and HasSize. Negative means no size; docks compare it to their min and max crafting size.
private Vector3 storeScaleBacking field for StoreScale: the item's scale in a scaling dock (half size by default).
private List<PickupTag> tagsBacking field for Tags.
private float weightBacking field for Weight (1 by default).

Properties​

MemberWhat it is
float CalculatedScale { set; }Write-only: stores the last calculated scale on the asset, shown read-only in the inspector.
IEnumerable<ItemComponent> Components { get; }The extra ItemComponent data blocks on this item.
int DockedStackSize { get; }How many of this item make one stack in a dock (default 30). Docks multiply it by their max stacks.
Glyph Glyph { get; }The symbol shown for this item on book pages.
bool HasSize { get; }True if the asset's size is not negative.
bool IsAssistGrabBlocked { get; }When true, grab assist will not pull this item to the hand.
bool IsDestroyWhenDocked { get; }Asset flag; nothing reads it in this build.
bool IsDisabledOnSimpleServer { get; }Hides the item from progress console commands on a simple server.
bool IsOverridingDefaultShrunkenScale { get; }Whether OverrideShrunkenScale replaces the default shrunken scale.
bool IsOverridingDefaultVisualScale { get; }Whether OverrideScaleInsideVisual replaces the default scale inside the shrunken visual.
bool IsPlayingSound { get; }Whether picking up and letting go of this item plays a sound.
bool IsScalingOnGrab { get; }Whether the item shrinks or grows when grabbed (used by PickupInteractionScaler).
bool IsSnappingToHand { get; }Whether the item snaps into the hand when grabbed, for example out of a dock.
bool IsStackable { get; }Whether more than one of this item can share a dock.
bool IsStackableWhenCrafted { get; }Whether the item can still stack in a dock once it is part of a crafted object.
bool IsUsingShrunkenVisual { get; }Whether the shrunken visual is used when the item is scaled down.
Category LootCategory { get; }The loot category this item belongs to.
LootValue LootValue { get; }The item's loot value. Crafting also uses it to pick the most valuable part.
SoundEffect OverrideLetGoSoundEffectType { get; }Sound played on letting go, or None for the default.
SoundEffect OverridePickUpSoundEffectType { get; }Sound played on pick up, or None for the default.
float OverrideScaleInsideVisual { get; }Scale of the item inside the shrunken visual, when overriding the default.
float OverrideShrunkenScale { get; }Shrunken scale to use when overriding the default.
NetworkPrefab Prefab { get; set; }The network prefab for this item, looked up by stored hash. Logs a warning if no prefab is set.
PooledObjectDefinition ShrunkenVisual { get; }Pooled visual shown around the item when it is shrunk.
int Size { get; }The item's crafting size (never below 0). Crafting parts start with it.
Vector3 StoreScale { get; }Scale applied when the item is stored scaled down in a dock (default half size).
List<PickupTag> Tags { get; }The pickup tags on this item. Docks use them to include, exclude or scale items.
float Weight { get; }Base weight of the item. Pickup.RawWeight uses it, then the material's multiplier applies.

Methods​

MemberWhat it is
PageData CreatePage(int preferredProvider)Builds a book page for this item using the edible or ingredient page provider.
static Item GetByPrefabHash(uint hash)Finds the item used by a prefab, through the prefab's common pickup. Null if there is none.
T GetComponent<T>(PhysicalMaterial material = null)Gets the first item component of a type that matches the given material (or any), initialised for this item.
ItemComponent GetComponent(Type type, PhysicalMaterial material = null)Gets the first item component of a type that matches the given material (or any), initialised for this item.
uint GetHash()Returns the item's hash, for the page system.
Item.DockPositioning GetPositioning(PickupDockSettings settings, bool isScaling, bool isCrafted)Picks where and how the item sits in a dock: crafted custom, custom per dock type, then scaled or normal default.
int GetProviderID(int preferredProvider)Returns the page provider to use, the edible one unless the ingredient one was asked for. Logs other values.

Used in​

Members of other types that take, return or hold a Item:

Smelter.CheckMould, Smelter.Consume, Smelter.FindRecipe, Smelter.GetInput, Smelter.mouldResult, SmelterSaveData.currentItem, BuilderDock.wedgeItem, RepairBoxModule.SpawnBox, HashedItemInfo.op_Implicit, CookingPot.IsCookable, FruitNinja.itemsToSpawn, FruitNinja.SpawnItem, StewManagerSaveData.garnishes, StewManagerSaveData.ingredients, GenericCraftingPieceDefinition.source, MainMenuShopInterface.talemItem, Fire.FuelConsumptionState.fuels, Fire.FuelConsumptionState.tracked, ResourceDropChance.resourceDefinition, BoundsDockPositioning.Position, DockPositioning.BeginInvoke, DockPositioning.Invoke, ItemCount.item, ItemCount.Item, ItemSet.items, ItemSet.Items, PickupDock.CheckAllowed, PickupDock.dockedType, PickupDock.GetPositioning, PickupDock.MoveToDock, PickupDockSaveData.dockedType, PickupDockSaveDataOld.dockedType, PickupDockSettings.includedItems, PickupDockSettings.IncludedItems, PickupDockSettings.IsPhysical, PickupEventStreamLogger.GetItemHash, PickupEventStreamLogger.GetItemName, StorageData.item, LootHelper.Spawn, LootTable.GetLoot, LootTable.Entry.item, LootTable.Entry.Item, BlockingCharge.validItems, CoinPress.outputItem, CommonPrefabs.duplicatePageItem, CommonPrefabs.DuplicatePageItem, CommonPrefabs.pageItem, CommonPrefabs.PageItem, CommonPrefabs.pouchItem, CommonPrefabs.PouchItem, DockByDefault.item, DockObjectTask.targetItems, EdiblePageProvider.GeneratePage, EdiblePageProvider.testItem, Fuel.burning, Fuel.BurningItem, Gatherer.trainingPouchItem, Gatherer.validItems, IItemComponent.Initialize, IngredientPageProvider.CheckIfCookable and 30 more.