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.
- Listed in Crafting and making
- Inherits or implements
NetworkEntityBehaviour,ISerializationCallbackReceiver,IGenericCraftingComponent - Documented in Crafting
Constructors
| Member | What it is |
|---|---|
GenericCraftingComponent() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private IAffectCrafting[] affectedBy | Private: the IAffectCrafting behaviours that must all be active before this item counts. |
private MonoBehaviour[] affectedByBehaviours | Serialized list of behaviours implementing IAffectCrafting. |
private int bestPieceKey | Private: key of the piece chosen by Track, used by Released. |
private Transform cachedTransform | Private: cached transform of this object. |
private Vector3 centrePointOffset | Local offset of the point used to find the closest piece. |
private PhysicalMaterial material | Serialized material, used when there is no part. |
private TransformEvent onAddedToProjectEffect | Effect event raised with the transform when the item is added to a project. |
private PhysicalMaterialPart part | Optional PhysicalMaterialPart that holds the material instead of material. |
private Pickup pickup | Backing field for Pickup. |
private MethodSync syncEffects | Private: message that tells clients to play the added effect. |
Properties
| Member | What 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
| Member | What 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
| Member | What 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
| Member | What 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: