mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Designate optimization
This commit is contained in:
parent
e16e5d9a81
commit
49bf6010f8
@ -944,7 +944,7 @@ end
|
||||
-- @param #string PlayerName
|
||||
-- @return Core.Settings#SETTINGS
|
||||
function DATABASE:GetPlayerSettings( PlayerName )
|
||||
self:E({PlayerName})
|
||||
self:F2( { PlayerName } )
|
||||
return self.PLAYERSETTINGS[PlayerName]
|
||||
end
|
||||
|
||||
@ -955,7 +955,7 @@ end
|
||||
-- @param Core.Settings#SETTINGS Settings
|
||||
-- @return Core.Settings#SETTINGS
|
||||
function DATABASE:SetPlayerSettings( PlayerName, Settings )
|
||||
self:E({PlayerName, Settings})
|
||||
self:F2( { PlayerName, Settings } )
|
||||
self.PLAYERSETTINGS[PlayerName] = Settings
|
||||
end
|
||||
|
||||
|
||||
@ -817,7 +817,7 @@ do
|
||||
-- @param MenuTime
|
||||
-- @param MenuTag A Tag or Key to filter the menus to be refreshed with the Tag set.
|
||||
-- @return #MENU_GROUP self
|
||||
function MENU_GROUP:RemoveSubMenus( MenuTime, Menutag )
|
||||
function MENU_GROUP:RemoveSubMenus( MenuTime, MenuTag )
|
||||
--self:F2( { self.MenuPath, MenuTime, self.MenuTime } )
|
||||
|
||||
self:T( { "Removing Group SubMenus:", MenuTime, MenuTag, self.MenuGroup:GetName(), self.MenuPath } )
|
||||
@ -890,12 +890,13 @@ do
|
||||
function MENU_GROUP_COMMAND:New( MenuGroup, MenuText, ParentMenu, CommandMenuFunction, ... )
|
||||
|
||||
MenuGroup._Menus = MenuGroup._Menus or {}
|
||||
local Path = ( ParentMenu and ( table.concat( ParentMenu.MenuPath or {}, "@" ) .. "@" .. MenuText ) ) or MenuText
|
||||
local Path = ( ParentMenu and ( table.concat( ParentMenu.MenuPath or {}, "@" ) .. "@" .. MenuText ) ) or MenuText
|
||||
if MenuGroup._Menus[Path] then
|
||||
self = MenuGroup._Menus[Path]
|
||||
self:F2( { "Re-using Group Command Menu:", MenuGroup:GetName(), MenuText } )
|
||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||
|
||||
--self:E( { Path=Path } )
|
||||
--self:E( { self.MenuTag, self.MenuTime, "Re-using Group Command Menu:", MenuGroup:GetName(), MenuText } )
|
||||
--missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||
return self
|
||||
end
|
||||
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||
|
||||
@ -903,6 +904,7 @@ do
|
||||
MenuGroup._Menus[Path] = self
|
||||
--end
|
||||
|
||||
--self:E({Path=Path})
|
||||
self.Path = Path
|
||||
self.MenuGroup = MenuGroup
|
||||
self.MenuGroupID = MenuGroup:GetID()
|
||||
@ -930,13 +932,14 @@ do
|
||||
function MENU_GROUP_COMMAND:Remove( MenuTime, MenuTag )
|
||||
--self:F2( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
||||
|
||||
--self:E( { MenuTag = MenuTag, MenuTime = self.MenuTime, Path = self.Path } )
|
||||
if not MenuTime or self.MenuTime ~= MenuTime then
|
||||
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
|
||||
if self.MenuGroup._Menus[self.Path] then
|
||||
self = self.MenuGroup._Menus[self.Path]
|
||||
|
||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||
self:T( { "Removing Group Command Menu:", MenuGroup = self.MenuGroup:GetName(), MenuText = self.MenuText, MenuPath = self.Path } )
|
||||
--self:E( { "Removing Group Command Menu:", MenuGroup = self.MenuGroup:GetName(), MenuText = self.MenuText, MenuPath = self.Path } )
|
||||
|
||||
self.ParentMenu.Menus[self.MenuText] = nil
|
||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
||||
|
||||
@ -798,7 +798,7 @@ do -- COORDINATE
|
||||
-- @return #string The coordinate Text in the configured coordinate system.
|
||||
function COORDINATE:ToString( Controllable, Settings, Task ) -- R2.2
|
||||
|
||||
self:E( { Controllable = Controllable } )
|
||||
self:F( { Controllable = Controllable and Controllable:GetName() } )
|
||||
|
||||
local Settings = Settings or ( Controllable and _DATABASE:GetPlayerSettings( Controllable:GetPlayerName() ) ) or _SETTINGS
|
||||
|
||||
|
||||
@ -55,6 +55,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
||||
self:F2( { Scheduler, ScheduleFunction, ScheduleArguments, Start, Repeat, Randomize, Stop } )
|
||||
|
||||
self.CallID = self.CallID + 1
|
||||
local CallID = self.CallID .. "#" .. ( Scheduler.MasterObject and Scheduler.MasterObject:GetClassNameAndID() or "" ) or ""
|
||||
|
||||
-- Initialize the ObjectSchedulers array, which is a weakly coupled table.
|
||||
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
||||
@ -65,27 +66,27 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
||||
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
||||
|
||||
if Scheduler.MasterObject then
|
||||
self.ObjectSchedulers[self.CallID] = Scheduler
|
||||
self:F3( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), MasterObject = tostring(Scheduler.MasterObject) } )
|
||||
self.ObjectSchedulers[CallID] = Scheduler
|
||||
self:F3( { CallID = CallID, ObjectScheduler = tostring(self.ObjectSchedulers[CallID]), MasterObject = tostring(Scheduler.MasterObject) } )
|
||||
else
|
||||
self.PersistentSchedulers[self.CallID] = Scheduler
|
||||
self:F3( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
|
||||
self.PersistentSchedulers[CallID] = Scheduler
|
||||
self:F3( { CallID = CallID, PersistentScheduler = self.PersistentSchedulers[CallID] } )
|
||||
end
|
||||
|
||||
self.Schedule = self.Schedule or setmetatable( {}, { __mode = "k" } )
|
||||
self.Schedule[Scheduler] = self.Schedule[Scheduler] or {}
|
||||
self.Schedule[Scheduler][self.CallID] = {}
|
||||
self.Schedule[Scheduler][self.CallID].Function = ScheduleFunction
|
||||
self.Schedule[Scheduler][self.CallID].Arguments = ScheduleArguments
|
||||
self.Schedule[Scheduler][self.CallID].StartTime = timer.getTime() + ( Start or 0 )
|
||||
self.Schedule[Scheduler][self.CallID].Start = Start + .1
|
||||
self.Schedule[Scheduler][self.CallID].Repeat = Repeat or 0
|
||||
self.Schedule[Scheduler][self.CallID].Randomize = Randomize or 0
|
||||
self.Schedule[Scheduler][self.CallID].Stop = Stop
|
||||
self.Schedule[Scheduler][CallID] = {}
|
||||
self.Schedule[Scheduler][CallID].Function = ScheduleFunction
|
||||
self.Schedule[Scheduler][CallID].Arguments = ScheduleArguments
|
||||
self.Schedule[Scheduler][CallID].StartTime = timer.getTime() + ( Start or 0 )
|
||||
self.Schedule[Scheduler][CallID].Start = Start + .1
|
||||
self.Schedule[Scheduler][CallID].Repeat = Repeat or 0
|
||||
self.Schedule[Scheduler][CallID].Randomize = Randomize or 0
|
||||
self.Schedule[Scheduler][CallID].Stop = Stop
|
||||
|
||||
self:T3( self.Schedule[Scheduler][self.CallID] )
|
||||
self:T3( self.Schedule[Scheduler][CallID] )
|
||||
|
||||
self.Schedule[Scheduler][self.CallID].CallHandler = function( CallID )
|
||||
self.Schedule[Scheduler][CallID].CallHandler = function( CallID )
|
||||
self:F2( CallID )
|
||||
|
||||
local ErrorHandler = function( errmsg )
|
||||
@ -164,9 +165,9 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
||||
return nil
|
||||
end
|
||||
|
||||
self:Start( Scheduler, self.CallID )
|
||||
self:Start( Scheduler, CallID )
|
||||
|
||||
return self.CallID
|
||||
return CallID
|
||||
end
|
||||
|
||||
function SCHEDULEDISPATCHER:RemoveSchedule( Scheduler, CallID )
|
||||
|
||||
@ -82,7 +82,6 @@ do -- SETTINGS
|
||||
-- @param #SETTINGS self
|
||||
-- @return #boolean true if metric.
|
||||
function SETTINGS:IsMetric()
|
||||
self:E( {Metric = ( self.Metric ~= nil and self.Metric == true ) or ( self.Metric == nil and _SETTINGS:IsMetric() ) } )
|
||||
return ( self.Metric ~= nil and self.Metric == true ) or ( self.Metric == nil and _SETTINGS:IsMetric() )
|
||||
end
|
||||
|
||||
@ -96,7 +95,6 @@ do -- SETTINGS
|
||||
-- @param #SETTINGS self
|
||||
-- @return #boolean true if imperial.
|
||||
function SETTINGS:IsImperial()
|
||||
self:E( {Metric = ( self.Metric ~= nil and self.Metric == false ) or ( self.Metric == nil and _SETTINGS:IsMetric() ) } )
|
||||
return ( self.Metric ~= nil and self.Metric == false ) or ( self.Metric == nil and _SETTINGS:IsMetric() )
|
||||
end
|
||||
|
||||
@ -187,7 +185,6 @@ do -- SETTINGS
|
||||
-- @param #SETTINGS self
|
||||
-- @return #boolean true if BRA
|
||||
function SETTINGS:IsA2G_BR()
|
||||
self:E( { BRA = ( self.A2GSystem and self.A2GSystem == "BR" ) or ( not self.A2GSystem and _SETTINGS:IsA2G_BR() ) } )
|
||||
return ( self.A2GSystem and self.A2GSystem == "BR" ) or ( not self.A2GSystem and _SETTINGS:IsA2G_BR() )
|
||||
end
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
--- **Functional** -- Management of target **Designation**.
|
||||
--- **Functional** -- Management of target **Designation**. Lase, smoke and illuminate targets.
|
||||
--
|
||||
-- --
|
||||
--
|
||||
@ -372,7 +372,7 @@ do -- DESIGNATE
|
||||
self:SetMission( Mission )
|
||||
self:SetDesignateMenu()
|
||||
|
||||
self:SetLaserCodes( 1688 ) -- set self.LaserCodes
|
||||
self:SetLaserCodes( { 1688, 1130, 4785, 6547, 1465, 4578 } ) -- set self.LaserCodes
|
||||
self:SetAutoLase( false ) -- set self.Autolase
|
||||
|
||||
self:SetThreatLevelPrioritization( false ) -- self.ThreatLevelPrioritization, default is threat level priorization off
|
||||
@ -413,7 +413,7 @@ do -- DESIGNATE
|
||||
function DESIGNATE:SetLaserCodes( LaserCodes ) --R2.1
|
||||
|
||||
self.LaserCodes = ( type( LaserCodes ) == "table" ) and LaserCodes or { LaserCodes }
|
||||
self:E(self.LaserCodes)
|
||||
self:E( { LaserCodes = self.LaserCodes } )
|
||||
|
||||
self.LaserCodesUsed = {}
|
||||
|
||||
@ -599,12 +599,19 @@ do -- DESIGNATE
|
||||
|
||||
local DetectedItems = self.Detection:GetDetectedItems()
|
||||
|
||||
local DetectedItemCount = 0
|
||||
|
||||
for Index, DetectedItemData in pairs( DetectedItems ) do
|
||||
if self.AutoLase then
|
||||
if not self.Designating[Index] then
|
||||
self:LaseOn( Index, self.LaseDuration )
|
||||
end
|
||||
end
|
||||
|
||||
DetectedItemCount = DetectedItemCount + 1
|
||||
if DetectedItemCount >= 5 then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
@ -656,12 +663,14 @@ do -- DESIGNATE
|
||||
|
||||
local DetectedItems = self.Detection:GetDetectedItems()
|
||||
|
||||
local DetectedItemCount = 0
|
||||
|
||||
for Index, DetectedItemData in pairs( DetectedItems ) do
|
||||
|
||||
local Report = self.Detection:DetectedItemMenu( Index, AttackGroup )
|
||||
|
||||
if not self.Designating[Index] then
|
||||
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, MenuDesignate )
|
||||
local DetectedMenu = MENU_GROUP:New( AttackGroup, Report, MenuDesignate ):SetTime( MenuTime ):SetTag( "Designate" )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Lase target 60 secs", DetectedMenu, self.MenuLaseOn, self, Index, 60 ):SetTime( MenuTime ):SetTag( "Designate" )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Lase target 120 secs", DetectedMenu, self.MenuLaseOn, self, Index, 120 ):SetTime( MenuTime ):SetTag( "Designate" )
|
||||
MENU_GROUP_COMMAND:New( AttackGroup, "Smoke red", DetectedMenu, self.MenuSmoke, self, Index, SMOKECOLOR.Red ):SetTime( MenuTime ):SetTag( "Designate" )
|
||||
@ -684,6 +693,10 @@ do -- DESIGNATE
|
||||
else
|
||||
end
|
||||
end
|
||||
DetectedItemCount = DetectedItemCount + 1
|
||||
if DetectedItemCount >= 5 then
|
||||
break
|
||||
end
|
||||
end
|
||||
MenuDesignate:Remove( MenuTime, "Designate" )
|
||||
end
|
||||
@ -779,10 +792,13 @@ do -- DESIGNATE
|
||||
|
||||
TargetSetUnit:Flush()
|
||||
|
||||
--self:F( { Recces = self.Recces } )
|
||||
for TargetUnit, RecceData in pairs( self.Recces ) do
|
||||
local Recce = RecceData -- Wrapper.Unit#UNIT
|
||||
self:F( { TargetUnit = TargetUnit, Recce = Recce:GetName() } )
|
||||
if not Recce:IsLasing() then
|
||||
local LaserCode = Recce:GetLaserCode() --(Not deleted when stopping with lasing).
|
||||
self:F( { ClearingLaserCode = LaserCode } )
|
||||
self.LaserCodesUsed[LaserCode] = nil
|
||||
self.Recces[TargetUnit] = nil
|
||||
end
|
||||
@ -791,17 +807,22 @@ do -- DESIGNATE
|
||||
TargetSetUnit:ForEachUnitPerThreatLevel( 10, 0,
|
||||
--- @param Wrapper.Unit#UNIT SmokeUnit
|
||||
function( TargetUnit )
|
||||
self:E("In procedure")
|
||||
self:F( { TargetUnit = TargetUnit:GetName() } )
|
||||
if TargetUnit:IsAlive() then
|
||||
local Recce = self.Recces[TargetUnit]
|
||||
if not Recce then
|
||||
self.RecceSet:Flush()
|
||||
for RecceGroupID, RecceGroup in pairs( self.RecceSet:GetSet() ) do
|
||||
for UnitID, UnitData in pairs( RecceGroup:GetUnits() or {} ) do
|
||||
local RecceUnit = UnitData -- Wrapper.Unit#UNIT
|
||||
local RecceUnitDesc = RecceUnit:GetDesc()
|
||||
--self:F( { RecceUnit = RecceUnit:GetName(), RecceDescription = RecceUnitDesc } )
|
||||
if RecceUnit:IsLasing() == false then
|
||||
--self:F( { IsDetected = RecceUnit:IsDetected( TargetUnit ), IsLOS = RecceUnit:IsLOS( TargetUnit ) } )
|
||||
if RecceUnit:IsDetected( TargetUnit ) and RecceUnit:IsLOS( TargetUnit ) then
|
||||
local LaserCodeIndex = math.random( 1, #self.LaserCodes )
|
||||
local LaserCode = self.LaserCodes[LaserCodeIndex]
|
||||
--self:F( { LaserCode = LaserCode, LaserCodeUsed = self.LaserCodesUsed[LaserCode] } )
|
||||
if not self.LaserCodesUsed[LaserCode] then
|
||||
self.LaserCodesUsed[LaserCode] = LaserCodeIndex
|
||||
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
|
||||
@ -812,7 +833,8 @@ do -- DESIGNATE
|
||||
end
|
||||
self.Recces[TargetUnit] = RecceUnit
|
||||
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.", 5, self.AttackSet )
|
||||
break
|
||||
-- OK. We have assigned for the Recce a TargetUnit. We can exit the function.
|
||||
return
|
||||
end
|
||||
else
|
||||
--RecceUnit:MessageToSetGroup( "Can't mark " .. TargetUnit:GetTypeName(), 5, self.AttackSet )
|
||||
@ -823,7 +845,7 @@ do -- DESIGNATE
|
||||
local Recce = self.Recces[TargetUnit] -- Wrapper.Unit#UNIT
|
||||
if Recce then
|
||||
Recce:LaseOff()
|
||||
Recce:MessageToGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet )
|
||||
Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() "out of LOS. Cancelling lase!", 5, self.AttackSet )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -226,7 +226,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
local DetectedSet = DetectedItem.Set -- Core.Set#SET_UNIT
|
||||
local DetectedZone = DetectedItem.Zone
|
||||
--self:E( { "Targets in DetectedItem", DetectedItem.ItemID, DetectedSet:Count(), tostring( DetectedItem ) } )
|
||||
DetectedSet:Flush()
|
||||
--DetectedSet:Flush()
|
||||
|
||||
local DetectedItemID = DetectedItem.ID
|
||||
local TaskIndex = DetectedItem.Index
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user