Chemistry · function

installLibrary

Species, then reactions, then substances — skipping whatever is already registered.

Explained in Chemistry.

function installLibrary(library: SubstanceLibrary, species: SpeciesRegistry, reactions: ReactionRegistry, substances: SubstanceRegistry): void
import { installLibrary } from '@driftengine/chemistry';

Parameters

ParameterTypeDescription
librarySubstanceLibrary
speciesSpeciesRegistry
reactionsReactionRegistry
substancesSubstanceRegistry

In depth

The skipping is the whole reason this is not three loops of register. Gas-phase combustion belongs to every family that burns, and registering an id twice throws by design, so a consumer installing organic and fuel together would otherwise fail at init on the first reaction they share. Skipping also makes installing a family twice a no-op rather than a crash, which is what a consumer assembling a world out of several libraries will do by accident sooner or later.

It does not check that the existing registration matches. Two libraries declaring different reactions under one id would silently take the first, and nothing here would say so — but every id in these libraries is defined in exactly one place, and a consumer who shadows one has said something deliberate. Refusing it would mean comparing stoichiometry and kinetics for equality, which is a real cost at init for a case the libraries themselves cannot produce.