mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Updates to make the tasking work correctly.
This commit is contained in:
parent
87a44f7f7f
commit
fb23ac1d55
@ -3985,7 +3985,7 @@ do -- AI_A2G_DISPATCHER
|
|||||||
else
|
else
|
||||||
-- TODO: prio 1, what is this index stuff again, simplify it.
|
-- TODO: prio 1, what is this index stuff again, simplify it.
|
||||||
if DefenderTask.Target then
|
if DefenderTask.Target then
|
||||||
self:F( { Target = DefenderTask.Target } )
|
self:F( { TargetIndex = DefenderTask.Target.Index } )
|
||||||
local AttackerItem = Detection:GetDetectedItemByIndex( DefenderTask.Target.Index )
|
local AttackerItem = Detection:GetDetectedItemByIndex( DefenderTask.Target.Index )
|
||||||
if not AttackerItem then
|
if not AttackerItem then
|
||||||
self:F( { "Removing obsolete Target:", DefenderTask.Target.Index } )
|
self:F( { "Removing obsolete Target:", DefenderTask.Target.Index } )
|
||||||
|
|||||||
@ -131,6 +131,20 @@ do -- SET_BASE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Clear the Objects in the Set.
|
||||||
|
-- @param #SET_BASE self
|
||||||
|
-- @return #SET_BASE self
|
||||||
|
function SET_BASE:Clear()
|
||||||
|
|
||||||
|
for Name, Object in pairs( self.Set ) do
|
||||||
|
self:Remove( Name )
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Finds an @{Core.Base#BASE} object based on the object Name.
|
--- Finds an @{Core.Base#BASE} object based on the object Name.
|
||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @param #string ObjectName
|
-- @param #string ObjectName
|
||||||
|
|||||||
@ -1525,17 +1525,13 @@ do -- DETECTION_BASE
|
|||||||
self.DetectedItemCount = self.DetectedItemCount + 1
|
self.DetectedItemCount = self.DetectedItemCount + 1
|
||||||
self.DetectedItemMax = self.DetectedItemMax + 1
|
self.DetectedItemMax = self.DetectedItemMax + 1
|
||||||
|
|
||||||
if DetectedItemKey then
|
|
||||||
self.DetectedItems[DetectedItemKey] = DetectedItem
|
self.DetectedItems[DetectedItemKey] = DetectedItem
|
||||||
else
|
|
||||||
self.DetectedItems[self.DetectedItemMax] = DetectedItem
|
|
||||||
end
|
|
||||||
|
|
||||||
self.DetectedItemsByIndex[self.DetectedItemMax] = DetectedItem
|
|
||||||
|
|
||||||
|
local DetectedItemIndex = DetectedItemKey or self.DetectedItemMax
|
||||||
|
self.DetectedItemsByIndex[DetectedItemIndex] = DetectedItem
|
||||||
|
DetectedItem.Index = DetectedItemIndex
|
||||||
|
|
||||||
DetectedItem.Set = Set or SET_UNIT:New():FilterDeads():FilterCrashes()
|
DetectedItem.Set = Set or SET_UNIT:New():FilterDeads():FilterCrashes()
|
||||||
DetectedItem.Index = DetectedItemKey or self.DetectedItemMax
|
|
||||||
DetectedItem.ItemID = ItemPrefix .. "." .. self.DetectedItemMax
|
DetectedItem.ItemID = ItemPrefix .. "." .. self.DetectedItemMax
|
||||||
DetectedItem.ID = self.DetectedItemMax
|
DetectedItem.ID = self.DetectedItemMax
|
||||||
DetectedItem.Removed = false
|
DetectedItem.Removed = false
|
||||||
|
|||||||
@ -261,8 +261,8 @@ do -- DETECTION_ZONES
|
|||||||
|
|
||||||
local DetectedUnits = SET_UNIT:New()
|
local DetectedUnits = SET_UNIT:New()
|
||||||
|
|
||||||
-- First go through all detected sets, and check if there are new detected units, match all existing detected units and identify undetected units.
|
-- First go through all zones, and check if there are new Zones.
|
||||||
-- Regroup when needed, split groups when needed.
|
-- New Zones become a new DetectedItem.
|
||||||
for ZoneName, DetectionZone in pairs( self.DetectionSetZone:GetSet() ) do
|
for ZoneName, DetectionZone in pairs( self.DetectionSetZone:GetSet() ) do
|
||||||
|
|
||||||
local DetectedItem = self:GetDetectedItemByKey( ZoneName )
|
local DetectedItem = self:GetDetectedItemByKey( ZoneName )
|
||||||
@ -276,6 +276,8 @@ do -- DETECTION_ZONES
|
|||||||
-- Scan the zone
|
-- Scan the zone
|
||||||
DetectionZone:Scan( { Object.Category.UNIT }, { Unit.Category.GROUND_UNIT } )
|
DetectionZone:Scan( { Object.Category.UNIT }, { Unit.Category.GROUND_UNIT } )
|
||||||
|
|
||||||
|
-- For all the units in the zone,
|
||||||
|
-- check if they are of the same coalition to be included.
|
||||||
local ZoneUnits = DetectionZone:GetScannedUnits()
|
local ZoneUnits = DetectionZone:GetScannedUnits()
|
||||||
for DCSUnitID, DCSUnit in pairs( ZoneUnits ) do
|
for DCSUnitID, DCSUnit in pairs( ZoneUnits ) do
|
||||||
local UnitName = DCSUnit:getName()
|
local UnitName = DCSUnit:getName()
|
||||||
@ -289,12 +291,9 @@ do -- DETECTION_ZONES
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Now all the tests should have been build, now make some smoke and flares...
|
-- Now all the tests should have been build, now make some smoke and flares...
|
||||||
-- We also report here the friendlies within the detected areas.
|
-- We also report here the friendlies within the detected areas.
|
||||||
|
|
||||||
|
|||||||
@ -633,7 +633,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
--DetectedSet:Flush( self )
|
--DetectedSet:Flush( self )
|
||||||
|
|
||||||
local DetectedItemID = DetectedItem.ID
|
local DetectedItemID = DetectedItem.ID
|
||||||
local TaskIndex = DetectedItem.ID
|
local TaskIndex = DetectedItem.Index
|
||||||
local DetectedItemChanged = DetectedItem.Changed
|
local DetectedItemChanged = DetectedItem.Changed
|
||||||
|
|
||||||
self:F( { DetectedItemChanged = DetectedItemChanged, DetectedItemID = DetectedItemID, TaskIndex = TaskIndex } )
|
self:F( { DetectedItemChanged = DetectedItemChanged, DetectedItemID = DetectedItemID, TaskIndex = TaskIndex } )
|
||||||
@ -649,6 +649,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
if Task:IsInstanceOf( TASK_A2G_SEAD ) then
|
if Task:IsInstanceOf( TASK_A2G_SEAD ) then
|
||||||
Task:SetTargetSetUnit( TargetSetUnit )
|
Task:SetTargetSetUnit( TargetSetUnit )
|
||||||
|
Task:SetDetection( Detection, DetectedItem )
|
||||||
Task:UpdateTaskInfo( DetectedItem )
|
Task:UpdateTaskInfo( DetectedItem )
|
||||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||||
else
|
else
|
||||||
@ -659,7 +660,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
if Task:IsInstanceOf( TASK_A2G_CAS ) then
|
if Task:IsInstanceOf( TASK_A2G_CAS ) then
|
||||||
Task:SetTargetSetUnit( TargetSetUnit )
|
Task:SetTargetSetUnit( TargetSetUnit )
|
||||||
Task:SetDetection( Detection, TaskIndex )
|
Task:SetDetection( Detection, DetectedItem )
|
||||||
Task:UpdateTaskInfo( DetectedItem )
|
Task:UpdateTaskInfo( DetectedItem )
|
||||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||||
else
|
else
|
||||||
@ -671,7 +672,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
if TargetSetUnit then
|
if TargetSetUnit then
|
||||||
if Task:IsInstanceOf( TASK_A2G_BAI ) then
|
if Task:IsInstanceOf( TASK_A2G_BAI ) then
|
||||||
Task:SetTargetSetUnit( TargetSetUnit )
|
Task:SetTargetSetUnit( TargetSetUnit )
|
||||||
Task:SetDetection( Detection, TaskIndex )
|
Task:SetDetection( Detection, DetectedItem )
|
||||||
Task:UpdateTaskInfo( DetectedItem )
|
Task:UpdateTaskInfo( DetectedItem )
|
||||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user