World

class World
simulation/src/world.ts:178

Members

constructor

constructor(options: WorldOptions) → World
optionsWorldOptions
Undocumented

catalogreadonly

catalog: StarCatalog

clockreadonly

framesreadonly

frames: FrameGraph

galaxyreadonly

galaxy: GalaxyId

galaxySeedreadonly

galaxySeed: Seed

rootSeedreadonly

rootSeed: Seed

seedTextreadonly

seedText: string

entitiesaccessor

entities() → EntityView

The entities, to read. Every write is a verb on the world (EntityView).

structuresaccessor

structures() → readonly SurfacePlacement[]

Stable, immutable authored placements, including those in unloaded systems.

advance

advance(realSeconds: number) → number

Advance by wall-clock seconds. Returns the number of ticks actually run.

The only place real time enters the simulation, and all it decides is how many identical fixed steps to take — and how many of those may be taken one at a time.

realSecondsnumber
Undocumented

altitudeOf

altitudeOf(id: EntityId) → number | null
idEntityId
Undocumented

binding

binding(frame: FrameId) → FrameBinding | undefined

The binding governing a frame, walking up until one is found.

A ship in a surface frame is three levels below the body that is pulling on it, and this is what makes that work without registering a binding per landing site.

frameFrameId
Undocumented

bindingsUnder

bindingsUnder(frame: FrameId) → readonly FrameBinding[]
frameFrameId
Undocumented

bodyAt

bodyAt(frame: FrameId) → Body | null
frameFrameId
Undocumented

canonicalEntities

canonicalEntities() → readonly CanonicalEntity[]

Every entity as the facts that decide its next tick, in id order.

What a save captures and what the hash reads — one projection for both, which is the whole reason CanonicalEntity exists. landed is in it because it is the world's bookkeeping rather than the entity's, and the entity alone cannot say.

canonicalPositionOf

canonicalPositionOf(id: EntityId) → UniverseVector
idEntityId
Undocumented

contactHeight

contactHeight(body: Body) → number

Highest support above the body datum: the integrator's rails boundary, and the band above which a tick cannot touch anything on this body. Cached, because the integrator asks on every tick with a body binding and each answer is a terrain sample per placement.

bodyBody
Undocumented

contactRadius

contactRadius(body: Body, direction: BodyFixedDirection, terrain: number) → number

Terrain and any placed support disk compete by height, never insertion order.

bodyBody
Undocumented
directionBodyFixedDirection
Undocumented
terrainnumber
Undocumented

ensureFrame

ensureFrame(id: FrameId) → boolean

Re-create a frame from its id.

Surface frames are minted on landing rather than up front, so a save that has a ship parked on a planet refers to a frame that does not exist yet after a reload. Because terrain is a pure function of the seed, the frame can be regenerated exactly — which is the persistence model working as intended: store the reference, regenerate the content.

idFrameId
Undocumented

events

events(limit: number) → readonly WorldEvent[]
limitnumber
Undocumented

isCoasting

isCoasting(id: EntityId) → boolean

Whether an entity is coasting on rails rather than being integrated.

idEntityId
Undocumented

isLanded

isLanded(id: EntityId) → boolean
idEntityId
Undocumented

killRotation

killRotation(id: EntityId) → Entity

Zero the spin without disturbing the trajectory.

idEntityId
Undocumented

landedEntities

landedEntities() → readonly EntityId[]

loadedSystems

loadedSystems() → readonly StarSystem[]

loadSystem

loadSystem(id: SystemId) → StarSystem
idSystemId
Undocumented

moveStructure

moveStructure(placement: SurfacePlacement) → SurfacePlacement

A replacement is fully validated before the existing placement is touched.

placementSurfacePlacement
Undocumented

placeStructure

placeStructure(placement: SurfacePlacement) → SurfacePlacement
placementSurfacePlacement
Undocumented

previousState

previousState(id: EntityId) → FrameState | undefined
idEntityId
Undocumented

reframeEntity

reframeEntity(id: EntityId, frame: FrameId) → Entity

Move an entity into another frame without moving it in the universe.

idEntityId
Undocumented
frameFrameId
Undocumented

removeCharacter

removeCharacter(id: EntityId) → boolean

Release an on-foot avatar when control returns to its parked vessel.

idEntityId
Undocumented

removeStructure

removeStructure(id: string) → boolean
idstring
Undocumented

restoreDynamicIdCounter

restoreDynamicIdCounter(value: number) → void

Restore the dynamic id counter after a load, so a replay issues the same ids.

valuenumber
Undocumented

restoreLanded

restoreLanded(ids: readonly EntityId[]) → void

Restore internal bookkeeping after a load.

idsreadonly EntityId[]
Undocumented

runTicks

runTicks(count: number) → void

Run n ticks with no wall clock. Deterministic by construction.

countnumber
Undocumented

setCharacterFlightPermission

setCharacterFlightPermission(id: EntityId, canFly: boolean) → void

A session host reconciles restored privileges with its current authority.

idEntityId
Undocumented
canFlyboolean
Undocumented

setCharacterFlying

setCharacterFlying(id: EntityId, flying: boolean) → boolean

A host-granted capability is necessary even when callers bypass the HUD.

idEntityId
Undocumented
flyingboolean
Undocumented

setCharacterInput

setCharacterInput(id: EntityId, input: Partial<CharacterInput>) → Entity
idEntityId
Undocumented
inputPartial<CharacterInput>
Undocumented

setControl

setControl(id: EntityId, translation: Vec3, rotation: Vec3) → Entity

The thrusters and the attitude. The throttle stays where it was.

idEntityId
Undocumented
translationVec3
Undocumented
rotationVec3
Undocumented

setFlightAssist

setFlightAssist(id: EntityId, enabled: boolean) → boolean
idEntityId
Undocumented
enabledboolean
Undocumented

setThrottle

setThrottle(id: EntityId, throttle: number) → Entity

The main drive's throttle, 0..1, clamped there.

A setting rather than a held key: it stays where it is put until something puts it elsewhere, which is what lets a burn outlast a hand on the keyboard, a mode change and a save. Its own verb rather than a fourth argument to setControl because the two are set by different acts — a key edge writes the thrusters forty times a burn and never means to touch the drive.

idEntityId
Undocumented
throttlenumber
Undocumented

spawn

spawn(init: EntityInit) → Entity
initEntityInit
Undocumented

spawnCharacter

spawnCharacter(body: Body, latitude: number, longitude: number, options: { canFly?: boolean; heading?: number; vessel?: EntityId }) → Entity

Put a suited character's feet on canonical support. Contact earns groundedness. vessel is the ship it steps back into, and has to exist.

bodyBody
Undocumented
latitudenumber
Undocumented
longitudenumber
Undocumented
options{ canFly?: boolean; heading?: number; vessel?: EntityId }
Undocumented

spawnShip

spawnShip(name: string, frame: FrameId, position: Vec3, velocity: Vec3) → Entity

Spawn the debug spacecraft in a frame, at rest unless given a velocity.

The velocity is a spawn argument rather than a later write: a ship that begins in orbit, or falling, or inbound from interstellar space is spawned that way, so the interpolation history it is born with already describes that motion and nothing has to reach past the verbs to set it.

namestring
Undocumented
frameFrameId
Undocumented
positionVec3
Undocumented
velocityVec3
Undocumented

stateHash

stateHash() → string

A hash of everything canonical.

Two runs that agree on this agree on the universe. Used by the determinism tests, by the harness, and (later) as a desync check against a server.

angularVelocity, control and flightAssist are in here now. They were not, and the docstring said "everything canonical" anyway, so two worlds differing only in the fields that killRotation and flight assist write hashed identically at the instant they diverged. That matters because it is where a real bug already lived — a save taken mid-burn resumed coasting — and the persistence test caught it only by stepping 300 further ticks and letting the difference show up in position. This makes it detectable at the tick it happens.

The rails epoch is in it for the same reason: two worlds that agree on a coasting entity's state and disagree on its epoch diverge on the next tick, in the low bits, and a hash that ignored the epoch would call them equal.

Which fields, exactly, is entityState.ts's decision and not this method's: the line is written from CanonicalEntity, the same record the save carries, so the hash cannot count a field the save drops or the other way round. The thrust profile was that field — omitted here, reduced to a boolean there — and two worlds with different drives hashed equal until the first tick under throttle.

step

step() → void

Advance exactly one fixed tick.

An entity on rails is evaluated from its epoch rather than integrated, and its sphere-of-influence tests run only on a RAILS_CHUNK boundary — the same instants #jump tests at, so that stepping and jumping agree.

structuresOn

structuresOn(bodyAddress: string) → readonly SurfacePlacement[]

The placements on one body, by its formatted address; empty for a body with none.

bodyAddressstring
Undocumented

system

system(id: SystemId) → StarSystem | undefined
idSystemId
Undocumented

teleport

teleport(id: EntityId, state: FrameState) → Entity

Set an entity's state discontinuously.

Resets the interpolation history as well, which a plain update does not: the presentation layer lerps between the previous tick and this one, so a teleport without this smears the ship across the system for one frame. Only debug tooling should be calling it — nothing in normal play moves an entity without moving it.

idEntityId
Undocumented
stateFrameState
Undocumented

unloadSystem

unloadSystem(id: SystemId) → void
idSystemId
Undocumented

updateInterest

updateInterest(center: UniverseVector, radius: number) → { loaded: readonly SystemId[]; unloaded: readonly SystemId[] }

Load systems near a point and unload ones that are far away.

Ordinary control flow, called every so often rather than at a mode boundary. Systems containing an entity are never unloaded.

centerUniverseVector
Undocumented
radiusnumber
Undocumented