Skip to main content

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.

Constructors​

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

Fields​

30 private and internal fields
MemberWhat it is
private PooledObjectDefinition blowUpPiecePooled effect spawned on each block piece when the recipe is broken.
private SoundEffectSet changePieceAudioSound played when the guide moves to the next piece.
private AltaCoroutine coroutineHandlerThe running light coroutine, stopped before a new one starts.
private Gradient crystalColorZeroWrongGradientCrystal _ColorA colour over the wrong-order flash.
private Gradient crystalEmmisionWorkingGradientCrystal emission over one pulse cycle while guiding.
private Gradient crystalEmmisionWrongGradientCrystal emission over the wrong-order flash.
private PlatformLight crystalLightLight on the crystal, off when idle.
private Material crystalMaterialInstanced material shared by all crystal renderers.
private Renderer[] crystalRenderersRenderers that share the instanced crystal material.
private PooledObject currentPulsatorThe pulse effect currently on the next piece, or null.
private ChisellingDeck deckThe chiselling deck whose block this placer checks.
private Color fadeOutEmmisionCrystal emission colour when faded out.
private Transform lightPointerTransform that aims at the next piece and holds the pointer visual.
private AnimationCurve lightPulsatingIntensityCrystal light intensity over one pulse cycle while guiding.
private PickupDock pageDockThe dock the recipe page goes into (on the same object).
private AnimationCurve pointerAlphaAnimationPointer alpha while it fades in or out.
private Material pointerMaterialInstanced pointer material.
private Renderer pointerRendererPointer renderer under lightPointer, found at build time.
private readonly int pointerShaderAlphaShader id for the pointer's _TintColor.
private PooledObjectDefinition pulsatorDefinitionPooled pulse effect put on the next piece. Set to null on headless servers.
private float pusatingPeriodSeconds per pulse cycle of the crystal light while guiding.
private readonly int shaderColorZeroShader id for _ColorA.
private readonly int shaderEmmisionShader id for _EmissionColor.
private SoundEffectSet startWorkingAudioSound played when the guide starts on a block.
private SoundEffectSet stopWorkingAudioSound played when the guide stops because the recipe was broken.
private float warmUpDurationSeconds the warm-up and fade-out blends take.
private Color workingLightColorCrystal light colour while guiding.
private Color wrongLightColorCrystal light colour for the wrong-order flash.
private AnimationCurve wrongPulseCrystal light intensity over the wrong-order flash.
private float wrongPulseDurationSeconds the wrong-order flash lasts.

Properties​

MemberWhat 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
MemberWhat 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.