Testing reduced traces, added fast display toggle

This commit is contained in:
Dan
2019-11-25 19:32:40 +00:00
parent 823124fffa
commit 79c82499f2

View File

@@ -116,11 +116,11 @@ RADAR.activeVehicles = {}
-- These vectors are used in the custom ray tracing system
RADAR.rayTraces = {
-- { startVec = { x = 0.0, y = 5.0 }, endVec = { x = 0.0, y = 150.0 }, rayType = "same" },
-- { startVec = { x = -5.0, y = 15.0 }, endVec = { x = -5.0, y = 150.0 }, rayType = "same" },
-- { startVec = { x = 5.0, y = 15.0 }, endVec = { x = 5.0, y = 150.0 }, rayType = "same" },
{ startVec = { x = 0.0, y = 5.0 }, endVec = { x = 0.0, y = 150.0 }, rayType = "same" },
{ startVec = { x = -5.0, y = 15.0 }, endVec = { x = -5.0, y = 150.0 }, rayType = "same" },
{ startVec = { x = 5.0, y = 15.0 }, endVec = { x = 5.0, y = 150.0 }, rayType = "same" },
{ startVec = { x = -10.0, y = 15.0 }, endVec = { x = -10.0, y = 150.0 }, rayType = "opp" },
{ startVec = { x = -15.0, y = 15.0 }, endVec = { x = -15.0, y = 150.0 }, rayType = "opp" }
{ startVec = { x = -10.0, y = 15.0 }, endVec = { x = -10.0, y = 150.0 }, rayType = "opp" }
}
-- Each of these are used for sorting the captured vehicle data, depending on what the
@@ -161,6 +161,14 @@ function RADAR:TogglePower()
self.vars.power = not self.vars.power
end
function RADAR:IsFastDisplayEnabled()
return self.vars.settings.fastDisplay
end
function RADAR:ToggleFastDisplay()
self.vars.settings.fastDisplay = not self.vars.settings.fastDisplay
end
--[[------------------------------------------------------------------------
Radar basics functions
@@ -316,7 +324,7 @@ function RADAR:GetVehsHitByRay( ownVeh, vehs, s, e )
end
function RADAR:CreateRayThread( vehs, from, startX, endX, endY, rayType )
Citizen.CreateThread( function()
-- Citizen.CreateThread( function()
local startP = GetOffsetFromEntityInWorldCoords( from, startX, 0.0, 0.0 )
local endP = GetOffsetFromEntityInWorldCoords( from, endX, endY, 0.0 )
@@ -326,7 +334,7 @@ function RADAR:CreateRayThread( vehs, from, startX, endX, endY, rayType )
-- UTIL:DebugPrint( "Ray thread: increasing ray state from " .. tostring( self:GetRayTraceState() ) .. " to " .. tostring( self:GetRayTraceState() + 1 ) )
self:IncreaseRayTraceState()
end )
-- end )
end
function RADAR:CreateRayThreads( ownVeh, vehicles )
@@ -605,17 +613,19 @@ function RADAR:GetVehiclesForAntenna()
end
end
if ( self:IsFastDisplayEnabled() ) then
-- Get the 'fastest' vehicle for the antenna
table.sort( vehs[ant], self:GetFastestSortFunc() )
for k, v in pairs( vehs[ant] ) do
if ( self:CheckVehicleDataFitsMode( ant, v.rayType ) and v.veh ~= results[ant][1].veh ) then
if ( self:CheckVehicleDataFitsMode( ant, v.rayType ) and v.veh ~= results[ant][1].veh and v.size + 1.0 < results[ant][1].size ) then
results[ant][2] = v
break
end
end
end
end
end
return { results["front"][1], results["front"][2], results["rear"][1], results["rear"][2] }
end
@@ -642,6 +652,11 @@ function RADAR:RunControlManager()
UTIL:Notify( "Radar power toggled." )
end
if ( IsDisabledControlJustPressed( 1, 118 ) ) then
self:ToggleFastDisplay()
UTIL:Notify( "Fast display toggled." )
end
-- 'Num8' key, toggles front antenna
if ( IsDisabledControlJustPressed( 1, 111 ) ) then
self:ToggleAntenna( "front" )
@@ -722,7 +737,7 @@ Citizen.CreateThread( function()
while ( true ) do
RADAR:Main()
Citizen.Wait( 50 )
Citizen.Wait( 100 )
end
end )