Skip to main content

JointPoint

An abstract class in Root.Township, Alta.Crafting.

Base for the two ends of a crafting join: JointSlot (receives) and the insert (goes in). It tracks whether it is connected, shows a glow, and switches objects on or off when joined.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private JointPointEvent connectedEvent behind Connected, invoked by OnJointConnected.
private List<GameObject> connectedObjectsObjects shown only while the joint is connected.
private CraftingPart craftingPartBacking field for CraftingPart, found in the parents on first use.
private JointPointEvent disconnectedEvent behind Disconnected, invoked by OnJointDisconnected.
private List<GameObject> disconnectedObjectsObjects shown only while the joint is disconnected.
private Renderer glowRenderer that glows to show the joint. OnValidate finds a child named Glow if unset.
private static readonly int glowColorShader property ID for the glow colour (_EmisColor).
private MaterialPropertyBlock glowPropertiesMaterial property block used to set the glow colour.
private static Logger loggerNLog logger for this class.

Properties​

MemberWhat it is
CraftingPart CraftingPart { get; }The crafting part this joint belongs to, found in parents.
abstract IEnumerable<JointPointType> GeneralTypes { get; }The joint's types, used to match slots and inserts.
Transform Glow { get; }Transform of the glow renderer.
bool IsConnected { get; private set; }True while joined.
bool IsGlowing { get; set; }Shows or hides the glow. Always false on a headless server.
bool IsPreConfirmationConnected { get; private set; }True while a join is waiting for confirmation (such as nailing).

Events​

MemberWhat it is
event Action<JointPoint> ConnectedRaised when the joint connects.
event Action<JointPoint> DisconnectedRaised when the joint disconnects.
event IsJointAvailable isAvailableLets other code veto IsAvailable.

Methods​

MemberWhat it is
bool IsAvailable(bool isIgnoringPreConfirmation = false)True if not connected, active, not held for a pending confirmation, and no isAvailable handler says no.
virtual void OnJointConnected(bool isPlayingEffects)Marks connected, swaps the connected and disconnected objects and raises Connected.
virtual void OnJointDisconnected(bool isPlayingEffects)Marks disconnected, swaps the objects back and raises Disconnected.
void OnPreConfirmationConnected()Marks the joint as held by a pending join.
void OnPreConfirmationDisconnected()Clears the pending join mark.
void SetGlowColor(Color color)Sets the glow colour.
protected virtual void Awake()Hides the glow.
protected virtual void OnDrawGizmosSelected()Draws the joint's axes in the editor.
protected virtual void OnValidate()Finds a child named "Glow" as the glow renderer if none is set.
1 private and internal method
MemberWhat it is
private void SetObjectsActive(bool isConnected)Shows connectedObjects and hides disconnectedObjects when connected, and the other way round.

Used in​

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