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.
- Listed in Items, inventory and logic
- Inherits or implements
HashedGeneralValue<Item>,IPageBasis - Derived types
Item,Item.Create,EdiblePageProvider,IngredientPageProvider - Nested types
Create,CustomDockPositioning,DockPositioning - Attributes
HashedPath,TypeConverter - Documented in Items and materials, Arguments and results
Constructors
| Member | What it is |
|---|---|
Item() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
31 private and internal fields
| Member | What it is |
|---|---|
private List<ItemComponent> components | Backing list for Components. GetComponent returns the first entry matching the type and physical material. |
private Item.CustomDockPositioning[] customPositions | Per dock type positions used by GetPositioning; an entry with no dock settings is the fallback. |
private Item.CustomDockPositioning[] customPositionsWhenCrafted | Like customPositions, but checked first when the item is a crafted assembly. |
private bool destroyWhenDocked | Backing field for IsDestroyWhenDocked. |
private int dockedStackSize | Backing field for DockedStackSize: how many fit in one stack (30 by default). Docks multiply it by their max stacks. |
private Glyph glyph | Backing field for Glyph, the item's symbol used on pages. |
private bool isAssistGrabBlocked | Backing field for IsAssistGrabBlocked. When true, grab assist never picks this item. |
private bool isDisabledOnSimpleServer | Backing field for IsDisabledOnSimpleServer. Progress commands skip such items on simple servers. |
private bool isOverridingDefaultShrunkenScale | Backing field for IsOverridingDefaultShrunkenScale. |
private bool isOverridingDefaultVisualScale | Backing field for IsOverridingDefaultVisualScale. |
private bool isPlayingSound | Backing field for IsPlayingSound. |
private bool isScalingOnGrab | Backing field for IsScalingOnGrab, read by PickupInteractionScaler and Pickup. |
private bool isSnappingToHand | Backing field for IsSnappingToHand. Read by Pickup when deciding how a grab moves the item to the hand. |
private bool isStackable | Backing field for IsStackable. |
private bool isStackableWhenCrafted | Backing field for IsStackableWhenCrafted. Docks check it for crafted items. |
private bool isUsingShrunkenVisual | Backing field for IsUsingShrunkenVisual (true by default). |
private float lastCalculatedScale | Read-only inspector value written through CalculatedScale by PickupInteractionScaler. |
private Category lootCategory | Backing field for LootCategory, the loot category used for weighted loot picks. |
private LootValue lootValue | Backing field for LootValue. |
private Item.DockPositioning normalPositioning | Dock position and rotation used when no custom entry matches and the dock doesn't scale items. |
private SoundEffect overrideLetGoSoundEffectType | Backing field for OverrideLetGoSoundEffectType; None means the default sound. |
private SoundEffect overridePickUpSoundEffectType | Backing field for OverridePickUpSoundEffectType; None means the default sound. |
private float overrideScaleInsideVisual | Backing field for OverrideScaleInsideVisual. |
private float overrideShrunkenScale | Backing field for OverrideShrunkenScale. |
private uint prefabHash | Network prefab hash behind Prefab. A zero hash logs a warning when read. |
private Item.DockPositioning scaledPositioning | Dock position and rotation used when no custom entry matches and the dock scales items down. |
private PooledObjectDefinition shrunkenVisual | Backing field for ShrunkenVisual. |
private int size | Backing field for Size and HasSize. Negative means no size; docks compare it to their min and max crafting size. |
private Vector3 storeScale | Backing field for StoreScale: the item's scale in a scaling dock (half size by default). |
private List<PickupTag> tags | Backing field for Tags. |
private float weight | Backing field for Weight (1 by default). |
Properties
| Member | What 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
| Member | What 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.