Skip to main content

JointSlotGroup

A class in Root.Township, Alta.Crafting.

Groups several joint slots so only a set number of them (default 1) can be used at once. It counts as used when any child slot is.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private Transform[] additionalTargetsExtra transforms whose joint slots belong to the group. Awake does not process them in this build.
private int maximumHow many child slots can be used at once.
private MonoBehaviour[] targetsChild joint slot components in the group.

Properties​

MemberWhat it is
bool HasSpace { get; }True while fewer children are used than the maximum.
bool IsUsed { get; }True if any child slot is used.
HashSet<IJointSlotComponent> Used { get; }The child slots currently in use.
1 private and internal property
MemberWhat it is
private bool Alta.Crafting.IJointSlotComponent.IsDestroyed { get; }True once this component has been destroyed.

Events​

MemberWhat it is
event IsJointAvailable isAvailableRaised to ask whether the group is available; children route their checks through it.
event Action<IJointSlotComponent> UsedChangedRaised when the set of used children changes.

Methods​

6 private and internal methods
MemberWhat it is
private void Awake()Hooks the child slots in targets and raises UsedChanged if any start used.
private void ChildChanged(IJointSlotComponent child)Adds or removes a child from Used when its used state changes, and raises UsedChanged.
private void IsAvailable(ref bool isAvailable)Availability check for each child: asks this group's own listeners while unused, then requires space.
private void OnValidate()Editor: renames the object to show the group's maximum.
private void Process(MonoBehaviour[] targets)Hooks each target that is a joint slot component (or has one) into this group.
private void Process(Transform[] targets)Hooks each target that is a joint slot component (or has one) into this group.