GE Lua Documentation

Press F to search!

setupCrawlMarkers

Definition


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

local function setupCrawlMarkers(path)
  local pathId = path._filePath or path.id or path._id or tostring(path)
  if markersVisibleForPath == pathId then
    return
  elseif markersVisibleForPath ~= nil then
    markers.onClientEndMission()
  end
  markersVisibleForPath = pathId

  if not markers then
    markers = require('scenario/race_marker')
    markers.init()
  end

  if not path then
    log('W', logTag, 'No path available for trail')
    return
  end

  local wps = {}
  local markerModes = {}
  for i, pn in ipairs(path.nodes or {}) do
    if pn.pos then
      local dir = vec3(0, 1, 0)
      if pn.rotation then
        dir = pn.rotation * vec3(0, 1, 0)
      end

      table.insert(wps, {
        name = tostring(i),
        pos = pn.pos,
        radius = pn.radius or 6.0,
        normal = nil,
        delay = 0,
        dir = dir
      })
      markerModes[tostring(i)] = 'hidden'
    end
  end
  if path.nodes and #path.nodes > 0 then
    markerModes[tostring(#path.nodes)] = 'final'
  end

  markers.setupMarkers(wps,'crawlMarker')
  markers.setModes(markerModes)

  dottedPath = {}
  dottedPathTimer = -1
  local stepDist = 1.5

  if path and path.nodes and #path.nodes > 0 then
    local pathnodes = path.nodes
    local pathPositions = { be:getPlayerVehicle(0):getPosition()}
    for i, pn in ipairs(pathnodes) do
      if pn.pos then
        table.insert(pathPositions, pn.pos)
      end
    end

    local currentDist = 0
    local dotPos = vec3()

    for i = 1, #pathPositions - 1 do
      local currentPos = pathPositions[i]
      local nextPos = pathPositions[i + 1]
      if currentPos and nextPos then
        dotPos:set(currentPos)
        local direction = (nextPos - currentPos):normalized()
        local segmentLength = (nextPos - currentPos):length()
        local segmentEndDist = currentDist + segmentLength
        while currentDist < segmentEndDist-stepDist do
          dotPos = dotPos + direction*stepDist

          local terrainHeight = 0
          if core_terrain then
            terrainHeight = core_terrain.getTerrainHeight(dotPos) or dotPos.z
          end
          dotPos.z = terrainHeight + 1

          currentDist = currentDist + stepDist
          table.insert(dottedPath, {
            pos = vec3(dotPos),
            distanceFromStart = currentDist
          })
        end
      end
    end
  end

  isPreviewMode = true

end

Callers

@/lua/ge/extensions/gameplay/crawl/general.lua
      end
      gameplay_crawl_utils.setupCrawlMarkers(path)
    end
@/lua/ge/extensions/gameplay/crawl/utils.lua
  if path and path.nodes and #path.nodes > 0 then
    setupCrawlMarkers(path)
    activateCrawlMarkers()