Skip to main content

CraftingOptions

A class in Root.Township, Alta.Crafting.

A possible connection between two crafting parts the local player is holding together. It finds free slots that fit the insert, shows glow and guide lines, and requests the craft when the insert part is let go.

Constructors​

1 private and internal constructor
MemberWhat it is
private CraftingOptions(PlayerController player, CraftingPart insertPart, CraftingPart slotPart)Creates a CraftingOptions from player, insertPart and slotPart.

Fields​

10 private and internal fields
MemberWhat it is
private JointSlot bestMatchThe slot the insert would go into right now.
private IUnityUpdateMethod craftVisualUpdateHandle for the registered late update.
private JointInsert insertThe joint insert being placed.
private CraftingPart insertPartThe part with the free insert.
private static readonly Logger loggerNLog logger for this class.
private const float MaximumAllowedCraftDistance0.1 m. Not used; the best-match check has the same distance written in directly.
private PlayerController playerThe player doing the craft.
private static Stack<HashSet<JointSlot>> possibleSlotPoolsPool of reused slot sets, so options don't allocate each time.
private HashSet<JointSlot> possibleSlotsFree slots that the insert could go into.
private CraftingPart slotPartThe part that has the slots.

Methods​

MemberWhat it is
static bool Create(PlayerController player, CraftingPart primaryCraftingPart, CraftingPart secondaryCraftingPart)Starts a crafting option when exactly one of the two parts has a free insert. Returns false otherwise.
void Destroy()Unhooks the release events, clears both parts' PotentialConnection and hides the visuals.
bool Involves(CraftingPart part)True if the part is either side of this option.
8 private and internal methods
MemberWhat it is
private void AttemptCraft(Interactable dropped, Interactor interactor)Runs when the insert part is released. Requests the craft if both parts can still craft, otherwise cleans up.
private void Cancel(Interactable dropped, Interactor interactor)Runs when the slot part is released. Cleans up without crafting.
private void CompilePossibilities(CraftingPart part)Walks the slot part and every part connected to it, collecting free slots that support the insert's type.
private void EvaluateBestMatch()Picks the free slot closest to the insert (along its insert length), within 0.1 m.
private void HideCraftVisuals()Client: turns off glow and guide lines and stops the visual update.
private void RequestCraft(Interactable dropped, Interactor interactor)Finds the best slot, cleans up, then asks the insert part to craft into that slot.
private void ShowCraftVisuals()Client: makes the insert and possible slots glow, draws guide lines and starts updating them every late update.
private void UpdateCraftVisuals()Late update while showing: re-picks the best slot and moves the highlighted line if it changed.

Used in​

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