Fixed bug during detection, when i unit got destroyed, the detection stopped. Fixed now

Added a test :IsAlive
This commit is contained in:
FlightControl
2016-06-22 09:31:44 +02:00
parent 08116dab2c
commit 062f34bd26
5 changed files with 2073 additions and 361 deletions
+2
View File
@@ -111,6 +111,7 @@ function DETECTION_BASE:_DetectionScheduler( SchedulerName )
if self.DetectedUnits then if self.DetectedUnits then
for DetectedUnitName, DetectedUnitData in pairs( self.DetectedUnits ) do for DetectedUnitName, DetectedUnitData in pairs( self.DetectedUnits ) do
local DetectedUnit = DetectedUnitData.DetectedUnit -- Unit#UNIT local DetectedUnit = DetectedUnitData.DetectedUnit -- Unit#UNIT
if DetectedUnit and DetectedUnit:IsAlive() then
self:T( DetectedUnit:GetName() ) self:T( DetectedUnit:GetName() )
if #self.DetectedUnitSets == 0 then if #self.DetectedUnitSets == 0 then
self:T( { "Adding Unit Set #", 1 } ) self:T( { "Adding Unit Set #", 1 } )
@@ -140,6 +141,7 @@ function DETECTION_BASE:_DetectionScheduler( SchedulerName )
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...
+7 -1
View File
@@ -390,7 +390,7 @@ end
-- @param #SET_BASE self -- @param #SET_BASE self
-- @param Event#EVENTDATA Event -- @param Event#EVENTDATA Event
function SET_BASE:_EventOnDeadOrCrash( Event ) function SET_BASE:_EventOnDeadOrCrash( Event )
self:F3( { Event } ) self:F2( { Event } )
if Event.IniDCSUnit then if Event.IniDCSUnit then
local ObjectName, Object = self:FindInDatabase( Event ) local ObjectName, Object = self:FindInDatabase( Event )
@@ -957,6 +957,10 @@ function SET_UNIT:New()
-- Inherits from BASE -- Inherits from BASE
local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.UNITS ) ) local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.UNITS ) )
_EVENTDISPATCHER:OnBirth( self._EventOnBirth, self )
_EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
_EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
return self return self
end end
@@ -965,6 +969,7 @@ end
-- @param #string AddUnit A single UNIT. -- @param #string AddUnit A single UNIT.
-- @return #SET_UNIT self -- @return #SET_UNIT self
function SET_UNIT:AddUnit( AddUnit ) function SET_UNIT:AddUnit( AddUnit )
self:F2( AddUnit:GetName() )
self:Add( AddUnit:GetName(), AddUnit ) self:Add( AddUnit:GetName(), AddUnit )
@@ -1151,6 +1156,7 @@ end
function SET_UNIT:FindInDatabase( Event ) function SET_UNIT:FindInDatabase( Event )
self:F3( { Event } ) self:F3( { Event } )
self:E( { Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] } )
return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName]
end end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff