Skip to main content

Items and materials

Item​

Alta.Inventory.Item in Root.Township. A ScriptableObject asset (through Alta.HashedGeneralValue<Item> in Alta.Values). The same on both sides; it's data.

An Item is the definition behind a pickup: its name, tags, weight, stack size, trade value and size class. Every copy of "Flint" shares one Item. Get it from a pickup (pickup.Item) or look it up:

LookupNotes
HashedGeneralValue<Item>.AllEvery item definition.
HashedGeneralValue<Item>.Get(uint hash)By the item's own hash (item.Hash). Logs an error if missing.
HashedGeneralValue<Item>.Get(string name, bool isLogging = true)By asset name. See the trap below.
Item.GetByPrefabHash(uint prefabHash)From a prefab hash, through the prefab's CommonPickup.
Name lookups must be lower case

HashedGeneralValue<T>.Get(string) strips spaces from your name but doesn't lower-case it, while the names it compares against are stored lower case. Get("Iron") finds nothing; Get("iron") works, and the material asset "Carsi Alloy" is Get("carsialloy"). This applies to every HashedGeneralValue<T> type, including PhysicalMaterial.

Members​

MemberWhat it doesNotes
NetworkPrefab Prefab { get; set; }The prefab to spawn for this item.Pass to SpawnHelper.
uint Hash { get; }The item's hash.Not the prefab hash.
List<PickupTag> Tags { get; }Tags that docks and recipes test.PickupTag is an empty ScriptableObject; compare by reference or name.
float Weight { get; }Base weight.Pickup.PhysicalWeight applies the material.
bool IsStackable { get; } / bool IsStackableWhenCrafted { get; }Whether a dock may stack it.
int DockedStackSize { get; }Most per stack in a dock (30 by default).
int Size { get; } / bool HasSize { get; }Size class, checked against a dock's minimum and maximum.Crafted items use the crafting part's size.
LootValue LootValue { get; }Trade value.
Category LootCategory { get; }Loot category.
bool IsScalingOnGrab, IsSnappingToHand, IsAssistGrabBlocked, IsDestroyWhenDocked, IsDisabledOnSimpleServerGrab and dock behaviour flags.
bool IsPlayingSound, OverridePickUpSoundEffectType, OverrideLetGoSoundEffectTypeGrab sounds.
IEnumerable<ItemComponent> ComponentsExtra data blocks (food, fuel and so on).
T GetComponent<T>(PhysicalMaterial material = null) where T : ItemComponentThe first component of that type that matches the material.
PageData CreatePage(int preferredProvider)Its recipe or food page.See Pages and books.

Some item values​

Asset values (build main-1.7.2.1.42203):

ItemWeightSizeStack sizeStackableTags
Stick0.05150yesSmall, All, Fuel, Torch
Flint0.35130yesAll, Small, Stackable, Projectile
Copper Ore0.05none50yesAll, Small, Stackable, Ore, Projectile, Pedestal Placeable
Arrow0.35none30yesSmall, All, Stackable, Arrow
Short Sword5430noMedium Tool, All, Tool
Katana4430noMedium Tool, All, Back
Rusty Greataxe71030noBack, All, Medium Tool
Wooden Bag0.4430noBack, Wall Hangable, Bag
Hoarder Bag1541noBack, Wall Hangable, Bag
Pouch1none30noAll, Small, Projectile

"Size none" is size = -1: HasSize is false and docks skip the size check. There are 456 Item assets; Items and materials lists them all.

Items are shared assets. Changing one (through its private fields) changes every copy on that machine, and the other side won't know. Things like weight and size feed checks on both sides, so change them on server and clients alike or not at all.

PhysicalMaterial​

PhysicalMaterial in Root.Township (no namespace). A HashedGeneralValue<PhysicalMaterial> asset. Data, same on both sides.

Copper, iron, wood types and so on. A material changes how an item behaves:

MemberWhat it does
float DamageMultiplierMultiplies the item's impactors' damage.
uint HardnessLevelGiven to the item's impactors and detectors. A tool softer than what it hits does nothing (see Impacts).
float DurabilityMultiplierMeant to multiply the item's durability, but in the shipped code it has no effect (see Durability).
float WeightMultiplierMultiplies the item's weight.
float Density, MeltingPoint, ForgeMultiplier, GlowingStart, GlowingEndHeat and smithing.
SourceThermalConductivity, ReceiveThermalConductivity, InternalThermalConductivityHeat flow.
NoiseMultiplier, NailHealthMultiplier, MaxCraftingDamageMultiplier, TightnessMultiplier, TightnessBowImpact, MinimumProjectileWeight, MaxInvalidProjectileVelocityMultiplierOther tuning values.
Material GetMaterial(PhysicalMaterialChannel)The render material.

Material values​

Asset values for some of the 29 PhysicalMaterial assets (build main-1.7.2.1.42203). Physical materials has all of them.

MaterialHardnessDamage ×Durability ×Weight ×Melting point
Copper10.70.70.851040
Iron21111528
Gold20.50.531064
Silver3221.5961
Red Iron Alloy21.50.851.2600
Carsi Alloy31.551.25600
White Gold Alloy31.51.51.6600
Mythril42.530.75961
Orchi Alloy51.751.51.75600
Evinon Steel Alloy533.53961
Oak0111660
Walnut21.51.41.25660
Redwood411.40.75660

Hardness is what lets a pickaxe mine: an Iron Boulder's detector has hardness 1, so a pickaxe head of Copper (hardness 1) or anything harder works on it, while an impactor left at hardness 0 only gets the "ineffective" effect.

PhysicalMaterialPart​

PhysicalMaterialPart in Root.Township (no namespace). A networked behaviour on items that have a material. The server picks and syncs the material; clients follow.

MemberWhat it doesNotes
PhysicalMaterial PhysicalMaterial { get; }The current material.
void SetMaterial(PhysicalMaterial)Changes it: re-scales impactor damage, sets hardness, tells IListenToPhysicalMaterial components, swaps renderers, updates durability.Syncs to clients only when called on the server.
event ChangedMaterial MaterialChangeddelegate void ChangedMaterial(PhysicalMaterial, PhysicalMaterialChannel)

Get it with pickup.PhysicalMaterial (a Pickup property that returns the part, not the material: pickup.PhysicalMaterial?.PhysicalMaterial is the material).

public static void MakeIron(Pickup pickup)
{
PhysicalMaterial iron = Alta.HashedGeneralValue<PhysicalMaterial>.Get("iron", isLogging: false);
if (iron != null && pickup.PhysicalMaterial != null && NetworkSceneManager.IsServer)
pickup.PhysicalMaterial.SetMaterial(iron);
}

"iron" stands for whatever the asset is called; list HashedGeneralValue<PhysicalMaterial>.All to see the names.

Things to know:

See also​