GE Lua Documentation

Press F to search!

updateCrawl

Definition


-- @/lua/ge/extensions/gameplay/crawl/utils.lua:1126


local function updateCrawl(dtSim)
  gameplay_crawl_boundary.updateBoundaryAnimations(dtSim)

  for crawlerId, state in pairs(crawlStates) do
    if not state or not state.active then
      return
    end

    if not state.crawlStarted then
      return
    end

    state.currentTime = state.currentTime + dtSim
    updateCrawlerData(crawlerId)

    local path = gameplay_crawl_general.activeTrail and gameplay_crawl_general.activeTrail.path
    local boundary = gameplay_crawl_general.activeTrail and gameplay_crawl_general.activeTrail.boundary

    if path and path.nodes then
      checkPathnodeReached(path.nodes, crawlerId)
    end

    if boundary then
      gameplay_crawl_boundary.checkBoundary(boundary, state.crawlerData, crawlStates)
    end

    checkInfractions(crawlerId, dtSim)
    digestCrawlEvents(crawlerId)

    -- Update lap times fast stream (every frame) - just update existing structure
    if core_lapTimes and state.raceData then
      updateRaceDataStructure(crawlerId, state, state.raceData)
      core_lapTimes.updateFastFromRace(state.raceData, crawlerId)
      core_lapTimes.updateStaticFromRace(state.raceData, crawlerId)
    end

    if state.crawlerData.points ~= state.crawlerData.lastPoints then
      gameplay_crawl_display.showPointsMessage(state.crawlerData.points)
      state.crawlerData.lastPoints = state.crawlerData.points

      if state.crawlerData.points >= infractionPoints.dnf and not state.isDisqualified then
        applyDNF(crawlerId)
      end
    end

    if state.completionStartTime > 0 then
      local elapsed = state.currentTime - state.completionStartTime
      if elapsed >= completionDelay and not state.isFromMission then
        stopCrawl()
      end
    end
  end

  -- Update lap times system (sends data to UI)
  if core_lapTimes then
    core_lapTimes.onUpdate(0, dtSim, 0)
  end
end

Callers

@/lua/ge/extensions/gameplay/crawl/general.lua
  if M.activeTrail then
    gameplay_crawl_utils.updateCrawl(dtSim)
  end