Fixes for performance in DESIGNATE.

This commit is contained in:
FlightControl
2018-09-14 21:59:30 +02:00
parent 7fa7f0fb79
commit 4ab94ecf26
2 changed files with 96 additions and 74 deletions
@@ -936,17 +936,12 @@ do -- DESIGNATE
return self return self
end end
--- Sets the Designate Menu.
--- Sets the Designate Menu for one attack groups.
-- @param #DESIGNATE self -- @param #DESIGNATE self
-- @return #DESIGNATE -- @return #DESIGNATE
function DESIGNATE:SetDesignateMenu() function DESIGNATE:SetMenu( AttackGroup )
self.AttackSet:Flush( self )
self.AttackSet:ForEachGroupAlive(
--- @param Wrapper.Group#GROUP GroupReport
function( AttackGroup )
self.MenuDesignate = self.MenuDesignate or {} self.MenuDesignate = self.MenuDesignate or {}
local MissionMenu = nil local MissionMenu = nil
@@ -978,6 +973,8 @@ do -- DESIGNATE
MENU_GROUP_COMMAND_DELAYED:New( AttackGroup, "Flash Status Report On", StatusMenu, self.MenuFlashStatus, self, AttackGroup, true ):SetTime( MenuTime ):SetTag( self.DesignateName ) MENU_GROUP_COMMAND_DELAYED:New( AttackGroup, "Flash Status Report On", StatusMenu, self.MenuFlashStatus, self, AttackGroup, true ):SetTime( MenuTime ):SetTag( self.DesignateName )
end end
local DesignateCount = 0
for DesignateIndex, Designating in pairs( self.Designating ) do for DesignateIndex, Designating in pairs( self.Designating ) do
local DetectedItem = self.Detection:GetDetectedItemByIndex( DesignateIndex ) local DetectedItem = self.Detection:GetDetectedItemByIndex( DesignateIndex )
@@ -1016,10 +1013,35 @@ do -- DESIGNATE
MENU_GROUP_COMMAND_DELAYED:New( AttackGroup, "Illuminate", DetectedMenu, self.MenuIlluminate, self, DesignateIndex ):SetTime( MenuTime ):SetTag( self.DesignateName ) MENU_GROUP_COMMAND_DELAYED:New( AttackGroup, "Illuminate", DetectedMenu, self.MenuIlluminate, self, DesignateIndex ):SetTime( MenuTime ):SetTag( self.DesignateName )
end end
end end
DesignateCount = DesignateCount + 1
if DesignateCount > 10 then
break
end
end end
MenuDesignate:Remove( MenuTime, self.DesignateName ) MenuDesignate:Remove( MenuTime, self.DesignateName )
MenuDesignate:Set() MenuDesignate:Set()
end end
--- Sets the Designate Menu for all the attack groups.
-- @param #DESIGNATE self
-- @return #DESIGNATE
function DESIGNATE:SetDesignateMenu()
self.AttackSet:Flush( self )
local Delay = 1
self.AttackSet:ForEachGroupAlive(
--- @param Wrapper.Group#GROUP GroupReport
function( AttackGroup )
self:ScheduleOnce( Delay, self.SetMenu, self, AttackGroup )
Delay = Delay + 1
end
) )
return self return self
@@ -2027,7 +2027,7 @@ do -- DETECTION_UNITS
local DetectedFirstUnitCoord = DetectedFirstUnit:GetCoordinate() local DetectedFirstUnitCoord = DetectedFirstUnit:GetCoordinate()
self:SetDetectedItemCoordinate( DetectedItem, DetectedFirstUnitCoord, DetectedFirstUnit ) self:SetDetectedItemCoordinate( DetectedItem, DetectedFirstUnitCoord, DetectedFirstUnit )
self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table --self:ReportFriendliesNearBy( { DetectedItem = DetectedItem, ReportSetGroup = self.DetectionSetGroup } ) -- Fill the Friendlies table
self:SetDetectedItemThreatLevel( DetectedItem ) self:SetDetectedItemThreatLevel( DetectedItem )
self:NearestRecce( DetectedItem ) self:NearestRecce( DetectedItem )