onRaceWaypointReached
Definition
-- @/lua/ge/extensions/core/checkpoints.lua:109
local function onRaceWaypointReached(data)
local scenario = scenario_scenarios.getScenario()
if not scenario then
return
end
-- log('I', logTag,'onRaceWaypointReached called')
-- dump(data)
local vehWpData = scenario_waypoints.getVehicleWaypointData(data.vehicleId)
-- dump(vehWpData)
local cpData = {}
cpData.desiredPos = data.curPos
-- TODO(AK): Don't use the next way point to determine the direction. it could be behind the vehicle and make it face the wrong direction.
-- May be try the direction of the waypoint or use the vehicle direction
if vehWpData.nextWp then
cpData.desiredDir = nil--(data.curPos - vehWpData.nextWp.pos):normalized()
end
-- For directional waypoints, use the direction of the waypoints
if data.curRot then
cpData.desiredDir = data.curRot
-- For other waypoints, use the velocity direction of the vehicle
else
local vehicleData = map.objects[data.vehicleId]
local vehicleVelocity = vehicleData.vel
cpData.desiredDir = vehicleVelocity
end
cpData.currentWpName = data.waypointName
cpData.currentWpIndex = data.cur
cpData.nextWpIndex = data.next
saveCheckpoint(data.vehicleId, data.vehicleName, cpData)
local state = M.state
local vehicleCheckpoints = state.vehicleCheckpoints
local aiVehiclePath = state.aiVehiclePath
if scenario_waypoints.isFinalWaypoint(data.vehicleId, data.waypointName) then
vehicleCheckpoints[data.vehicleId].raceOver = true
end
if aiVehiclePath[data.vehicleId] then
-- dump(aiVehiclePath[data.vehicleId])
-- dump(data.waypointName)
local waypoints = aiVehiclePath[data.vehicleId].waypoints
for index, wpName in ipairs(waypoints) do
if wpName == data.waypointName then
-- log('I', logTag,'removing '..wpName)
table.remove(waypoints, index)
break
end
end
-- dump(aiVehiclePath[data.vehicleId])
end
end
Callers
@/lua/ge/extensions/scenario/raceGoals.lua
local function onRaceWaypointReached(data)
local scenario = scenario_scenarios.getScenario()
@/lua/ge/extensions/flowgraph/nodes/timetrials/onRaceCheckpoint.lua
function C:onRaceWaypointReached(data)
self.pinOut.vehId.value = data.vehId
@/lua/ge/extensions/scenario/quickRace.lua
local function onRaceWaypointReached( wpInfo )
if not scenario_scenarios.getScenario().isQuickRace then return end
@/lua/ge/extensions/scenario/raceUI.lua
local function onRaceWaypointReached( data )
local scenario = scenario_scenarios.getScenario()
@/lua/ge/extensions/core/hotlapping.lua
local function onRaceWaypointReached(wpInfo)
if wpInfo.vehId ~= be:getPlayerVehicleID(0) then return end
@/lua/ge/extensions/util/richPresence.lua
local function onRaceWaypointReached(data)
if Steam then
@/lua/ge/extensions/core/lapTimes.lua
local function onRaceWaypointReached(wpInfo)
-- Legacy hook - not used in new system