Log inGet started
Package

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, tier index and names filled in), or nil.
  • typeIds(): { string }: every type id, the kit's twelve first in catalogue order.
  • style(id: string): any: one style (with bodyRgb, trimRgb, baseRgb, glowRgb), or nil.
  • 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; base copies another type first. Needs at least one tier.
  • defineStyle(id: string, def: any, base: string?): any: adds or replaces a style; shots entries merge over the base's.
  • undefine(id: string): removes a type or style added with define/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: every STAT_DEFAULTS key, tier, tierName, baseFireRate/baseDamage/baseRange, turn limits and speeds (with turnBoost), special and specialValue. boost is { 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 in TARGETING.