Fixed errors with SET_GROUP

This commit is contained in:
FlightControl_Master 2017-12-04 14:01:59 +01:00
parent 901f460907
commit d38c2540c2
6 changed files with 91 additions and 25 deletions

View File

@ -422,6 +422,8 @@ do -- MENU_MISSION
return nil
end
end
else
BASE:E( { "Cannot Remove MENU_MISSION", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText } )
end
return self
@ -507,6 +509,8 @@ do -- MENU_MISSION_COMMAND
return nil
end
end
else
BASE:E( { "Cannot Remove MENU_MISSION_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText } )
end
return self
@ -643,6 +647,8 @@ do -- MENU_COALITION
return nil
end
end
else
BASE:E( { "Cannot Remove MENU_COALITION", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Coalition = self.Coalition } )
end
return self
@ -733,6 +739,8 @@ do -- MENU_COALITION_COMMAND
return nil
end
end
else
BASE:E( { "Cannot Remove MENU_COALITION_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Coalition = self.Coalition } )
end
return self
@ -901,7 +909,7 @@ do
end
end
else
error( "Remove: Not a correct path" )
BASE:E( { "Cannot Remove MENU_GROUP", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
return nil
end
@ -992,6 +1000,8 @@ do
return nil
end
end
else
BASE:E( { "Cannot Remove MENU_GROUP_COMMAND", Path = Path, ParentMenu = self.ParentMenu, MenuText = self.MenuText, Group = self.Group } )
end
return self

View File

@ -716,6 +716,25 @@ function SET_GROUP:New()
return self
end
--- Gets the Set.
-- @param #SET_GROUP self
-- @return #SET_GROUP self
function SET_BASE:GetSet()
self:F2()
-- Clean the Set before returning with only the alive Groups.
for GroupName, GroupObject in pairs( self.Set ) do
if GroupObject then
if not GroupObject:IsAlive() then
self:Remove( GroupName )
end
end
end
return self.Set
end
--- Add GROUP(s) to SET_GROUP.
-- @param Core.Set#SET_GROUP self
-- @param #string AddGroupNames A single name or an array of GROUP names.
@ -972,7 +991,7 @@ end
function SET_GROUP:ForEachGroup( IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end
@ -985,7 +1004,7 @@ end
function SET_GROUP:ForEachGroupCompletelyInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Group#GROUP GroupObject
function( ZoneObject, GroupObject )
@ -1007,7 +1026,7 @@ end
function SET_GROUP:ForEachGroupPartlyInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Group#GROUP GroupObject
function( ZoneObject, GroupObject )
@ -1029,7 +1048,7 @@ end
function SET_GROUP:ForEachGroupNotInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Group#GROUP GroupObject
function( ZoneObject, GroupObject )
@ -1705,7 +1724,7 @@ do -- SET_UNIT
function SET_UNIT:ForEachUnitInZone( IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end
@ -1721,7 +1740,7 @@ do -- SET_UNIT
function SET_UNIT:ForEachUnit( IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end
@ -1764,7 +1783,7 @@ do -- SET_UNIT
self:E( { ThreatLevel = ThreatLevel } )
local ThreatLevelItem = ThreatLevelSet[ThreatLevel]
if ThreatLevelItem then
self:ForEach( IteratorFunction, arg, ThreatLevelItem.Set )
self:ForEach( IteratorFunction, arg, ThreatLevelItem:GetSet() )
end
end
end
@ -1782,7 +1801,7 @@ do -- SET_UNIT
function SET_UNIT:ForEachUnitCompletelyInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Unit#UNIT UnitObject
function( ZoneObject, UnitObject )
@ -1804,7 +1823,7 @@ do -- SET_UNIT
function SET_UNIT:ForEachUnitNotInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Unit#UNIT UnitObject
function( ZoneObject, UnitObject )
@ -2617,7 +2636,7 @@ do -- SET_STATIC
function SET_STATIC:ForEachStaticInZone( IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end
@ -2633,7 +2652,7 @@ do -- SET_STATIC
function SET_STATIC:ForEachStatic( IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end
@ -2647,7 +2666,7 @@ do -- SET_STATIC
function SET_STATIC:ForEachStaticCompletelyInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Static#STATIC StaticObject
function( ZoneObject, StaticObject )
@ -2669,7 +2688,7 @@ do -- SET_STATIC
function SET_STATIC:ForEachStaticNotInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Static#STATIC StaticObject
function( ZoneObject, StaticObject )
@ -3199,7 +3218,7 @@ end
function SET_CLIENT:ForEachClient( IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end
@ -3212,7 +3231,7 @@ end
function SET_CLIENT:ForEachClientInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Client#CLIENT ClientObject
function( ZoneObject, ClientObject )
@ -3234,7 +3253,7 @@ end
function SET_CLIENT:ForEachClientNotInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Client#CLIENT ClientObject
function( ZoneObject, ClientObject )
@ -3598,7 +3617,7 @@ end
function SET_PLAYER:ForEachPlayer( IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end
@ -3611,7 +3630,7 @@ end
function SET_PLAYER:ForEachPlayerInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Client#CLIENT ClientObject
function( ZoneObject, ClientObject )
@ -3633,7 +3652,7 @@ end
function SET_PLAYER:ForEachPlayerNotInZone( ZoneObject, IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set,
self:ForEach( IteratorFunction, arg, self:GetSet(),
--- @param Core.Zone#ZONE_BASE ZoneObject
-- @param Wrapper.Client#CLIENT ClientObject
function( ZoneObject, ClientObject )
@ -3926,7 +3945,7 @@ end
function SET_AIRBASE:ForEachAirbase( IteratorFunction, ... )
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end
@ -4231,7 +4250,7 @@ end
function SET_CARGO:ForEachCargo( IteratorFunction, ... ) --R2.1
self:F2( arg )
self:ForEach( IteratorFunction, arg, self.Set )
self:ForEach( IteratorFunction, arg, self:GetSet() )
return self
end

View File

@ -689,8 +689,9 @@ do -- DESIGNATE
-- This Detection is obsolete, remove from the designate scope
self.Designating[DesignateIndex] = nil
self.AttackSet:ForEachGroup(
--- @param Wrapper.Group#GROUP AttackGroup
function( AttackGroup )
if AttackGroup:IsAlive() then
if AttackGroup:IsAlive() == true then
local DetectionText = self.Detection:DetectedItemReportSummary( DesignateIndex, AttackGroup ):Text( ", " )
self.CC:GetPositionable():MessageToGroup( "Targets out of LOS\n" .. DetectionText, 10, AttackGroup, self.DesignateName )
end

View File

@ -222,8 +222,6 @@ do -- TASK_A2G_DISPATCHER
Mission:GetCommandCenter():MessageToGroup( string.format( "Obsolete A2G task %s for %s removed.", TaskText, Mission:GetName() ), TaskGroup )
end
Task = self:RemoveTask( TaskIndex )
Mission:RemoveTask( Task )
self.Tasks[TaskIndex] = nil
end
end
end

View File

@ -485,6 +485,8 @@ function GROUP:GetCallsign()
return GroupCallSign
end
BASE:E( { "Cannot GetCallsign", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -527,6 +529,8 @@ function GROUP:GetPointVec2()
return FirstUnitPointVec2
end
BASE:E( { "Cannot GetPointVec2", Group = self, Alive = self:IsAlive() } )
return nil
end
@ -544,6 +548,8 @@ function GROUP:GetCoordinate()
return FirstUnitCoordinate
end
BASE:E( { "Cannot GetCoordinate", Group = self, Alive = self:IsAlive() } )
return nil
end
@ -566,6 +572,8 @@ function GROUP:GetRandomVec3(Radius)
return FirstUnitRandomPointVec3
end
BASE:E( { "Cannot GetRandomVec3", Group = self, Alive = self:IsAlive() } )
return nil
end
@ -586,6 +594,8 @@ function GROUP:GetHeading()
return math.floor(HeadingAccumulator / GroupSize)
end
BASE:E( { "Cannot GetHeading", Group = self, Alive = self:IsAlive() } )
return nil
end
@ -612,6 +622,8 @@ function GROUP:GetFuel()
return GroupFuel
end
BASE:E( { "Cannot GetFuel", Group = self, Alive = self:IsAlive() } )
return 0
end

View File

@ -85,6 +85,8 @@ function POSITIONABLE:GetPositionVec3()
return PositionablePosition
end
BASE:E( { "Cannot GetPositionVec3", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -108,6 +110,8 @@ function POSITIONABLE:GetVec2()
return PositionableVec2
end
BASE:E( { "Cannot GetVec2", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -129,6 +133,8 @@ function POSITIONABLE:GetPointVec2()
return PositionablePointVec2
end
BASE:E( { "Cannot GetPointVec2", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -150,6 +156,8 @@ function POSITIONABLE:GetPointVec3()
return PositionablePointVec3
end
BASE:E( { "Cannot GetPointVec3", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -172,6 +180,8 @@ function POSITIONABLE:GetCoordinate()
return PositionableCoordinate
end
BASE:E( { "Cannot GetCoordinate", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -206,6 +216,8 @@ function POSITIONABLE:GetRandomVec3( Radius )
end
end
BASE:E( { "Cannot GetRandomVec3", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -224,6 +236,8 @@ function POSITIONABLE:GetVec3()
return PositionableVec3
end
BASE:E( { "Cannot GetVec3", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -245,6 +259,8 @@ function POSITIONABLE:GetBoundingBox() --R2.1
end
end
BASE:E( { "Cannot GetBoundingBox", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -263,6 +279,8 @@ function POSITIONABLE:GetAltitude()
return PositionablePointVec3.y
end
BASE:E( { "Cannot GetAltitude", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -285,6 +303,8 @@ function POSITIONABLE:IsAboveRunway()
return IsAboveRunway
end
BASE:E( { "Cannot IsAboveRunway", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -311,6 +331,8 @@ function POSITIONABLE:GetHeading()
end
end
BASE:E( { "Cannot GetHeading", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -341,6 +363,8 @@ function POSITIONABLE:GetVelocity()
return Velocity
end
BASE:E( { "Cannot GetVelocity", Positionable = self, Alive = self:IsAlive() } )
return nil
end
@ -361,6 +385,8 @@ function POSITIONABLE:GetVelocityVec3()
return PositionableVelocityVec3
end
BASE:E( { "Cannot GetVelocityVec3", Positionable = self, Alive = self:IsAlive() } )
return nil
end