mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Improved it
This commit is contained in:
@@ -102,6 +102,38 @@ function DETECTION_MANAGER:GetReportDisplayTime()
|
||||
return self._ReportDisplayTime
|
||||
end
|
||||
|
||||
--- Creates a string of the detected items in a @{Set}.
|
||||
-- @param #DETECTION_MANAGER self
|
||||
-- @param Set#SET_BASE DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
|
||||
-- @return #DETECTION_MANAGER self
|
||||
function DETECTION_MANAGER:GetDetectedItemsText( DetectedSet )
|
||||
self:F2()
|
||||
|
||||
local MT = {} -- Message Text
|
||||
local UnitTypes = {}
|
||||
|
||||
for DetectedUnitID, DetectedUnitData in pairs( DetectedSet:GetSet() ) do
|
||||
local DetectedUnit = DetectedUnitData -- Unit#UNIT
|
||||
local UnitType = DetectedUnit:GetTypeName()
|
||||
|
||||
if not UnitTypes[UnitType] then
|
||||
UnitTypes[UnitType] = 1
|
||||
else
|
||||
UnitTypes[UnitType] = UnitTypes[UnitType] + 1
|
||||
end
|
||||
end
|
||||
|
||||
for UnitTypeID, UnitType in pairs( UnitTypes ) do
|
||||
MT[#MT+1] = UnitType .. " of " .. UnitTypeID
|
||||
end
|
||||
|
||||
local MessageText = table.concat( MT, ", " )
|
||||
|
||||
return MessageText
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Reports the detected items to the @{Set#SET_GROUP}.
|
||||
-- @param #DETECTION_MANAGER self
|
||||
-- @param Set#SET_BASE DetectedSets The detected Sets created by the @{Detection#DETECTION_BASE} object.
|
||||
@@ -187,22 +219,7 @@ function FAC_REPORTING:ProcessDetected( Group, DetectedSets, DetectedZones )
|
||||
local DetectedMsg = {}
|
||||
for DetectedUnitSetID, DetectedUnitSet in pairs( DetectedSets ) do
|
||||
local UnitSet = DetectedUnitSet -- Set#SET_UNIT
|
||||
local MT = {} -- Message Text
|
||||
local UnitTypes = {}
|
||||
for DetectedUnitID, DetectedUnitData in pairs( UnitSet:GetSet() ) do
|
||||
local DetectedUnit = DetectedUnitData -- Unit#UNIT
|
||||
local UnitType = DetectedUnit:GetTypeName()
|
||||
if not UnitTypes[UnitType] then
|
||||
UnitTypes[UnitType] = 1
|
||||
else
|
||||
UnitTypes[UnitType] = UnitTypes[UnitType] + 1
|
||||
end
|
||||
end
|
||||
for UnitTypeID, UnitType in pairs( UnitTypes ) do
|
||||
MT[#MT+1] = UnitType .. " of " .. UnitTypeID
|
||||
end
|
||||
local MessageText = table.concat( MT, ", " )
|
||||
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedUnitSetID .. ": " .. MessageText
|
||||
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedUnitSetID .. ": " .. self:GetDetectedItemsText( UnitSet )
|
||||
end
|
||||
local FACGroup = self.Detection:GetDetectionGroups()
|
||||
FACGroup:MessageToGroup( "Reporting detected target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), Group )
|
||||
@@ -286,8 +303,7 @@ function TASK_DISPATCHER:ProcessDetected( TaskGroup, DetectedSets, DetectedZones
|
||||
end
|
||||
end
|
||||
|
||||
local MessageText = table.concat( MT, ", " )
|
||||
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedID .. ": " .. MessageText
|
||||
DetectedMsg[#DetectedMsg+1] = " - Group #" .. DetectedID .. ": " .. self:GetDetectedItemsText( UnitSet ) .. ". " .. table.concat( MT, "," )
|
||||
end
|
||||
|
||||
self.CommandCenter:MessageToGroup( "Reporting tasks for target groups:\n" .. table.concat( DetectedMsg, "\n" ), self:GetReportDisplayTime(), TaskGroup )
|
||||
|
||||
@@ -75,7 +75,6 @@ function PROCESS:OnStateChange( Fsm, Event, From, To )
|
||||
|
||||
if self.Scores[To] then
|
||||
|
||||
MESSAGE:New( "Score:" .. self.Scores[To].ScoreText .. " " .. To , 15 ):ToGroup( self.ProcessUnit:GetGroup() )
|
||||
local Scoring = self.Task:GetScoring()
|
||||
if Scoring then
|
||||
Scoring:_AddMissionTaskScore( self.Task.Mission, self.ProcessUnit, self.Scores[To].ScoreText, self.Scores[To].Score )
|
||||
|
||||
@@ -47,7 +47,7 @@ function PROCESS_SEAD:New( Task, ProcessUnit, TargetSetUnit )
|
||||
} )
|
||||
|
||||
|
||||
_EVENTDISPATCHER:OnHit( self.EventHit, self )
|
||||
_EVENTDISPATCHER:OnDead( self.EventDead, self )
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -126,15 +126,13 @@ end
|
||||
-- @param #string To
|
||||
function PROCESS_SEAD:OnDestroyed( Fsm, Event, From, To )
|
||||
|
||||
self.ProcessUnit:Message( "Destroyed", 15 )
|
||||
|
||||
end
|
||||
|
||||
--- DCS Events
|
||||
|
||||
--- @param #PROCESS_SEAD self
|
||||
-- @param Event#EVENTDATA Event
|
||||
function PROCESS_SEAD:EventHit( Event )
|
||||
function PROCESS_SEAD:EventDead( Event )
|
||||
|
||||
if Event.IniUnit then
|
||||
self:NextEvent( self.Fsm.HitTarget, Event )
|
||||
|
||||
Reference in New Issue
Block a user