Log inGet started
Package

body.component

Newest version

README.md

firstlight.body

The survivor's body, and the record of the run. Attached to GameDirector by the scene build.

What it runs, every play frame

  • Where the local player stands: Rules.state.body.indoors is true inside the living hut's footprint; nearFire (0..1) is the stove's warmth reaching the body, full within a metre of the firebox and gone at fireReachM.
  • coreC: loses lossPerDegree per second per degree the felt temperature sits below comfortC — the hut's insideC indoors, the weather's chillC outdoors — multiplied by 1 + 2.5 * wet; gains fireGain * nearFire. At -40 C in still air a warm body dies in about 15 real minutes (1.5 in-game days); by a high stove it is back to normal in three.
  • kcal: Rules.KCAL_PER_DAY_REST per day at rest indoors, toward Rules.KCAL_PER_DAY_WORK moving outdoors.
  • wet: snow and storm soak clothes outdoors; the fire dries them.
  • frostbite below Rules.CORE_C_FROSTBITE: the avatar's CharacterController.moveSpeed is scaled by frostbiteSpeed until the core recovers.
  • Death at Rules.CORE_C_DEATH or Rules.KCAL_DEATH, through firstlight.legacy: the run ends, the last journal line is written, the cache is stashed, the save is written and death { cause, day } is emitted. A death another slice emits (the bear) is handled the same way.
  • Sleep (sleep event): eight hours of rest at the hut's warmth.
  • The journal: a line for the day that ended on every day event.
  • The save: firstlight.persist writes run, body, hut, stores and journal on every day, sleep, death, patch and (throttled) store change, and on leaving play; it reads them back at awake so a reload resumes the same morning. The forecast seed is chosen once per world at the first load.

Methods (call with a colon on entity.find("GameDirector").component.get("body"))

MethodDoesReturns
body:eat(kcal)Adds calories (a tin is about 800).calories held (number)
body:warm(degrees)Warms the core directly (a hot meal).core C (number)
body:newRun()Starts the next run from the death screen: body, clock and stores reset to the start values plus the cache; journal, seed, deaths, patched gaps and drilled hole stay. Emits newRun { deaths, cache }.—
body:save()Writes the save now.—
body:state(){ coreC, kcal, wet, frostbite, indoors, nearFire, alive, day }table