KartSelect.component
README.md
KartSelect
The kart select screen of a grand prix, in six styles a world switches between with one field. Put it on any entity of a scene that has a grandPrixKit.GrandPrix (or on its own with preview on). It draws only on this machine.
It shows itself while the GrandPrix is in its select phase (gp:getPhase()), the local player has joined (gp:hasJoined()) and gp:me() answers an entrant; otherwise it draws nothing and the player's camera is the one on screen. It reads gp:selectView() ({ cup, entrants, me, secondsLeft, catalog }, the shape of GP.sample("select")) and answers input with gp:setPick({ vehicle, look, paint }) and gp:setReady(bool), showing the new pick at once until the GrandPrix echoes it. With no GrandPrix in that phase and preview on, it draws GP.sample("select") and keeps picks locally, with a looping 30 second countdown.
Every style shows the vehicle name and blurb, stat bars for speed, acceleration, handling and weight (barsKit looks where the style has one), the look choice, paint swatches, a Ready button, every racer with their pick and ready state, the cup name and format, and the countdown.
Styles
The style is read from this component's style field every frame, so switching is live (a GrandPrix may copy its own selectStyle onto it):
garage: the real vehiclesKit model on a slowly turning steel turntable in a workshop under warm fluorescent tubes; smoked panels, amber stencil type, hazard stripes.grid: a fighting game roster of portrait cards with a 1P cursor and rival tags, the kart posed in a violet studio, a slanted name plate.carousel: every kart on a glossy turning carousel, the selected one swung to the front; white rounded cards.arcade: a pixel arcade cabinet with chunky 8-bit frames and step shadows around a CRT monitor showing the kart over a neon grid, a blinking PRESS START and a TIME counter.hangar: a sci-fi hangar, the kart hovering over a landing pad ringed in cyan, holographic glass panels with corner brackets.minimal: a plain clean list on a light background, no 3D.
The catalog (id, name, description, tags, theme) is grandPrixKit.selectStyles.
3D stage and camera
The 3D styles build their set with grandPrixKit.selectStage on this peer only (local entities, temporary, never synced or saved) at stageX/Y/Z, default 0, 400, 0, far above the track. The set's camera has priority 900, so it takes the screen only while the select is up; when the select ends the set and its camera are destroyed and the player's camera is the one drawing again. The camera frames the kart in the gap the layout leaves (between the side panels on a desktop, above the bottom sheet on a phone).
Input
While the screen is up it holds the grandPrixKit.kartSelect input map, which stands the walking and driving schemes down. The screen registers at UI layer 950, above race HUDs and minimaps, so taps and clicks reach it.
- Keyboard: arrows or WASD move between rows (vehicle, look, paint, ready) and change the value; Q/E cycle the vehicle; Enter or Space toggles Ready; Escape takes it back.
- Gamepad: d-pad or left stick move and change; LB/RB cycle the vehicle; A (south) toggles Ready; B (east) takes it back.
- Touch and mouse: every card, look, swatch and the Ready button is a large tap target; arrow buttons beside the model cycle the vehicle.
Picks are locked while ready. Phone-sized screens (narrower than 640 points, or portrait) switch to a stacked layout: header, the model, then a bottom sheet.
Fields
style:garage,grid,carousel,arcade,hangarorminimal.preview: show sample data when there is no GrandPrix in its select phase (also draws in edit mode).grandPrix: name of the entity carrying the GrandPrix (defaultGrandPrix).stageX,stageY,stageZ: where the local 3D stage is built.scale: UI size multiplier.inputMap: the menu controls (defaultgrandPrixKit.kartSelect).
Methods
Call on the component ref (ks:isOpen()):
isOpen(): whether the screen is up on this peer.focusedRow(): 1 vehicle, 2 look, 3 paint, 4 ready.currentPick():{ vehicle, look, paint, ready }the screen shows for the local player, or nil.isPreview(): whether it is drawing sample data.