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.
- Listed in Crafting and making
Constructors
1 private and internal constructor
| Member | What it is |
|---|---|
private CraftingOptions(PlayerController player, CraftingPart insertPart, CraftingPart slotPart) | Creates a CraftingOptions from player, insertPart and slotPart. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private JointSlot bestMatch | The slot the insert would go into right now. |
private IUnityUpdateMethod craftVisualUpdate | Handle for the registered late update. |
private JointInsert insert | The joint insert being placed. |
private CraftingPart insertPart | The part with the free insert. |
private static readonly Logger logger | NLog logger for this class. |
private const float MaximumAllowedCraftDistance | 0.1 m. Not used; the best-match check has the same distance written in directly. |
private PlayerController player | The player doing the craft. |
private static Stack<HashSet<JointSlot>> possibleSlotPools | Pool of reused slot sets, so options don't allocate each time. |
private HashSet<JointSlot> possibleSlots | Free slots that the insert could go into. |
private CraftingPart slotPart | The part that has the slots. |
Methods
| Member | What 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
| Member | What 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: