# VehicleSystem
Registers the metropolisVehicles package's vehicle presets with the vehiclesKit before any Vehicle component wakes, and runs per-frame updates for all vehicles in the scene. Attach it once to a plain entity in the scene to manage vehicle lamps, steering wheels, leans, wear, and ink effects.
# api
This module provides the public API for interacting with Metropolis vehicles. It allows game makers to install vehicle presets, query available vehicle kinds and their properties, spawn drivable or display-only vehicles, and request specific states (like lamps or wear) for vehicles. It is called by game code that needs to create, manage, or inspect vehicles within the Metropolis world.
# fleet
This module manages the parked vehicle population of a city, streaming them around players in three tiers: far (instanced models), standing (local entities with colliders and interaction prompts), and real (fully simulated vehiclesKit Vehicles). It is called by the game loop to update the visible vehicle population based on player proximity and to convert parked vehicles into drivable ones when a player interacts with them. The module uses a deterministic planning system based on the city plan and a seed to place vehicles consistently across peers.
# kinds
This module defines the data for every vehicle kind in the Metropolis package, including their physical properties, handling characteristics, wear stages, and available liveries. It is called by other vehicle modules to retrieve detailed information about specific vehicle types, such as their mass, engine, wheel setup, and visual attributes. Game makers can also use `Kinds.define` to add or replace vehicle kinds with their own custom data.
# look
This module defines the materials and shader parameters used by all vehicles in the Metropolis world. It provides three core materials (`paint`, `glass`, and `far`) that integrate with the `painterly` system for dynamic lighting and shading. Additionally, it offers functions to pack colors, manage vehicle-specific shader data (livery, lamps, wear), and write these parameters to entities. The module also handles the `ink` tagging for painterly's line pass, allowing for distinct visual outlines on vehicles. It is primarily called by `metropolisVehicles.resolver` and `metropolisVehicles.state` to manage vehicle appearance and lighting.
# meshes
This module provides references to the mesh assets for every vehicle model in the Metropolis package. It is generated from a manifest of GLB files and should not be edited manually. Other vehicle modules, such as `metropolisVehicles.fleet` and `metropolisVehicles.kinds`, call this module to access the specific mesh assets required for rendering vehicles at different levels of detail (e.g., Body, Cabin, Glass, Parked, Far models).
# resolver
This module integrates Metropolis vehicles with the `vehiclesKit` system by providing a resolver function. It parses vehicle preset names (e.g., `pm_finch.seafoam`) to extract the vehicle kind and livery. It then constructs a `vehiclesKit.Kind` object, defining the vehicle's layout (seats, wheels, colliders), `VehicleController` settings, and visual dressing (model, materials, shader lanes, ink). The module also includes functions to install and refresh this resolver with `vehiclesKit`, ensuring that Metropolis vehicles are correctly recognized and built within the kit's framework. It is primarily called by `metropolisVehicles.api` to make Metropolis vehicles available in the game.
# routes
This module provides tools for generating and managing lane routes within a city's road network, based on the `cityGen.query` plan. It allows callers to find the shortest drivable path between two points, or to generate a continuous "wander" route for ambient traffic. The module also offers functions to retrieve the center line of a specific lane on an edge, calculate lane offsets, and identify kerbside parking bays. It is primarily called by AI drivers or other systems that need to navigate vehicles through the city. Traffic adheres to right-hand driving rules, and stop lines are set back from junctions based on road class and width.
# ink
This shader defines the ink numbers for a vehicle's surface, used by the painterly frame's line pass. It assigns a unique ink value to different parts of the vehicle (e.g., paint, trim, glass, lamps) based on their `uv.x` slot. The painterly frame then draws a line where these different ink numbers meet, creating distinct visual outlines. This shader is used by the `metropolisVehicles.look` module to apply ink tagging to vehicle entities for rendering within the painterly system.
# paint
This shader applies cel-shaded paint to vehicle models, handling the entire vehicle with a single material. It uses `uv.x` slots to identify different parts of the vehicle (e.g., shell, trim, tires, lamps) and applies distinct visual properties to each. Vehicle-specific details like livery, lamp states, and wear are passed through instance data (four shader lanes). The shader simulates lighting based on the time of day (from `painterly.core` or the engine's sun), applying effects like lacquer sheen, metallic glint, and glass transparency. It also incorporates dirt and damage effects on painted panels. This shader is primarily used by the `metropolisVehicles.look` module to render the visual appearance of vehicles in the Metropolis world.
# state
This module manages the frame-by-frame state of every active Metropolis vehicle on a given peer. It registers dressed vehicles (added by `metropolisVehicles.resolver`) and updates their visual properties, such as lamps, steering wheel angles, scooter leans, and wear (damage, dirt, paint on glass). The module also handles the `ink` list for painterly rendering. It synchronizes vehicle state across peers by reading and writing replicated named values (`pm.show` for lamps, `pm.wear` for damage/dirt) on the vehicle's owner. It also provides hooks for game-layer events like crashes and tire marks. This module is called once per frame by the `VehicleSystem` component to ensure consistent and dynamic vehicle appearance and behavior.
# painterly
The `painterly.painterly` module mounts the Painted Valley look over a host's own land. It provides a complete visual system, including sky, clouds, time of day, ground paint, water, grass, flowers, trees, and shade. It is designed to be integrated into an existing world, taking its terrain, field dimensions, and axis, while allowing the host to control the hour, wind, and visual quality. The module returns a handle with methods to update the look each frame, set the hour, wind, and paint finish, and manage materials that integrate with the painterly system. It also provides access to tree and occluder controls, and methods to rebuild or destroy the mounted look.