Skip to main content

MouldDefinition

A class in Root.Township, the global namespace.

A hashed asset describing a smithing mould: the item it casts, the ingots it takes, the cost and how its picture looks on the mould. Look one up by product with GetDefinition.

Constructors​

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

Fields​

15 private and internal fields
MemberWhat it is
private ItemSet allowedMaterialsBacking field for AllowedMaterials. Must be ingots.
private int costBacking field for Cost, shown as the input count on the mould.
private Vector3 countNumberGraphicPositionBacking field for CountNumberGraphicPosition.
private Vector3 countXGraphicPositionBacking field for CountXGraphicPosition.
private static Dictionary<Item, MouldDefinition> definitionsStatic lookup from product item to its mould definition.
private static List<MouldDefinition> findableStatic list of findable moulds that GetRandom picks from.
private float gapBacking field for Gap.
private Mesh graphicBacking field for Graphic.
private Vector3 graphicPositionBacking field for GraphicPosition.
private Vector3 graphicRotationBacking field for GraphicRotation, as Euler angles.
private float graphicScaleOld uniform scale. Unused; GraphicScale returns graphicScaleNew.
private Vector3 graphicScaleNewBacking field for GraphicScale.
private bool isFindableBacking field for IsFindable. Defaults to true.
private Item productBacking field for Product. OnValidate names the asset after it.
private int quantityProducedBacking field for QuantityProduced. Defaults to 1.

Properties​

MemberWhat it is
ItemSet AllowedMaterials { get; }The ingot items that can be poured into this mould.
int Cost { get; }How many ingots one cast takes. The smelter also scales the fuel needed by it.
Vector3 CountNumberGraphicPosition { get; }Where the quantity number is drawn on the mould.
Vector3 CountXGraphicPosition { get; }Where the multiplication sign before the quantity is drawn on the mould.
float Gap { get; }A float set per mould. Nothing in the server build reads it.
Mesh Graphic { get; }Mesh of the picture shown on the mould.
Vector3 GraphicPosition { get; }Local position of the mould's picture.
Vector3 GraphicRotation { get; }Local rotation (Euler angles) of the mould's picture.
Vector3 GraphicScale { get; }Local scale of the mould's picture.
bool IsFindable { get; }Whether GetRandom can return this mould.
Item Product { get; }The item this mould casts.
int QuantityProduced { get; }How many items one cast makes.

Methods​

MemberWhat it is
static MouldDefinition GetDefinition(Item product)Returns the mould whose product is the given item, or null. Builds the lookup on first use.
static MouldDefinition GetRandom()Returns a random mould marked findable.
protected override void OnValidate()Editor: renames the asset to the product's name plus " Mould".
1 private and internal method
MemberWhat it is
private static void CheckInitialize()Builds the product lookup and the findable list from all mould definitions on first use.

Used in​

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