@adatechnology/game-urban 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,8 +75,8 @@ const plan = urban.neighbourhoods.get('suburb').compose(b, { x: 0, z: 0 }, {
75
75
  locale: 'en',
76
76
  providers: {
77
77
  house: (typology, request, b) => myHouse(typology, request, b), // default: the far-away silhouettes of game-floorplan
78
- vehicle: createVehicleProvider(), // default: none (the page's box car is not shipped)
79
- plant: createPlantProvider(), // default: the cone pine and the ball tree of the props
78
+ vehicle: createVehicleProvider({ ids: myFleetIds }), // default: none (the page's box car is not shipped)
79
+ plant: createPlantProvider({ pickSpecies: myPicker }), // default: the cone pine and the ball tree of the props
80
80
  },
81
81
  })
82
82
  // plan: { id, origin, houses, buildings, poles, vehicles, plants } (what was put where)
@@ -85,7 +85,7 @@ urban.neighbourhoods.composeSampleSheet(b) // the ground and the ten cells, in
85
85
 
86
86
  ### Vehicles and plants from the other packages
87
87
 
88
- `createVehicleProvider({ ids?, pick?, paint? })` parks a vehicle of `game-vehicles-fleet` (cars, SUVs, pickups and vans by default) where a pattern parks one, and `createPlantProvider({ region?, contexts?, seed?, pick? })` plants a species of `game-vegetation-species` where a pattern plants (a tree from the region's `sidewalk_tree` table, a pine from `square`). They do not draw: they add a `placement` part (`b.place(kind, id, x, z, { ry, scale, color, seed })`) that says what to put and where. The choice depends on the spot and not on `b.random`, so the scene around it keeps the same draw order. The drawer (`game-urban-three`) asks a resolver for each kind and leaves the spot empty when it has none.
88
+ `createVehicleProvider({ ids, pick?, paint? })` parks a vehicle of the fleet the game names in `ids` where a pattern parks one, and `createPlantProvider({ pickSpecies, contexts?, seed?, pick? })` plants the species `pickSpecies(context, key)` returns where a pattern plants (a tree from the `sidewalk_tree` context, a pine from `square`). The fleet and the species come by option (the recommended path; the preset `defaultUrbanProviders()` of `@adatechnology/game-kit-defaults` uses it). Without them the providers keep the old defaults, `PARKED_VEHICLE_IDS` of `game-vehicles-fleet` and the regional tables of `game-vegetation-species`; those defaults are deprecated and removed in the next major. They do not draw: they add a `placement` part (`b.place(kind, id, x, z, { ry, scale, color, seed })`) that says what to put and where. The choice depends on the spot and not on `b.random`, so the scene around it keeps the same draw order. The drawer (`game-urban-three`) asks a resolver for each kind and leaves the spot empty when it has none.
89
89
 
90
90
  ## City plans (zoning)
91
91
 
package/dist/index.d.ts CHANGED
@@ -325,16 +325,23 @@ type UrbanScene = {
325
325
  dark: SilhouetteWindow[];
326
326
  };
327
327
  };
328
- /** The lights a scene may spend. Every lamp that is on takes one, and the first ones win; the rest keep only their glowing lens. */
329
- type LightBudget = {
328
+ /**
329
+ * How many lights a scene may spend (a counter, not the render budget of `@adatechnology/game-render-three`). Every lamp that is on takes one, and the first ones win; the rest keep only their
330
+ * glowing lens.
331
+ */
332
+ type LightAllowance = {
330
333
  /** Lights left. It goes below zero when more lamps ask than the budget had, as the team's counter does. */
331
334
  left: number;
332
335
  /** True while the budget lasts (spends one either way). */
333
336
  take(): boolean;
334
337
  };
338
+ /** @deprecated Renamed `LightAllowance`: `LightBudget` is the name of the render budget of `@adatechnology/game-render-three`. Removed in the next major. */
339
+ type LightBudget = LightAllowance;
335
340
 
336
- /** The team's counter: `take()` is `left-- > 0`, so the count keeps falling after the budget is spent. */
337
- declare function createLightBudget(count: number): LightBudget;
341
+ /** The team's counter: `take()` is `left-- > 0`, so the count keeps falling after the allowance is spent. */
342
+ declare function createLightAllowance(count: number): LightAllowance;
343
+ /** @deprecated Renamed `createLightAllowance`: `LightBudget` is the name of the render budget of `@adatechnology/game-render-three`. Removed in the next major. */
344
+ declare const createLightBudget: typeof createLightAllowance;
338
345
 
339
346
  type BoxOptions = {
340
347
  parent?: number;
@@ -345,7 +352,7 @@ type BoxOptions = {
345
352
  };
346
353
  type UrbanBuilderOptions = {
347
354
  /** Lights the scene may spend; omitted means no limit. */
348
- budget?: LightBudget;
355
+ budget?: LightAllowance;
349
356
  };
350
357
  /**
351
358
  * Collects the parts of an urban scene the way the team's page adds them to its root: every helper appends in call order, so a
@@ -355,7 +362,7 @@ type UrbanBuilderOptions = {
355
362
  declare function createUrbanBuilder(random: RandomSource, options?: UrbanBuilderOptions): {
356
363
  random: RandomSource;
357
364
  pick: <TEntry>(list: readonly TEntry[]) => TEntry;
358
- lights: LightBudget;
365
+ lights: LightAllowance;
359
366
  parts: UrbanPart[];
360
367
  items: ItemBox[];
361
368
  windows: {
@@ -1180,6 +1187,8 @@ type Terrain = ReturnType<typeof createTerrain>;
1180
1187
  declare function drawTerrain(b: UrbanBuilder, terrain: Terrain, segments?: number): void;
1181
1188
 
1182
1189
  /** Lights a scene may spend: the Galeria spends 16 real point lights. */
1190
+ declare const DEFAULT_LIGHT_ALLOWANCE = 16;
1191
+ /** @deprecated Renamed `DEFAULT_LIGHT_ALLOWANCE`. Removed in the next major. */
1183
1192
  declare const DEFAULT_LIGHT_BUDGET = 16;
1184
1193
  /** Seed of the Galeria's generator. */
1185
1194
  declare const DEFAULT_URBAN_SEED = 7;
@@ -1721,10 +1730,13 @@ declare const SILHOUETTE_TYPOLOGIES: Readonly<Record<string, SilhouetteFactory>>
1721
1730
  /** The default provider: the silhouette of game-floorplan for the typology, added to the builder with its shared random. */
1722
1731
  declare function createSilhouetteHouses(typologies?: Readonly<Record<string, SilhouetteFactory>>): HouseProvider;
1723
1732
 
1724
- /** The vehicles of the fleet that park on a street: cars, SUVs, pickups and vans. */
1733
+ /**
1734
+ * The vehicles of the fleet that park on a street: cars, SUVs, pickups and vans.
1735
+ * @deprecated the fleet is content: pass `ids` to `createVehicleProvider` (`PARKED_VEHICLE_IDS` of `@adatechnology/game-kit-defaults` is the same list). The default is removed in the next major.
1736
+ */
1725
1737
  declare const PARKED_VEHICLE_IDS: readonly string[];
1726
1738
  type VehicleProviderOptions = {
1727
- /** Ids of the fleet to choose from. Default `PARKED_VEHICLE_IDS`. */
1739
+ /** Ids of the fleet to choose from. Default `PARKED_VEHICLE_IDS`, which is deprecated: pass the ids (`game-kit-defaults` has the same list). */
1728
1740
  ids?: readonly string[];
1729
1741
  /** Replaces the choice: the id for a request. The default picks by the spot, so the same pattern parks the same cars every time. */
1730
1742
  pick?: (request: VehicleRequest, ids: readonly string[]) => string;
@@ -1737,7 +1749,12 @@ type VehicleProviderOptions = {
1737
1749
  */
1738
1750
  declare function createVehicleProvider(options?: VehicleProviderOptions): VehicleProvider;
1739
1751
  type PlantProviderOptions = {
1740
- /** Planting table of a region. Default Brazil's. */
1752
+ /** Chooses the species id for a context of the planting table and a key (`defaultPlantPicker` of `game-kit-defaults`, or the game's own). Without it the species come from the `region` table (deprecated default). */
1753
+ pickSpecies?: (context: string, key: string) => string;
1754
+ /**
1755
+ * Planting table of a region, used only when `pickSpecies` is absent. Default Brazil's.
1756
+ * @deprecated pass `pickSpecies`; the default is removed in the next major.
1757
+ */
1741
1758
  region?: Region;
1742
1759
  /** Context of the table for each kind the patterns plant. */
1743
1760
  contexts?: Partial<Record<PlantRequest['kind'], string>>;
@@ -1747,7 +1764,7 @@ type PlantProviderOptions = {
1747
1764
  pick?: (request: PlantRequest, context: string, seed: string) => string;
1748
1765
  };
1749
1766
  declare const DEFAULT_PLANT_CONTEXTS: Readonly<Record<PlantRequest['kind'], string>>;
1750
- /** A plant provider that asks the drawer for a species of the pack, drawn from the region's table for the kind (a tree on the sidewalk, a pine in the square). */
1767
+ /** A plant provider that asks the drawer for a species chosen by `pickSpecies`, from the table of the context for the kind (a tree on the sidewalk, a pine in the square). */
1751
1768
  declare function createPlantProvider(options?: PlantProviderOptions): PlantProvider;
1752
1769
 
1753
1770
  /** The ten patterns of the Galeria's sample sheet, in the order the page builds them. */
@@ -1766,4 +1783,4 @@ declare const TOWER_SAMPLE_CELLS: Readonly<Record<string, {
1766
1783
  z: number;
1767
1784
  }>>;
1768
1785
 
1769
- export { type BarSpec, type Block, type BlockBuilding, type BlockUse, type BuilderOptions, type BuildingOptions, COMPOSERS, type Cities, type CitiesOptions, type CityLayout, type CityPlanDef, type CityPlanInput, type CityScale, type ColorRule, type ComposeContext, type ComposeOptions, type Composer, type ConePart, type CrossarmSpec, type CrownPart, DEFAULT_CITY_PLANS, DEFAULT_DISTRICT_KINDS, DEFAULT_FACADES, DEFAULT_LIGHT_BUDGET, DEFAULT_MAX_FLOORS, DEFAULT_PATTERNS, DEFAULT_PLANT_CONTEXTS, DEFAULT_POLES, DEFAULT_PROP_COLORS, DEFAULT_ROAD_STYLE, DEFAULT_STOREY_PRESETS, DEFAULT_STREET, DEFAULT_TOWER_PRESETS, DEFAULT_URBAN_SEED, DEFAULT_WALK_STYLE, type DistrictKindDef, type DistrictKindText, type DoubleArmSpec, type DowntownParams, type FillBlockCityOptions, type FillBlockOptions, type Flatten, type FloodTowerSpec, type ForestOptions, type HistoricParams, type HouseProvider, type HouseRequest, type IndustrialParams, type ItemBox, type KindStats, type LabelPart, type Lake, type LampLightSpec, type LampSpec, type LanternSpec, type LayoutOptions, type LensSpec, type LightBudget, type LightPart, type Locale, type MastSpec, type MilitaryParams, type MountainParams, type NeighbourhoodPattern, type Origin, PARKED_VEHICLE_IDS, POLE_SHAPES, type PartStyle, type PatternText, type PlacementPart, type PlanDistrict, type PlanLandmark, type PlanLine, type PlanPoint, type PlanRect, type PlanePart, type PlantProvider, type PlantProviderOptions, type PlantRequest, type Point, type Pole, type PoleDef, type PoleOptions, type PoleShapeBuilder, type PropColors, type Providers, type RailwayParams, type Ramp, type Rect, type ResolvedDistrict, type River, type RiverBed, type RoadStyle, type RuralParams, SAMPLE_CELLS, SILHOUETTE_TYPOLOGIES, type SampleSheetOptions, type SilhouetteFactory, type SingleArmSpec, type StiltParams, type StreetOptions, type SuburbParams, TOWER_DEFAULTS, TOWER_PATTERNS, TOWER_SAMPLE_CELLS, type Terrain, type TerrainGrid, type TerrainLayer, type TerrainOptions, type TerrainPart, type TowerOptions, type TowerPreset, type TowerProvider, type TowerRequest, type Trig, type UrbanBuilder, type UrbanBuilderOptions, type UrbanKit, type UrbanKitCore, type UrbanOptions, type UrbanPart, type UrbanPlan, type UrbanScene, type VaultPart, type VehicleProvider, type VehicleProviderOptions, type VehicleRequest, type WalkStyle, type Wave, type WorkingClassParams, type WorldFrame, clamp, composePattern, createCities, createLightBudget, createPlantProvider, createSilhouetteHouses, createTerrain, createTowerDrawer, createUrban, createUrbanBuilder, createVehicleProvider, distanceToPolyline, drawBuilding, drawContainer, drawFence, drawGround, drawPine, drawRoad, drawSandbags, drawStreetGrid, drawStripLabel, drawTent, drawTerrain, drawTower, drawTree, drawWalk, drawWatchtower, drawWires, fillBlock, hash2, insideEllipse, insideRect, lerp, patternMarker, pickTowerPreset, smoothstep, towerPresetOf, towerStoreys };
1786
+ export { type BarSpec, type Block, type BlockBuilding, type BlockUse, type BuilderOptions, type BuildingOptions, COMPOSERS, type Cities, type CitiesOptions, type CityLayout, type CityPlanDef, type CityPlanInput, type CityScale, type ColorRule, type ComposeContext, type ComposeOptions, type Composer, type ConePart, type CrossarmSpec, type CrownPart, DEFAULT_CITY_PLANS, DEFAULT_DISTRICT_KINDS, DEFAULT_FACADES, DEFAULT_LIGHT_ALLOWANCE, DEFAULT_LIGHT_BUDGET, DEFAULT_MAX_FLOORS, DEFAULT_PATTERNS, DEFAULT_PLANT_CONTEXTS, DEFAULT_POLES, DEFAULT_PROP_COLORS, DEFAULT_ROAD_STYLE, DEFAULT_STOREY_PRESETS, DEFAULT_STREET, DEFAULT_TOWER_PRESETS, DEFAULT_URBAN_SEED, DEFAULT_WALK_STYLE, type DistrictKindDef, type DistrictKindText, type DoubleArmSpec, type DowntownParams, type FillBlockCityOptions, type FillBlockOptions, type Flatten, type FloodTowerSpec, type ForestOptions, type HistoricParams, type HouseProvider, type HouseRequest, type IndustrialParams, type ItemBox, type KindStats, type LabelPart, type Lake, type LampLightSpec, type LampSpec, type LanternSpec, type LayoutOptions, type LensSpec, type LightAllowance, type LightBudget, type LightPart, type Locale, type MastSpec, type MilitaryParams, type MountainParams, type NeighbourhoodPattern, type Origin, PARKED_VEHICLE_IDS, POLE_SHAPES, type PartStyle, type PatternText, type PlacementPart, type PlanDistrict, type PlanLandmark, type PlanLine, type PlanPoint, type PlanRect, type PlanePart, type PlantProvider, type PlantProviderOptions, type PlantRequest, type Point, type Pole, type PoleDef, type PoleOptions, type PoleShapeBuilder, type PropColors, type Providers, type RailwayParams, type Ramp, type Rect, type ResolvedDistrict, type River, type RiverBed, type RoadStyle, type RuralParams, SAMPLE_CELLS, SILHOUETTE_TYPOLOGIES, type SampleSheetOptions, type SilhouetteFactory, type SingleArmSpec, type StiltParams, type StreetOptions, type SuburbParams, TOWER_DEFAULTS, TOWER_PATTERNS, TOWER_SAMPLE_CELLS, type Terrain, type TerrainGrid, type TerrainLayer, type TerrainOptions, type TerrainPart, type TowerOptions, type TowerPreset, type TowerProvider, type TowerRequest, type Trig, type UrbanBuilder, type UrbanBuilderOptions, type UrbanKit, type UrbanKitCore, type UrbanOptions, type UrbanPart, type UrbanPlan, type UrbanScene, type VaultPart, type VehicleProvider, type VehicleProviderOptions, type VehicleRequest, type WalkStyle, type Wave, type WorkingClassParams, type WorldFrame, clamp, composePattern, createCities, createLightAllowance, createLightBudget, createPlantProvider, createSilhouetteHouses, createTerrain, createTowerDrawer, createUrban, createUrbanBuilder, createVehicleProvider, distanceToPolyline, drawBuilding, drawContainer, drawFence, drawGround, drawPine, drawRoad, drawSandbags, drawStreetGrid, drawStripLabel, drawTent, drawTerrain, drawTower, drawTree, drawWalk, drawWatchtower, drawWires, fillBlock, hash2, insideEllipse, insideRect, lerp, patternMarker, pickTowerPreset, smoothstep, towerPresetOf, towerStoreys };