mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
Testing reduced traces, added fast display toggle
This commit is contained in:
41
cl_radar.lua
41
cl_radar.lua
@@ -116,11 +116,11 @@ RADAR.activeVehicles = {}
|
|||||||
|
|
||||||
-- These vectors are used in the custom ray tracing system
|
-- These vectors are used in the custom ray tracing system
|
||||||
RADAR.rayTraces = {
|
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 = 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 = -10.0, y = 15.0 }, endVec = { x = -10.0, y = 150.0 }, rayType = "opp" }
|
||||||
{ 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" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Each of these are used for sorting the captured vehicle data, depending on what the
|
-- 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
|
self.vars.power = not self.vars.power
|
||||||
end
|
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
|
Radar basics functions
|
||||||
@@ -316,7 +324,7 @@ function RADAR:GetVehsHitByRay( ownVeh, vehs, s, e )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function RADAR:CreateRayThread( vehs, from, startX, endX, endY, rayType )
|
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 startP = GetOffsetFromEntityInWorldCoords( from, startX, 0.0, 0.0 )
|
||||||
local endP = GetOffsetFromEntityInWorldCoords( from, endX, endY, 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 ) )
|
-- UTIL:DebugPrint( "Ray thread: increasing ray state from " .. tostring( self:GetRayTraceState() ) .. " to " .. tostring( self:GetRayTraceState() + 1 ) )
|
||||||
self:IncreaseRayTraceState()
|
self:IncreaseRayTraceState()
|
||||||
end )
|
-- end )
|
||||||
end
|
end
|
||||||
|
|
||||||
function RADAR:CreateRayThreads( ownVeh, vehicles )
|
function RADAR:CreateRayThreads( ownVeh, vehicles )
|
||||||
@@ -605,13 +613,15 @@ function RADAR:GetVehiclesForAntenna()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get the 'fastest' vehicle for the antenna
|
if ( self:IsFastDisplayEnabled() ) then
|
||||||
table.sort( vehs[ant], self:GetFastestSortFunc() )
|
-- Get the 'fastest' vehicle for the antenna
|
||||||
|
table.sort( vehs[ant], self:GetFastestSortFunc() )
|
||||||
|
|
||||||
for k, v in pairs( vehs[ant] ) do
|
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
|
results[ant][2] = v
|
||||||
break
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -642,6 +652,11 @@ function RADAR:RunControlManager()
|
|||||||
UTIL:Notify( "Radar power toggled." )
|
UTIL:Notify( "Radar power toggled." )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ( IsDisabledControlJustPressed( 1, 118 ) ) then
|
||||||
|
self:ToggleFastDisplay()
|
||||||
|
UTIL:Notify( "Fast display toggled." )
|
||||||
|
end
|
||||||
|
|
||||||
-- 'Num8' key, toggles front antenna
|
-- 'Num8' key, toggles front antenna
|
||||||
if ( IsDisabledControlJustPressed( 1, 111 ) ) then
|
if ( IsDisabledControlJustPressed( 1, 111 ) ) then
|
||||||
self:ToggleAntenna( "front" )
|
self:ToggleAntenna( "front" )
|
||||||
@@ -722,7 +737,7 @@ Citizen.CreateThread( function()
|
|||||||
while ( true ) do
|
while ( true ) do
|
||||||
RADAR:Main()
|
RADAR:Main()
|
||||||
|
|
||||||
Citizen.Wait( 50 )
|
Citizen.Wait( 100 )
|
||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user