mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-25 04:25:26 +00:00
Refactoring
This commit is contained in:
@@ -72,6 +72,9 @@
|
||||
-- @field Core.Point#COORDINATE transportPickup Coordinate where to pickup the cargo.
|
||||
-- @field Core.Point#COORDINATE transportDropoff Coordinate where to drop off the cargo.
|
||||
--
|
||||
-- @field #number artyRadius Radius in meters.
|
||||
-- @field #number artyShots Number of shots fired.
|
||||
--
|
||||
-- @field Ops.WingCommander#WINGCOMMANDER wingcommander The WINGCOMMANDER managing this mission.
|
||||
-- @field Ops.AirWing#AIRWING airwing The assigned airwing.
|
||||
-- @field #table assets Airwing Assets assigned for this mission.
|
||||
@@ -1037,14 +1040,25 @@ end
|
||||
|
||||
--- Create an ARTY mission.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Point#COORDINATE Coordinate Center of the firing solution.
|
||||
-- @param Core.Point#COORDINATE Target Center of the firing solution.
|
||||
-- @param #number Nshots Number of shots to be fired. Default 3.
|
||||
-- @param #number Radius Radius of the shells in meters. Default 100 meters.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewARTY(Coordinate, Nshots, Radius)
|
||||
function AUFTRAG:NewARTY(Target, Nshots, Radius)
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.ARTY)
|
||||
|
||||
mission:_TargetFromObject(Target)
|
||||
|
||||
mission.artyShots=Nshots or 3
|
||||
mission.artyRadius=Radius or 100
|
||||
|
||||
mission.optionROE=ENUMS.ROE.OpenFire
|
||||
mission.missionFraction=0.1
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
|
||||
@@ -2968,13 +2982,13 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
|
||||
|
||||
table.insert(DCStasks, DCStask)
|
||||
|
||||
elseif self.type==AUFTRAG.Type.RESCUEHELO then
|
||||
elseif self.type==AUFTRAG.Type.ARTY then
|
||||
|
||||
------------------
|
||||
-- ARTY Mission --
|
||||
------------------
|
||||
|
||||
local DCStask=CONTROLLABLE.TaskFireAtPoint(nil, self:GetTargetVec2(),self.engageRadius, self.engageShots, self.engageWeaponType)
|
||||
local DCStask=CONTROLLABLE.TaskFireAtPoint(nil, self:GetTargetVec2(), self.artyRadius, self.artyShots, self.engageWeaponType)
|
||||
|
||||
table.insert(DCStasks, DCStask)
|
||||
|
||||
|
||||
@@ -2886,13 +2886,6 @@ function FLIGHTGROUP:IsLandingAirbase(wp)
|
||||
end
|
||||
|
||||
|
||||
--- Check if this group is currently "uncontrolled" and needs to be "started" to begin its route.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @return #boolean If this group uncontrolled.
|
||||
function FLIGHTGROUP:IsUncontrolled()
|
||||
return self.isUncontrolled
|
||||
end
|
||||
|
||||
--- Check if task description is unique.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param #string description Task destription
|
||||
@@ -2982,14 +2975,14 @@ function FLIGHTGROUP:InitWaypoints(waypoints)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add a waypoint to the flight plan.
|
||||
--- Add an AIR waypoint to the flight plan.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param Core.Point#COORDINATE coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude.
|
||||
-- @param #number wpnumber Waypoint number. Default at the end.
|
||||
-- @param #number speed Speed in knots. Default 350 kts.
|
||||
-- @param #boolean updateroute If true or nil, call UpdateRoute. If false, no call.
|
||||
-- @return #number Waypoint index.
|
||||
function FLIGHTGROUP:AddWaypointAir(coordinate, wpnumber, speed, updateroute)
|
||||
function FLIGHTGROUP:AddWaypoint(coordinate, wpnumber, speed, updateroute)
|
||||
|
||||
-- Waypoint number. Default is at the end.
|
||||
wpnumber=wpnumber or #self.waypoints+1
|
||||
|
||||
@@ -486,6 +486,67 @@ end
|
||||
-- Routing
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Add an a waypoint to the route.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param Core.Point#COORDINATE coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude.
|
||||
-- @param #number wpnumber Waypoint number. Default at the end.
|
||||
-- @param #number speed Speed in knots. Default 11 kts.
|
||||
-- @param #boolean updateroute If true or nil, call UpdateRoute. If false, no call.
|
||||
-- @return #number Waypoint index.
|
||||
function NAVYGROUP:AddWaypoint(coordinate, wpnumber, speed, updateroute)
|
||||
|
||||
-- Waypoint number. Default is at the end.
|
||||
wpnumber=wpnumber or #self.waypoints+1
|
||||
|
||||
if wpnumber>self.currentwp then
|
||||
self.passedfinalwp=false
|
||||
end
|
||||
|
||||
-- Speed in knots.
|
||||
speed=speed or 11
|
||||
|
||||
-- Speed at waypoint.
|
||||
local speedkmh=UTILS.KnotsToKmph(speed)
|
||||
|
||||
-- Create a Naval waypoint.
|
||||
local wp=coordinate:WaypointNaval(speedkmh)
|
||||
|
||||
-- Add to table.
|
||||
table.insert(self.waypoints, wpnumber, wp)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Adding NAVAL waypoint #%d, speed=%.1f knots. Last waypoint passed was #%s. Total waypoints #%d", wpnumber, speed, self.currentwp, #self.waypoints))
|
||||
|
||||
-- Shift all waypoint tasks after the inserted waypoint.
|
||||
for _,_task in pairs(self.taskqueue) do
|
||||
local task=_task --#FLIGHTGROUP.Task
|
||||
if task.type==OPSGROUP.TaskType.WAYPOINT and task.waypoint and task.waypoint>=wpnumber then
|
||||
task.waypoint=task.waypoint+1
|
||||
end
|
||||
end
|
||||
|
||||
-- Shift all mission waypoints after the inserted waypoint.
|
||||
for _,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
-- Get mission waypoint index.
|
||||
local wpidx=mission:GetFlightWaypointIndex(self)
|
||||
|
||||
-- Increase number if this waypoint lies in the future.
|
||||
if wpidx and wpidx>=wpnumber then
|
||||
mission:SetFlightWaypointIndex(self, wpidx+1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Update route.
|
||||
if updateroute==nil or updateroute==true then
|
||||
self:_CheckGroupDone(1)
|
||||
end
|
||||
|
||||
return wpnumber
|
||||
end
|
||||
|
||||
--- Initialize group parameters. Also initializes waypoints if self.waypoints is nil.
|
||||
-- @param #NAVYGROUP self
|
||||
-- @return #NAVYGROUP self
|
||||
@@ -515,6 +576,9 @@ function NAVYGROUP:_InitGroup()
|
||||
-- Is (template) group late activated.
|
||||
self.isLateActivated=self.template.lateActivation
|
||||
|
||||
-- Naval groups cannot be uncontrolled.
|
||||
self.isUncontrolled=false
|
||||
|
||||
-- Max speed in km/h.
|
||||
self.speedmax=self.group:GetSpeedMax()
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
-- @field Wrapper.Group#GROUP group Group object.
|
||||
-- @field #table template Template of the group.
|
||||
-- @field #boolean isLateActivated Is the group late activated.
|
||||
-- @field #boolean isUncontrolled Is the group uncontrolled.
|
||||
-- @field #table elements Table of elements, i.e. units of the group.
|
||||
-- @field #boolean ai If true, group is purely AI.
|
||||
-- @field #boolean isAircraft If true, group is airplane or helicopter.
|
||||
@@ -549,6 +550,12 @@ function OPSGROUP:IsStopped()
|
||||
return self:Is("Stopped")
|
||||
end
|
||||
|
||||
--- Check if this group is currently "uncontrolled" and needs to be "started" to begin its route.
|
||||
-- @param #OPSGROUP self
|
||||
-- @return #boolean If this group uncontrolled.
|
||||
function OPSGROUP:IsUncontrolled()
|
||||
return self.isUncontrolled
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Waypoint Functions
|
||||
@@ -1419,11 +1426,8 @@ function OPSGROUP:onbeforeMissionStart(From, Event, To, Mission)
|
||||
end
|
||||
|
||||
-- Startup group if it is uncontrolled.
|
||||
if self:IsParking() and self:IsUncontrolled() then
|
||||
if self.isAircraft and self:IsParking() and self:IsUncontrolled() then
|
||||
self:StartUncontrolled(delay)
|
||||
else
|
||||
--env.info("FF hallo!")
|
||||
--self:StartUncontrolled(5)
|
||||
end
|
||||
|
||||
return true
|
||||
@@ -1637,7 +1641,7 @@ function OPSGROUP:RouteToMission(mission, delay)
|
||||
if mission.missionAltitude then
|
||||
waypointcoord:SetAltitude(mission.missionAltitude, true)
|
||||
end
|
||||
env.info(string.format("FF mission alt=%d", waypointcoord.y))
|
||||
env.info(string.format("FF mission alt=%d meters", waypointcoord.y))
|
||||
|
||||
-- Add enroute tasks.
|
||||
for _,task in pairs(mission.enrouteTasks) do
|
||||
@@ -1645,7 +1649,7 @@ function OPSGROUP:RouteToMission(mission, delay)
|
||||
end
|
||||
|
||||
-- Add waypoint.
|
||||
self:AddWaypointAir(waypointcoord, nextwaypoint, UTILS.KmphToKnots(self.speedCruise), false)
|
||||
self:AddWaypoint(waypointcoord, nextwaypoint, UTILS.KmphToKnots(self.speedCruise), false)
|
||||
|
||||
-- Special for Troop transport.
|
||||
if mission.type==AUFTRAG.Type.TROOPTRANSPORT then
|
||||
|
||||
Reference in New Issue
Block a user