Mapmgr Module Reference
Module defined in `lua/vehicle/mapmgr.lua`. This module interfaces the vehicle with the global navigation graph (NavGraph), handles tracking of nearby vehicles, and provides world analysis tools like
Module defined in lua/vehicle/mapmgr.lua. This module interfaces the vehicle with the global navigation graph (NavGraph), handles tracking of nearby vehicles, and provides world analysis tools like road finding and ground normal estimation.
- AI: For higher-level pathfinding logic that uses mapmgr data.
- Sensors: For physical world sensing.
| Variable | Description |
|---|
mapData | The core graphpath object containing the level's road network, nodes, and edges. |
objects | A table containing state data (position, velocity, etc.) for all other tracked vehicles in the world. |
objectCollisionIds | A list of object IDs currently in physical contact with this vehicle. |
changeSet | Tracks recent drivability changes in the NavGraph (e.g., roads becoming blocked). |
| Function | Signature | Description |
|---|
mapmgr.findClosestRoad | (pos, wZ) | Finds the nearest road edge using a KD-Tree. Returns nodeA, nodeB, and distance. |
mapmgr.findBestRoad | (pos, dir, wZ) | Similar to findClosestRoad, but weights results based on the vehicle's heading and road one-way rules. |
mapmgr.getPointToPointPath | (start, target, cutOff, dirMult, ...) | Calculates the shortest path between two world coordinates using the NavGraph. |
mapmgr.surfaceNormalBelow | (pos, radius) | Estimates the ground surface normal vector by sampling heights in a triangular pattern around the point. |
| Function | Signature | Description |
|---|
mapmgr.getObjects | () | Returns the most recent snapshot of all nearby vehicle objects. |
mapmgr.enableTracking | (name) / disableTracking(force) | Starts or stops reporting this vehicle's state (position, damage, signals) to the global map manager. |
mapmgr.sendTracking | () | Serializes and transmits local state data (horn, lights, ignition, damage) to the Game Engine. Automatically called during onGraphicsStep. |
| Function | Signature | Description |
|---|
mapmgr.setSignals | (data) / updateSignals(data) | Internal synchronization for traffic light states. |
| Function | Signature | Description |
|---|
mapmgr.requestMap | () | Requests a fresh NavGraph snapshot from the Game Engine. |
mapmgr.setMap | (serial) | Imports a new navigation graph from the engine's mailbox. |
mapmgr.init | () / reset() | Standard lifecycle hooks. Initializes tracking and clears object caches. |
module.updateDrivabilities | () | Dynamically Change edge Drivability for the Navgraph |
module.setCustomMap | (map) | Sets the custom map. |