RecipePlacer
A class in Root.Township, Alta.Carpentry.
Page dock on a chiselling deck that reads a ChiselDefinition recipe page and guides the player by pulsing the next piece to chisel. Client visuals only; on a headless server it does nothing.
- Listed in Crafting and making
- Inherits or implements
MonoBehaviour,IBuildRendererPostBake,IBuildBakeable - Attributes
RequireComponent - Documented in Farming, woodcutting and carpentry
Constructors
| Member | What it is |
|---|---|
RecipePlacer() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
30 private and internal fields
| Member | What it is |
|---|---|
private PooledObjectDefinition blowUpPiece | Pooled effect spawned on each block piece when the recipe is broken. |
private SoundEffectSet changePieceAudio | Sound played when the guide moves to the next piece. |
private AltaCoroutine coroutineHandler | The running light coroutine, stopped before a new one starts. |
private Gradient crystalColorZeroWrongGradient | Crystal _ColorA colour over the wrong-order flash. |
private Gradient crystalEmmisionWorkingGradient | Crystal emission over one pulse cycle while guiding. |
private Gradient crystalEmmisionWrongGradient | Crystal emission over the wrong-order flash. |
private PlatformLight crystalLight | Light on the crystal, off when idle. |
private Material crystalMaterial | Instanced material shared by all crystal renderers. |
private Renderer[] crystalRenderers | Renderers that share the instanced crystal material. |
private PooledObject currentPulsator | The pulse effect currently on the next piece, or null. |
private ChisellingDeck deck | The chiselling deck whose block this placer checks. |
private Color fadeOutEmmision | Crystal emission colour when faded out. |
private Transform lightPointer | Transform that aims at the next piece and holds the pointer visual. |
private AnimationCurve lightPulsatingIntensity | Crystal light intensity over one pulse cycle while guiding. |
private PickupDock pageDock | The dock the recipe page goes into (on the same object). |
private AnimationCurve pointerAlphaAnimation | Pointer alpha while it fades in or out. |
private Material pointerMaterial | Instanced pointer material. |
private Renderer pointerRenderer | Pointer renderer under lightPointer, found at build time. |
private readonly int pointerShaderAlpha | Shader id for the pointer's _TintColor. |
private PooledObjectDefinition pulsatorDefinition | Pooled pulse effect put on the next piece. Set to null on headless servers. |
private float pusatingPeriod | Seconds per pulse cycle of the crystal light while guiding. |
private readonly int shaderColorZero | Shader id for _ColorA. |
private readonly int shaderEmmision | Shader id for _EmissionColor. |
private SoundEffectSet startWorkingAudio | Sound played when the guide starts on a block. |
private SoundEffectSet stopWorkingAudio | Sound played when the guide stops because the recipe was broken. |
private float warmUpDuration | Seconds the warm-up and fade-out blends take. |
private Color workingLightColor | Crystal light colour while guiding. |
private Color wrongLightColor | Crystal light colour for the wrong-order flash. |
private AnimationCurve wrongPulse | Crystal light intensity over the wrong-order flash. |
private float wrongPulseDuration | Seconds the wrong-order flash lasts. |
Properties
| Member | What it is |
|---|---|
ChiselDefinition Definition { get; private set; } | The recipe from the docked page, or null when no recipe page is docked. |
Methods
19 private and internal methods
| Member | What it is |
|---|---|
private void AddDefinition(Interactor interactor, Pickup pickup, PickupDock dock) | Handler for a page docking: applies the page's recipe now, or waits for OnChangedPage if the page has no data yet. |
private void Awake() | Client: hooks the page dock events and makes instanced crystal and pointer materials. Skipped on headless servers. |
private void ChangeDefinition(ChiselDefinition definition) | Sets the active recipe, checks it against the block on the deck and flashes the wrong effect if it doesn't match. Null clears the pulse. |
private void ClearDefinition(Interactor interactor, Pickup pickup, PickupDock dock) | Handler for the page undocking: clears the active recipe. |
private IEnumerator FadeOut(bool hasPointer) (iterator) | Coroutine that fades the crystal light, emission and pointer to off, then hides the pointer. |
private void InvalidDefinition(bool isBlowingUp) | Stops the guide and plays the wrong pulse; when isBlowingUp is true it also spawns blow-up effects on the block's active pieces. |
private void OnDestroy() | Cleans up the instanced materials. |
private void PageFilter(Interactor interactor, Pickup pickup, ref bool result) | Dock filter that only accepts pages carrying a ChiselDefinition. |
private IEnumerator Point() (iterator) | Coroutine that aims the pointer at the pulsing piece and animates the crystal light while a guide is active. |
private void IBuildRendererPostBake.PostBake() | Build step that finds the pointer renderer and strips null crystal renderers. |
private bool ReleasePulsator() | Returns the pulse effect to its pool. Returns true if there was one. |
private void Start() | Client: applies any page already docked and listens for the deck's block changing. |
private void UpdateBlock(TimberBlock block) | Handler for the deck's block changing: re-checks the new block against the recipe. |
private void UpdatePage(PageInstance page) | Pulls the ChiselDefinition out of a page and makes it the active recipe. |
private void UpdatePiece(TimberPieceBase piece) | Moves the pulse effect onto the given piece (creating it if needed) and starts it pulsing. |
private bool ValidateBlock(TimberBlock block) | Checks a block's size, stage and chiselled pieces so far against the recipe order; if it fits, points at the next piece. |
private void ValidateDefinition(IListenedList<int> list, int item) | Runs on each chiselled piece: moves the guide on if the order is right, blows up the guide if wrong, and sets HasFollowedRecipe when all 12 are done. |
private IEnumerator WarmUp(bool toWorking) (iterator) | Coroutine that blends the crystal light and emission to the working or wrong colours and fades the pointer in or out. |
private IEnumerator WrongPulse() (iterator) | Coroutine for the wrong-order flash on the crystal, then fades out. |