Yotc Carrat Race Start
Based on game build 714014 | Last updated: 2026-03-07
Overview
yotc_carrat_race_start is a prefabricated structure used to begin and manage carrat races. It acts as the race start gate and coordinates with the yotc_raceprizemanager, yotc_racestart, yotc_racecompetitor, and yotc_racestats components to register racers, start/end races, and handle race statistics. It supports construction, hammering, burning, and integration with the deployable kit system. When activated, it spawns three ghost racers with randomized but calibrated stat spreads and triggers race-phase transitions.
Usage example
local inst = SpawnPrefab("yotc_carrat_race_start")
inst.Transform:SetPosition(x, 0, z)
-- Typically initialized by the game’sPrefab system; not usually instantiated manually in mods.
-- To trigger a race start after placement:
inst:PushEvent("yotc_start_race") -- if such an event is used upstream
-- or directly invoke the racestart component:
if inst.components.yotc_racestart then
inst.components.yotc_racestart:OnStartRace(inst) -- internal callback, not public API
end
Dependencies & tags
Components used:
yotc_racestart(attached, with callbacks)lootdropperworkableburnableinspectable(only on master)small_propagatorhauntable(viaMakeHauntableWork)
Tags:
- Adds:
structure,yotc_racestart - Checks:
burnt(viayotc_racestart.onburntandlootdropper.DropLoot),yotc_racestart(tag-based optimization)
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
racestartstring | string | "ANNOUNCE_CARRAT_START_RACE" | Localization key used for race start announcements. |
Main functions
OnStartRace(inst)
- Description: Initiates the race by playing the "use" animation and scheduling the gong hit event. Spawns three ghost racers with stat spreads derived from a reference racer’s stats. Must be called when the race should begin.
- Parameters:
inst(Entity) — the race start structure instance. - Returns: Nothing.
- Error states: No explicit error handling, but race starts only if
yotc_raceprizemanageris present (checked viaTheWorld.components.yotc_raceprizemanager).
OnEndRace(inst)
- Description: Ends the race by resetting animations (to "reset" → "idle"). Calls
yotc_racestart:EndRace()to remove therace_ontag. - Parameters:
inst(Entity) — the race start structure instance. - Returns: Nothing.
OnGongHit(inst)
- Description: Triggered after a fixed delay (
GONG_HIT_DELAY) fromOnStartRace. Plays the gong sound and invokesyotc_raceprizemanager:BeginRace(inst). - Parameters:
inst(Entity) — the race start structure instance. - Returns: Nothing.
onhammered(inst, worker)
- Description: Executed when the structure is fully hammered (workable finishes). Drops loot (adjusted for burn state), spawns a
collapse_bigFX, and removes the entity. - Parameters:
inst(Entity) — the race start structure instance.worker(Entity) — the entity performing the hammering.
- Returns: Nothing.
onburnt(inst)
- Description: Called when the structure finishes burning. Burns the rug sub-entity, removes the
yotc_racestartcomponent, sets animation to "burnt", and notifies the rug with"onburntup"event. - Parameters:
inst(Entity) — the race start structure instance. - Returns: Nothing.
SpawnGhostRacer(inst, num_stat_points)
- Description: Spawns a
carrat_ghostracerat a walkable offset from the race start, registers it with the race manager, sets its start point, adds random stat spread based onnum_stat_points, and saves stats as baseline. - Parameters:
inst(Entity) — the race start structure instance.num_stat_points(number) — desired total stat points to distribute (after clamping toBAD_STAT_SPREAD).
- Returns: Nothing.
SpawnGhostRacers(inst, race_data)
- Description: Helper that calls
SpawnGhostRacerthree times with varying stat formulas whenrace_data.num_racers == 1. Uses stat points from an existing racer to calibrate difficulty. - Parameters:
inst(Entity) — the race start structure instance.race_data(table?) — race metadata containingnum_racersand optionalracerslist. May benil.
- Returns: Nothing.
MakeRug(inst)
- Description: Spawns a
yotc_carrat_rugprefab and parents it to the race start structure for visual placement effect. - Parameters:
inst(Entity) — the race start structure instance. - Returns: Nothing.
OnSave(inst, data)
- Description: Serializes burn state for persistence: sets
data.burnt = trueif the structure is burnt or currently burning. - Parameters:
inst(Entity) — the race start structure instance.data(table) — the save data table to populate.
- Returns: Nothing.
OnLoad(inst, data)
- Description: Restores burn state during world load: triggers
onburntifdata.burntistrue. - Parameters:
inst(Entity) — the race start structure instance.data(table) — the loaded data table (may benil).
- Returns: Nothing.
Events & listeners
-
Listens to:
onbuilt— triggersonbuiltfunction to set animation and notify rug.yotc_race_over— triggersOnRaceOver, which callsyotc_racestart:EndRace().
-
Pushes:
- None directly. Internally, via sub-entity rug:
"onbuilt"and"onburntup". - Internally via
yotc_raceprizemanager:"BeginRace"is invoked when gong hits.
- None directly. Internally, via sub-entity rug: