mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Documentation
This commit is contained in:
125
Moose/Group.lua
125
Moose/Group.lua
@@ -1,6 +1,9 @@
|
||||
--- GROUP Classes
|
||||
--- A GROUP class abstraction of a DCSGroup class.
|
||||
-- The GROUP class will take an abstraction of the DCSGroup class, providing more methods that can be done with a GROUP.
|
||||
--
|
||||
--
|
||||
-- @module GROUP
|
||||
-- @return #GROUP
|
||||
-- @extends BASE#BASE
|
||||
|
||||
Include.File( "Routines" )
|
||||
Include.File( "Base" )
|
||||
@@ -9,13 +12,27 @@ Include.File( "Unit" )
|
||||
|
||||
--- The GROUP class
|
||||
-- @type GROUP
|
||||
-- @field ClassName The name of the class.
|
||||
-- @field #Group DCSGroup The DCS group class.
|
||||
-- @field #string GroupName The name of the group.
|
||||
-- @field #number GroupID the ID of the group.
|
||||
-- @field #table Controller The controller of the group.
|
||||
GROUP = {
|
||||
ClassName = "GROUP",
|
||||
GroupName = "",
|
||||
GroupID = 0,
|
||||
Controller = nil,
|
||||
}
|
||||
|
||||
--- A DCSGroup
|
||||
-- @type Group
|
||||
-- @field id_ The ID of the group in DCS
|
||||
|
||||
GROUPS = {}
|
||||
|
||||
--- Create a new GROUP from a DCSGroup
|
||||
-- @param self
|
||||
-- @param #Group DCSGroup The DCS Group
|
||||
-- @return #GROUP self
|
||||
function GROUP:New( DCSGroup )
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:T( DCSGroup:getName() )
|
||||
@@ -29,6 +46,10 @@ function GROUP:New( DCSGroup )
|
||||
end
|
||||
|
||||
|
||||
--- Create a new GROUP from an existing DCSGroup in the mission.
|
||||
-- @param self
|
||||
-- @param GroupName The name of the DCS Group.
|
||||
-- @return #GROUP self
|
||||
function GROUP:NewFromName( GroupName )
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:T( GroupName )
|
||||
@@ -37,35 +58,52 @@ function GROUP:NewFromName( GroupName )
|
||||
if self.DCSGroup then
|
||||
self.GroupName = self.DCSGroup:getName()
|
||||
self.GroupID = self.DCSGroup:getID()
|
||||
self.Controller = DCSGroup:getController()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the DCSGroup of the GROUP.
|
||||
-- @param self
|
||||
-- @return #Group The DCSGroup.
|
||||
function GROUP:GetDCSGroup()
|
||||
self:T( { self.GroupName } )
|
||||
self.DCSGroup = Group.getByName( self.GroupName )
|
||||
return self.DCSGroup
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Gets the DCS Unit of the GROUP.
|
||||
-- @param self
|
||||
-- @param #number UnitNumber The unit index to be returned from the GROUP.
|
||||
-- @return #Unit The DCS Unit.
|
||||
function GROUP:GetDCSUnit( UnitNumber )
|
||||
self:T( { self.GroupName, UnitNumber } )
|
||||
return self.DCSGroup:getUnit( UnitNumber )
|
||||
|
||||
end
|
||||
|
||||
--- Activates a GROUP.
|
||||
-- @param self
|
||||
function GROUP:Activate()
|
||||
self:T( { self.GroupName } )
|
||||
trigger.action.activateGroup( self:GetDCSGroup() )
|
||||
return self:GetDCSGroup()
|
||||
end
|
||||
|
||||
--- Gets the name of the GROUP.
|
||||
-- @param self
|
||||
-- @return #string The name of the GROUP.
|
||||
function GROUP:GetName()
|
||||
self:T( self.GroupName )
|
||||
|
||||
return self.GroupName
|
||||
end
|
||||
|
||||
--- Gets the current Point of the GROUP in VEC2 format.
|
||||
-- @return #Vec2 Current x and Y position of the group.
|
||||
function GROUP:GetPoint()
|
||||
self:T( self.GroupName )
|
||||
|
||||
@@ -74,7 +112,10 @@ function GROUP:GetPoint()
|
||||
return GroupPoint
|
||||
end
|
||||
|
||||
|
||||
--- Destroy a GROUP
|
||||
-- Note that this destroy method also raises a destroy event at run-time.
|
||||
-- So all event listeners will catch the destroy event of this GROUP.
|
||||
-- @param self
|
||||
function GROUP:Destroy()
|
||||
self:T( self.GroupName )
|
||||
|
||||
@@ -87,13 +128,19 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
--- Gets the DCS Unit.
|
||||
-- @param self
|
||||
-- @param #number UnitNumber The number of the Unit to be returned.
|
||||
-- @return #Unit The DCS Unit.
|
||||
function GROUP:GetUnit( UnitNumber )
|
||||
self:T( { self.GroupName, UnitNumber } )
|
||||
return UNIT:New( self.DCSGroup:getUnit( UnitNumber ) )
|
||||
end
|
||||
|
||||
|
||||
--- Returns if the group is of an air category.
|
||||
-- If the group is a helicopter or a plane, then this method will return true, otherwise false.
|
||||
-- @param self
|
||||
-- @return #boolean Air category evaluation result.
|
||||
function GROUP:IsAir()
|
||||
self:T()
|
||||
|
||||
@@ -103,6 +150,10 @@ self:T()
|
||||
return IsAirResult
|
||||
end
|
||||
|
||||
--- Returns if the group is alive.
|
||||
-- When the group exists at run-time, this method will return true, otherwise false.
|
||||
-- @param self
|
||||
-- @return #boolean Alive result.
|
||||
function GROUP:IsAlive()
|
||||
self:T()
|
||||
|
||||
@@ -112,7 +163,10 @@ self:T()
|
||||
return IsAliveResult
|
||||
end
|
||||
|
||||
|
||||
--- Returns if all units of the group are on the ground or landed.
|
||||
-- If all units of this group are on the ground, this function will return true, otherwise false.
|
||||
-- @param self
|
||||
-- @return #boolean All units on the ground result.
|
||||
function GROUP:AllOnGround()
|
||||
self:T()
|
||||
|
||||
@@ -128,9 +182,12 @@ self:T()
|
||||
return AllOnGroundResult
|
||||
end
|
||||
|
||||
|
||||
--- Returns the current maximum velocity of the group.
|
||||
-- Each unit within the group gets evaluated, and the maximum velocity (= the unit which is going the fastest) is returned.
|
||||
-- @param self
|
||||
-- @return #number Maximum velocity found.
|
||||
function GROUP:GetMaxVelocity()
|
||||
self:T()
|
||||
self:T()
|
||||
|
||||
local MaxVelocity = 0
|
||||
|
||||
@@ -148,13 +205,31 @@ self:T()
|
||||
end
|
||||
|
||||
|
||||
function GROUP:GetHeight()
|
||||
self:T()
|
||||
|
||||
--- Returns the current minimum height of the group.
|
||||
-- Each unit within the group gets evaluated, and the minimum height (= the unit which is the lowest elevated) is returned.
|
||||
-- @param self
|
||||
-- @return #number Minimum height found.
|
||||
function GROUP:GetMinHeight()
|
||||
self:T()
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Returns the current maximum height of the group.
|
||||
-- Each unit within the group gets evaluated, and the maximum height (= the unit which is the highest elevated) is returned.
|
||||
-- @param self
|
||||
-- @return #number Maximum height found.
|
||||
function GROUP:GetMaxHeight()
|
||||
self:T()
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Land the group at a Vec2Point.
|
||||
-- @param self
|
||||
-- @param #Vec2 Point The point where to land.
|
||||
-- @param #number Duration The duration in seconds to stay on the ground.
|
||||
-- @return #GROUP self
|
||||
function GROUP:Land( Point, Duration )
|
||||
trace.f( self.ClassName, { self.GroupName, Point, Duration } )
|
||||
|
||||
@@ -169,7 +244,12 @@ trace.f( self.ClassName, { self.GroupName, Point, Duration } )
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Move the group to a Vec2 Point, wait for a defined duration and embark a group.
|
||||
-- @param self
|
||||
-- @param #Vec2 Point The point where to wait.
|
||||
-- @param #number Duration The duration in seconds to wait.
|
||||
-- @param EmbarkingGroup The group to be embarked.
|
||||
-- @return #GROUP self
|
||||
function GROUP:Embarking( Point, Duration, EmbarkingGroup )
|
||||
trace.f( self.ClassName, { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } )
|
||||
|
||||
@@ -194,7 +274,11 @@ trace.f( self.ClassName, { self.GroupName, Point, Duration, EmbarkingGroup.DCSGr
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Move to a defined Vec2 Point, and embark to a group when arrived within a defined Radius.
|
||||
-- @param self
|
||||
-- @param #Vec2 Point The point where to wait.
|
||||
-- @param #number Radius The radius of the embarking zone around the Point.
|
||||
-- @return #GROUP self
|
||||
function GROUP:EmbarkToTransport( Point, Radius )
|
||||
trace.f( self.ClassName, { self.GroupName, Point, Radius } )
|
||||
|
||||
@@ -211,6 +295,10 @@ trace.f( self.ClassName, { self.GroupName, Point, Radius } )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Make the group to follow a given route.
|
||||
-- @param self
|
||||
-- @param #table GoPoints A table of Route Points.
|
||||
-- @return #GROUP self
|
||||
function GROUP:Route( GoPoints )
|
||||
self:T( GoPoints )
|
||||
|
||||
@@ -224,6 +312,15 @@ self:T( GoPoints )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Route the group to a given zone.
|
||||
-- The group final destination point can be randomized.
|
||||
-- A speed can be given in km/h.
|
||||
-- A given formation can be given.
|
||||
-- @param self
|
||||
-- @param ZONE#ZONE Zone The zone where to route to.
|
||||
-- @param #boolean Randomize Defines whether to target point gets randomized within the Zone.
|
||||
-- @param #number Speed The speed.
|
||||
-- @param BASE#FORMATION Formation The formation string.
|
||||
function GROUP:RouteToZone( Zone, Randomize, Speed, Formation )
|
||||
self:T( Zone )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user