Skip to main content

GenericCraftingComponent

A class in Root.Township, Alta.Crafting.

A component on a pickup that can be added as a piece to a GenericCraftingStation project. Tracks the nearest free piece while held and fills it when released.

Constructors​

MemberWhat it is
GenericCraftingComponent()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

10 private and internal fields
MemberWhat it is
private IAffectCrafting[] affectedByPrivate: the IAffectCrafting behaviours that must all be active before this item counts.
private MonoBehaviour[] affectedByBehavioursSerialized list of behaviours implementing IAffectCrafting.
private int bestPieceKeyPrivate: key of the piece chosen by Track, used by Released.
private Transform cachedTransformPrivate: cached transform of this object.
private Vector3 centrePointOffsetLocal offset of the point used to find the closest piece.
private PhysicalMaterial materialSerialized material, used when there is no part.
private TransformEvent onAddedToProjectEffectEffect event raised with the transform when the item is added to a project.
private PhysicalMaterialPart partOptional PhysicalMaterialPart that holds the material instead of material.
private Pickup pickupBacking field for Pickup.
private MethodSync syncEffectsPrivate: message that tells clients to play the added effect.

Properties​

MemberWhat it is
PhysicalMaterial Material { get; private set; }The physical material, from the PhysicalMaterialPart if one is set, otherwise the serialized material.
Pickup Pickup { get; }The pickup this component belongs to.
3 private and internal properties
MemberWhat it is
private bool Alta.Crafting.IGenericCraftingComponent.IsAddingProject { get; }Always false; this component fills pieces and does not start projects.
private bool IsActive { get; }Private: true only when every IAffectCrafting behaviour says it is active (for example the item is finished enough).
private Vector3 ObjectCentrePoint { get; }Private: world position of the centre point, used to find the closest piece.

Methods​

MemberWhat it is
void AddedToProject()Plays the added effect (not on headless) and, on the server, tells clients to play it too.
override void Initialize()Sets up the effect sync message.
void SetupAsRefuse(PhysicalMaterial material)Sets the material and forces every affecting behaviour active, so refuse can be used straight away.
6 private and internal methods
MemberWhat it is
private bool CalculateCentrePointOffset()Private, editor: sets centrePointOffset to the centre of the object's bounds. Returns whether it changed.
private void UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize()Casts affectedByBehaviours into the affectedBy array.
private void UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize()Does nothing.
private void Alta.Crafting.IGenericCraftingComponent.Released(GenericCraftingStation station)When the item is let go near a station, fills the tracked piece with its material and destroys the item.
private void SyncEffects(IPlayer player, Stream stream)Private: client side of the effect sync, plays AddedToProject effects.
private void Alta.Crafting.IGenericCraftingComponent.Track(GenericCraftingStation station)While held near a station, asks it for the closest piece to the centre point and animates that piece.

Used in​

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