Worldroutes
Overview
The WorldRoutes component caches static, world-scale route data—specifically, precomputed circular paths across traverseable terrain—to avoid expensive real-time calculations. It exists only on the master simulation and is attached exclusively to TheWorld. Route data is stored as named collections of Vector3 points and supports serialization for save/load operations.
Dependencies & Tags
- Component Requirements: None explicitly added via
AddComponent. - Tags: None assigned or removed.
- Constraints: Requires
TheWorld.ismastersimto be true; must be attached toTheWorld.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil (assigned in _ctor) | Reference to TheWorld, set during construction and never modified. |
routes | table<string, vector3[]> | {} | Dictionary mapping route names to ordered lists of Vector3 points defining traversal paths. |
Main Functions
SetRoute(routename, route)
- Description: Stores or overwrites a named route (an array of
Vector3points) in the component's internalroutestable. - Parameters:
routename(string): Unique identifier for the route.route(vector3[]): Ordered list ofVector3positions defining the path.
GetRoute(routename)
- Description: Returns the stored route corresponding to the given name, or
nilif not found. - Parameters:
routename(string): Name of the route to retrieve.
OnSave()
- Description: Serializes all stored routes into a compact format suitable for world save files. Converts each
Vector3point to a 2-element numeric array[x, z]. Returnsnilif no routes exist. - Parameters: None.
OnLoad(data)
- Description: Deserializes route data from a previously saved state. Converts numeric
[x, z]arrays back intoVector3objects (yis hardcoded to0). Does nothing ifdataisnilor missing aroutesfield. - Parameters:
data(table?): Save data table, typically containing arouteskey with serialized route data.
Events & Listeners
None.