ForgedModel<TB, TA>
An abstract class in Root.Township, Alta.Blacksmithing.
A metal piece that's shaped by hammering. Each hit on its forged points adds progress (and heat on the server); when every point is done the piece is complete, gives forging XP along the way and raises an item forged event.
- Listed in Crafting and making
- Inherits or implements
HeatModel<ForgedPoint, TB, TA>,ISpawnArguments,IAffectCrafting - Derived types
ForgedModel - Attributes
ExecuteInEditMode
Constructors
| Member | What it is |
|---|---|
protected ForgedModel() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
18 private and internal fields
| Member | What it is |
|---|---|
private ImpactDetectorSettings coldEffect | Impact effect for hitting the piece while it is too cold. |
private float distanceDistribution | Falloff distance for how a hit's damage spreads to forged points further from the impact. |
private ImpactDetectorSettings doneEffect | Impact effect when most of the hit lands on points that are already finished. |
private DurabilityModule durabilityModule | Durability module on the item; disabled until the piece is complete. |
private GameObject[] enableOnComplete | Objects that are hidden at start and shown once forging is complete. |
private ForgedPointCollection forgedPointCollection | Syncs the forged points' progress to clients. |
private List<ForgedPoint> forgedPoints | Backing field for ForgedPoints: the points that must each reach full progress. |
private bool hasDurabilityModule | Cached flag for whether a durability module was found (client only). |
private ImpactDetectorSettings hotEffect | Impact effect for a normal hit on hot, unfinished metal. |
private ImpactDetector impactDetector | The parent ImpactDetector whose hits drive forging. |
private bool isFirstEffectPlayed | Client: whether the first done-impact effect has played. |
private static Logger logger | NLog logger for this class. |
private static List<Mesh> modified | Static list of meshes; not used in this file. |
private AltaEvent onCompleted | Event fired when the piece becomes complete. |
private PhysicalMaterialPart physicalMaterialPart | Parent PhysicalMaterialPart whose material changes are tracked. |
private Pickup pickup | Parent Pickup, used to find the last player who held it for experience and events. |
private bool provideExperience | Whether hits on this piece grant forging experience. |
private MethodSyncStruct<bool> syncComplete | Network message used to tell clients the piece is complete. |
Properties
| Member | What it is |
|---|---|
ForgedPointCollection ForgedPointCollection { get; } | Syncs the forged points' state. |
List<ForgedPoint> ForgedPoints { get; } | The points that take hammer hits. |
ImpactDetector ImpactDetector { get; } | The impact detector whose hits shape the piece. |
bool IsDone { get; private set; } | True once the piece is complete. Only done pieces stack with done pieces. |
PooledParticleSystemMeshEmision MeshEffect { get; set; } | The particle effect playing over the mesh after completion, if any. |
MeshFilter MeshFilter { get; } | The piece's mesh filter. |
PhysicalMaterial PhysicalMaterial { get; set; } | The piece's metal. Sets how much each hit does and which effects play. |
protected override float DefaultGreen { get; } | 0: starting value for the colour model's green channel. |
protected override List<ForgedPoint> GreenPoints { get; } | The forged points, used for the colour model. |
Methods
| Member | What it is |
|---|---|
void ForceComplete(bool isPlayingEffects) | Sets every point's progress to full and completes the piece. Also used by the forged spawn argument. |
override void Initialize() | Sets up completion sync, and keeps durability and on-complete objects off until done. |
override void InitializeAsServer(SpawnData spawnData) | Server: completes the piece straight away if all points are already done. |
override void OnConnected(Player player) | Tells a newly connected player the piece is complete, if it is. |
protected override void Awake() | Hooks material changes, durability visuals and hits. |
protected virtual void OnValidate() | Editor: finds the durability module if it's missing. |
12 private and internal methods
| Member | What it is |
|---|---|
private void Alta.Utilities.ISpawnArguments.CheckArguments(string[] arguments) | Spawn argument hook: the argument forged makes the item spawn already complete. |
private void CheckComplete(bool isPlayingEffects) | Calls SetComplete once every forged point has reached full progress. |
private void Alta.Crafting.IAffectCrafting.ForceActive() | Crafting hook: forces the item complete without effects. |
private void HandleHit(ImpactHit impact) | Impact handler: spreads hit damage over nearby forged points; on the server also adds heat, grants forging experience and checks for completion. |
private void HandleSetCompleteEvents(bool isPlayingEffects) | Server: syncs completion to clients and broadcasts an ItemForgedEvent for the last player who held it. |
private bool Alta.Crafting.IAffectCrafting.IsActive() | Crafting hook: true once the item is done. |
private void MeshEffectReleased(PooledObject pooled) | Clears MeshEffect when the pooled mesh particle effect is released. |
private static void ProcessForgedEvent(IPlayer player, uint hash) | Broadcasts an ItemForgedEvent on the township event bus (server or local test only). |
private void SetComplete(bool isPlayingEffects) | Marks the item done, enables the complete objects, fires onCompleted, turns on durability and, on clients, swaps materials and plays the done effect. |
private void SyncComplete(IPlayer player, Stream stream, bool isPlayingEffects) | Network handler: reads the completion message and calls SetComplete on remote clients. |
private void UpdateDurabilityStage(DurabilityModule.DurabilityVisual durabilityStage) | Client: switches the mesh used for heat colouring when the durability visual stage changes. |
private void UpdateMaterial(PhysicalMaterial physicalMaterial, PhysicalMaterialChannel materialChannel) | Handles a material change from the PhysicalMaterialPart: on clients updates atlased mesh and materials, then stores the material. |