turretsKit.package
README.md
turretsKit.catalog
Every turret type and look style, read from data. Turret types are the .data files
bound to the turretsKit.turretType contract (the kit ships twelve in turrets/);
styles are the ones bound to turretsKit.turretStyle (scifi, medieval, toy in
styles/). A designer adds a turret by adding a data file anywhere in the world, or
from code with define. Everything is read lazily and cached; reload() forgets the
cache (the Turret component rebuilds when version() changes).
Used by every other turretsKit module; turretsKit.api re-exports define and
defineStyle.
Fields
TARGETING:{ "first", "last", "nearest", "strongest", "weakest" }.STYLES_BUILTIN:{ "scifi", "medieval", "toy" }.MAX_TIER:3.STAT_DEFAULTS: every number a tier can carry and its fallback (e.g.fireRate = 1,range = 10,damage = 10,burst = 1,chainRange = 4,chainFalloff = 0.8,pierce = 1,rampMax = 1,rampTime = 2,blockRadius = 1.4,barrels = 1,scale = 1,cost = 0; the rest default to 0).
Functions
color(c: any, fallback: { number }?): { number }:"#rrggbb",{ r, g, b }or{ 1, 1, 1 }as{ r, g, b }in 0..1.reload(): forgets the cached data and bumps the version.version(): number: goes up on every reload, so callers can tell their copy is stale.type(id: string): any: one turret type (normalised:colorRgb,shape, tierindexand names filled in), ornil.typeIds(): { string }: every type id, the kit's twelve first in catalogue order.style(id: string): any: one style (withbodyRgb,trimRgb,baseRgb,glowRgb), ornil.styleIds(): { string }: every style id (scifi, medieval, toy first).define(id: string, def: any, base: string?): any: adds or replaces a turret type from a table shaped like a turretType file's values;basecopies another type first. Needs at least one tier.defineStyle(id: string, def: any, base: string?): any: adds or replaces a style;shotsentries merge over the base's.undefine(id: string): removes a type or style added withdefine/defineStyle.tier(t: any, n: number): any: a type's tier table (rounded, clamped to its tiers).stats(t: any, n: number, boost: any?): any: resolved numbers of a type at a tier: everySTAT_DEFAULTSkey,tier,tierName,baseFireRate/baseDamage/baseRange, turn limits and speeds (withturnBoost),specialandspecialValue.boostis{ fireRate, damage, range }fractions (0.25 = +25%).costs(t: any, n: number): any:{ build, spent, upgrade (nil at max), sell, sellRate, maxTier }.isTargeting(name: string): boolean: whether a targeting mode name is inTARGETING.