mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Ops
- Airboss optimizations WIP
This commit is contained in:
@@ -588,6 +588,25 @@ function AIRBASE.GetAllAirbases(coalition, category)
|
||||
return airbases
|
||||
end
|
||||
|
||||
--- Get all airbase names of the current map. This includes ships and FARPS.
|
||||
-- @param DCS#Coalition coalition (Optional) Return only airbases belonging to the specified coalition. By default, all airbases of the map are returned.
|
||||
-- @param #number category (Optional) Return only airbases of a certain category, e.g. Airbase.Category.FARP
|
||||
-- @return #table Table containing all airbase names of the current map.
|
||||
function AIRBASE.GetAllAirbaseNames(coalition, category)
|
||||
|
||||
local airbases={}
|
||||
for airbasename,_airbase in pairs(_DATABASE.AIRBASES) do
|
||||
local airbase=_airbase --#AIRBASE
|
||||
if coalition==nil or airbase:GetCoalition()==coalition then
|
||||
if category==nil or category==airbase:GetAirbaseCategory() then
|
||||
table.insert(airbases, airbasename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return airbases
|
||||
end
|
||||
|
||||
--- Get ID of the airbase.
|
||||
-- @param #AIRBASE self
|
||||
-- @param #boolean unique (Optional) If true, ships will get a negative sign as the unit ID might be the same as an airbase ID. Default off!
|
||||
|
||||
@@ -947,24 +947,29 @@ end
|
||||
-- @param #GROUP self
|
||||
-- @return DCS#Vec2 Current Vec2 point of the first DCS Unit of the DCS Group.
|
||||
function GROUP:GetVec2()
|
||||
self:F2( self.GroupName )
|
||||
|
||||
local UnitPoint = self:GetUnit(1)
|
||||
UnitPoint:GetVec2()
|
||||
local GroupPointVec2 = UnitPoint:GetVec2()
|
||||
self:T3( GroupPointVec2 )
|
||||
return GroupPointVec2
|
||||
local Unit=self:GetUnit(1)
|
||||
|
||||
if Unit then
|
||||
return Unit:GetVec2()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Returns the current Vec3 vector of the first DCS Unit in the GROUP.
|
||||
-- @param #GROUP self
|
||||
-- @return DCS#Vec3 Current Vec3 of the first DCS Unit of the GROUP.
|
||||
function GROUP:GetVec3()
|
||||
self:F2( self.GroupName )
|
||||
|
||||
local GroupVec3 = self:GetUnit(1):GetVec3()
|
||||
self:T3( GroupVec3 )
|
||||
return GroupVec3
|
||||
-- Get first unit.
|
||||
local unit=self:GetUnit(1)
|
||||
|
||||
if unit then
|
||||
return unit:GetVec3()
|
||||
end
|
||||
|
||||
self:E("ERROR: Cannot get Vec3 of group "..tostring(self.GroupName))
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns a POINT_VEC2 object indicating the point in 2D of the first UNIT of the GROUP within the mission.
|
||||
|
||||
@@ -125,10 +125,17 @@ function POSITIONABLE:Destroy( GenerateEvent )
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the DCS object. Polymorphic for other classes like UNIT, STATIC, GROUP, AIRBASE.
|
||||
-- @param #POSITIONABLE self
|
||||
-- @return DCS#Object The DCS object.
|
||||
function POSITIONABLE:GetDCSObject()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns a pos3 table of the objects current position and orientation in 3D space. X, Y, Z values are unit vectors defining the objects orientation.
|
||||
-- Coordinates are dependent on the position of the maps origin.
|
||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||
-- @return DCS#Position Table consisting of the point and orientation tables.
|
||||
-- @return DCS#Position3 Table consisting of the point and orientation tables.
|
||||
function POSITIONABLE:GetPosition()
|
||||
self:F2( self.PositionableName )
|
||||
|
||||
@@ -221,45 +228,42 @@ end
|
||||
|
||||
--- Returns the @{DCS#Vec3} vector indicating the 3D vector of the POSITIONABLE within the mission.
|
||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||
-- @return DCS#Vec3 The 3D point vector of the POSITIONABLE.
|
||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
||||
-- @return DCS#Vec3 The 3D point vector of the POSITIONABLE or `nil` if it is not existing or alive.
|
||||
function POSITIONABLE:GetVec3()
|
||||
self:F2( self.PositionableName )
|
||||
|
||||
local DCSPositionable = self:GetDCSObject()
|
||||
|
||||
if DCSPositionable then
|
||||
local PositionableVec3 = DCSPositionable:getPosition().p
|
||||
self:T3( PositionableVec3 )
|
||||
return PositionableVec3
|
||||
|
||||
local vec3=DCSPositionable:getPoint()
|
||||
|
||||
if vec3 then
|
||||
return vec3
|
||||
else
|
||||
self:E("ERROR: Cannot get vec3!")
|
||||
end
|
||||
end
|
||||
|
||||
BASE:E( { "Cannot GetVec3", Positionable = self, Alive = self:IsAlive() } )
|
||||
|
||||
-- ERROR!
|
||||
self:E( { "Cannot GetVec3", Positionable = self, Alive = self:IsAlive() } )
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns the @{DCS#Vec2} vector indicating the point in 2D of the POSITIONABLE within the mission.
|
||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||
-- @return DCS#Vec2 The 2D point vector of the POSITIONABLE.
|
||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
||||
-- @return DCS#Vec2 The 2D point vector of the POSITIONABLE or #nil if it is not existing or alive.
|
||||
function POSITIONABLE:GetVec2()
|
||||
self:F2( self.PositionableName )
|
||||
|
||||
local DCSPositionable = self:GetDCSObject()
|
||||
|
||||
if DCSPositionable then
|
||||
local PositionableVec3 = DCSPositionable:getPosition().p
|
||||
|
||||
local PositionableVec2 = {}
|
||||
PositionableVec2.x = PositionableVec3.x
|
||||
PositionableVec2.y = PositionableVec3.z
|
||||
|
||||
self:T2( PositionableVec2 )
|
||||
return PositionableVec2
|
||||
local Vec3=DCSPositionable:getPoint() --DCS#Vec3
|
||||
|
||||
return {x=Vec3.x, y=Vec3.z}
|
||||
end
|
||||
|
||||
BASE:E( { "Cannot GetVec2", Positionable = self, Alive = self:IsAlive() } )
|
||||
self:E( { "Cannot GetVec2", Positionable = self, Alive = self:IsAlive() } )
|
||||
|
||||
return nil
|
||||
end
|
||||
@@ -282,7 +286,7 @@ function POSITIONABLE:GetPointVec2()
|
||||
return PositionablePointVec2
|
||||
end
|
||||
|
||||
BASE:E( { "Cannot GetPointVec2", Positionable = self, Alive = self:IsAlive() } )
|
||||
self:E( { "Cannot GetPointVec2", Positionable = self, Alive = self:IsAlive() } )
|
||||
|
||||
return nil
|
||||
end
|
||||
@@ -333,20 +337,20 @@ function POSITIONABLE:GetCoord()
|
||||
if DCSPositionable then
|
||||
|
||||
-- Get the current position.
|
||||
local PositionableVec3 = self:GetPositionVec3()
|
||||
local Vec3 = self:GetVec3()
|
||||
|
||||
if self.coordinate then
|
||||
--env.info("FF GetCoordinate GOT for "..tostring(self.PositionableName))
|
||||
|
||||
-- Update vector.
|
||||
self.coordinate.x=PositionableVec3.x
|
||||
self.coordinate.y=PositionableVec3.y
|
||||
self.coordinate.z=PositionableVec3.z
|
||||
self.coordinate.x=Vec3.x
|
||||
self.coordinate.y=Vec3.y
|
||||
self.coordinate.z=Vec3.z
|
||||
|
||||
else
|
||||
--env.info("FF GetCoordinate NEW for "..tostring(self.PositionableName))
|
||||
|
||||
self.coordinate=COORDINATE:NewFromVec3(PositionableVec3)
|
||||
-- New COORDINATE.
|
||||
self.coordinate=COORDINATE:NewFromVec3(Vec3)
|
||||
|
||||
end
|
||||
|
||||
return self.coordinate
|
||||
@@ -369,33 +373,15 @@ function POSITIONABLE:GetCoordinate()
|
||||
if DCSPositionable then
|
||||
|
||||
-- Get the current position.
|
||||
local PositionableVec3 = self:GetPositionVec3()
|
||||
local PositionableVec3 = self:GetVec3()
|
||||
|
||||
if self.coordinate then
|
||||
--env.info("FF GetCoordinate GOT for "..tostring(self.PositionableName))
|
||||
-- Return a new coordiante object.
|
||||
return COORDINATE:NewFromVec3(PositionableVec3)
|
||||
|
||||
-- Update vector.
|
||||
self.coordinate.x=PositionableVec3.x
|
||||
self.coordinate.y=PositionableVec3.y
|
||||
self.coordinate.z=PositionableVec3.z
|
||||
|
||||
else
|
||||
--env.info("FF GetCoordinate NEW for "..tostring(self.PositionableName))
|
||||
|
||||
self.coordinate=COORDINATE:NewFromVec3(PositionableVec3)
|
||||
end
|
||||
|
||||
|
||||
-- Set heading and velocity.
|
||||
self.coordinate:SetHeading( self:GetHeading() )
|
||||
self.coordinate:SetVelocity( self:GetVelocityMPS() )
|
||||
|
||||
return self.coordinate
|
||||
end
|
||||
|
||||
-- Error message.
|
||||
BASE:E( { "Cannot GetCoordinate", Positionable = self, Alive = self:IsAlive() } )
|
||||
|
||||
self:E( { "Cannot GetCoordinate", Positionable = self, Alive = self:IsAlive() } )
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user