Mould
A class in Root.Township, the global namespace.
A casting mould item that holds a MouldDefinition (what it casts and how many ingots it costs) and optionally a limited number of uses. Both sides; the server picks and syncs the definition.
- Listed in Global namespace: M to O
- Inherits or implements
GeneratedNetworkEntityBehaviour,IBlockGenericDecrafting,ISavable<MouldSaveData>,ISavableSave<MouldSaveData>,ISavableSaveBase - Derived types
MouldSaveData - Nested types
IBlockGenericDecrafting - Documented in Smelting and forging
Constructors
| Member | What it is |
|---|---|
Mould() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private MouldDefinition definition | Backing field for Definition. Saved. |
private MeshFilter graphic | Mesh showing the shape the mould makes. |
private TextRenderer inputCount | Text showing the definition's cost. |
private bool isGenerating | Whether a blank mould picks a random definition when spawned. Off for crafted moulds. |
private bool isUsingRestrictor | Backing field for IsUsingRestrictor. Defaults to true. |
private LODGroup lodGroup | LOD group whose first level gets the shape and text renderers. |
private static Logger logger | Private: logger. Not used in this build. |
private TextRenderer outputCount | Text showing how many items one use makes, shown when more than one. |
private MeshRenderer outputQuantityRenderer | The 'x' renderer next to outputCount. |
private MethodSync sync | Private: message for Sync, sent when the definition changes and to joining players. |
private MethodSync syncUse | Private: message for SyncUse, sent by Consume. |
private int usage | Backing field for Usage. -1 means unlimited uses. |
private IntegerVisual usageVisual | Optional visual showing the uses left. |
private static List<Renderer> workingRenderersList | Private static: scratch list used to rebuild the LOD renderers. |
Properties
| Member | What it is |
|---|---|
MouldDefinition Definition { get; } | What this mould casts, or null for an empty mould. Saved with the mould. |
bool IsUsingRestrictor { get; } | Whether a MouldRestrictor keeps only one mould per definition, destroying the older copy when a new one registers. |
int Usage { get; } | Uses left. -1 means unlimited; the smelter breaks the mould when Consume takes it to zero. |
protected override bool IsGeneratingFirstTime { get; } | True only when the mould has no definition yet and is set to generate one. |
1 private and internal property
Methods
| Member | What it is |
|---|---|
bool Consume() | Server: uses up one charge if the mould has limited uses and syncs it. Returns true when uses reach zero. |
override void Initialize() | Sets up the network syncs for the definition and the remaining uses. |
override void OnConnected(Player player) | Sends the current definition and uses to a player who joins. |
void SetDefinition(MouldDefinition definition, bool isOnvalidate = false) | Changes what the mould casts. The server syncs it; clients rebuild the mesh, cost and output-count visuals. |
protected override void Generate(SpawnData spawnData) | On first spawn, gives the mould a random definition if generation is turned on for it. |
3 private and internal methods
| Member | What it is |
|---|---|
private void OnValidate() | Empty in this build. |
private void Sync(IPlayer player, Stream stream) | Private: syncs the definition hash and, if the mould has limited uses, the uses left. Clients apply them. |
private void SyncUse(IPlayer player, Stream stream) | Private: syncs the uses left and updates the visual on clients. |
Used in
Members of other types that take, return or hold a Mould: