mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress CAS + PATROLZONE
-- Code -- Documentation -- Presentations -- Dias -- Test Missions
This commit is contained in:
@@ -166,6 +166,58 @@ function CONTROLLABLE:_GetController()
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Get methods
|
||||
|
||||
--- Returns the UNITs wrappers of the DCS Units of the Controllable (default is a GROUP).
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return #list<Wrapper.Unit#UNIT> The UNITs wrappers.
|
||||
function CONTROLLABLE:GetUnits()
|
||||
self:F2( { self.ControllableName } )
|
||||
local DCSControllable = self:GetDCSObject()
|
||||
|
||||
if DCSControllable then
|
||||
local DCSUnits = DCSControllable:getUnits()
|
||||
local Units = {}
|
||||
for Index, UnitData in pairs( DCSUnits ) do
|
||||
Units[#Units+1] = UNIT:Find( UnitData )
|
||||
end
|
||||
self:T3( Units )
|
||||
return Units
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Returns the health. Dead controllables have health <= 1.0.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return #number The controllable health value (unit or group average).
|
||||
-- @return #nil The controllable is not existing or alive.
|
||||
function CONTROLLABLE:GetLife()
|
||||
self:F2( self.ControllableName )
|
||||
|
||||
local DCSControllable = self:GetDCSObject()
|
||||
|
||||
if DCSControllable then
|
||||
local UnitLife = 0
|
||||
local Units = self:GetUnits()
|
||||
if #Units == 1 then
|
||||
local Unit = Units[1] -- Wrapper.Unit#UNIT
|
||||
UnitLife = Unit:GetLife()
|
||||
else
|
||||
local UnitLifeTotal = 0
|
||||
for UnitID, Unit in pairs( Units ) do
|
||||
local Unit = Unit -- Wrapper.Unit#UNIT
|
||||
UnitLifeTotal = UnitLifeTotal + Unit:GetLife()
|
||||
end
|
||||
UnitLife = UnitLifeTotal / #Units
|
||||
end
|
||||
return UnitLife
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Tasks
|
||||
|
||||
@@ -391,26 +391,6 @@ function GROUP:GetInitialSize()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the UNITs wrappers of the DCS Units of the DCS Group.
|
||||
-- @param #GROUP self
|
||||
-- @return #table The UNITs wrappers.
|
||||
function GROUP:GetUnits()
|
||||
self:F2( { self.GroupName } )
|
||||
local DCSGroup = self:GetDCSObject()
|
||||
|
||||
if DCSGroup then
|
||||
local DCSUnits = DCSGroup:getUnits()
|
||||
local Units = {}
|
||||
for Index, UnitData in pairs( DCSUnits ) do
|
||||
Units[#Units+1] = UNIT:Find( UnitData )
|
||||
end
|
||||
self:T3( Units )
|
||||
return Units
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Returns the DCS Units of the DCS Group.
|
||||
-- @param #GROUP self
|
||||
|
||||
@@ -467,6 +467,25 @@ function UNIT:GetFuel()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the UNIT in a UNIT list of one element.
|
||||
-- @param #UNIT self
|
||||
-- @return #list<Wrapper.Unit#UNIT> The UNITs wrappers.
|
||||
function UNIT:GetUnits()
|
||||
self:F2( { self.UnitName } )
|
||||
local DCSUnit = self:GetDCSObject()
|
||||
|
||||
if DCSUnit then
|
||||
local DCSUnits = DCSUnit:getUnits()
|
||||
local Units = {}
|
||||
Units[1] = UNIT:Find( DCSUnit )
|
||||
self:T3( Units )
|
||||
return Units
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Returns the unit's health. Dead units has health <= 1.0.
|
||||
-- @param #UNIT self
|
||||
-- @return #number The Unit's health value.
|
||||
|
||||
Reference in New Issue
Block a user