Adding Encounters
The first thing needed to get encounters from Route Planning into the driving phase is to capture them into the route in the first place. Making a slight modification to the SpaceTruckerEncounterManager.onEncounter
function gets the job done:
const cargoData = this.cargo.lastFlightPoint; cargoData.encounter = encounter;
The addition to the code (highlighted) adds the encounter instance to the last telemetry data point in the route, making it available to us later when we process the route. In calculateRouteParameters
, we are making sure to include the encounter data in the resulting routePath
structure, along with the position, velocity, and gravitational acceleration.
Now that the encounters have been located and processed, we can spawn the encounters themselves. For the time being, we are creating a temporary spherical mesh in the constructor to serve as a template for when we spawn the encounters:
// temporary until the encounter spawner is implemented...