mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Updates Csar
This commit is contained in:
parent
a94e744028
commit
a4d3089fdb
@ -277,6 +277,17 @@ do -- CARGO
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Find a CARGO in the _DATABASE.
|
||||
-- @param #CARGO self
|
||||
-- @param #string CargoName The Cargo Name.
|
||||
-- @return #CARGO self
|
||||
function CARGO:FindByName( CargoName )
|
||||
|
||||
local CargoFound = _DATABASE:FindCargo( CargoName )
|
||||
return CargoFound
|
||||
end
|
||||
|
||||
--- Destroy the cargo.
|
||||
-- @param #CARGO self
|
||||
function CARGO:Destroy()
|
||||
|
||||
@ -727,10 +727,11 @@ do -- TASK_CARGO
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param #list<Core.Zone#ZONE> DeployZones
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @return #TASK_CARGO
|
||||
function TASK_CARGO:SetDeployZones( DeployZones )
|
||||
function TASK_CARGO:SetDeployZones( DeployZones, TaskUnit )
|
||||
|
||||
for DeployZoneID, DeployZone in pairs( DeployZones ) do
|
||||
for DeployZoneID, DeployZone in pairs( DeployZones or {} ) do
|
||||
self.DeployZones[DeployZone:GetName()] = DeployZone
|
||||
end
|
||||
|
||||
|
||||
@ -205,7 +205,7 @@ do -- TASK_CARGO_DISPATCHER
|
||||
-- @param #string PlayerName
|
||||
|
||||
self:SetCSARRadius()
|
||||
self:__Start( 5 )
|
||||
self:__StartTasks( 5 )
|
||||
|
||||
-- For CSAR missions, we process the event when a pilot ejects.
|
||||
|
||||
@ -221,14 +221,52 @@ do -- TASK_CARGO_DISPATCHER
|
||||
function TASK_CARGO_DISPATCHER:OnEventEjection( EventData )
|
||||
|
||||
self:E( { EventData = EventData } )
|
||||
|
||||
local PilotUnit = EventData.IniUnit
|
||||
|
||||
local PlaneUnit = EventData.IniUnit
|
||||
local CSARName = EventData.IniUnitName
|
||||
|
||||
self.CSAR[CSARName] = {}
|
||||
self.CSAR[CSARName].PilotUnit = PilotUnit
|
||||
self.CSAR[CSARName].Task = nil
|
||||
local PilotUnit = nil
|
||||
|
||||
self:ScheduleOnce( 1,
|
||||
function()
|
||||
|
||||
-- Search for the ejected pilot
|
||||
|
||||
local PlaneCoord = PlaneUnit:GetCoordinate()
|
||||
|
||||
local SphereSearch = {
|
||||
id = world.VolumeType.SPHERE,
|
||||
params = {
|
||||
point = PlaneCoord:GetVec3(),
|
||||
radius = 100,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
--- @param Dcs.DCSWrapper.Unit#Unit FoundDCSUnit
|
||||
-- @param Wrapper.Group#GROUP ReportGroup
|
||||
-- @param Set#SET_GROUP ReportSetGroup
|
||||
local FindEjectedPilot = function( FoundDCSUnit )
|
||||
|
||||
local UnitName = FoundDCSUnit:getName()
|
||||
|
||||
self:E( { "Units near Plane:", UnitName } )
|
||||
|
||||
PilotUnit = UNIT:Register( UnitName )
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
world.searchObjects( { Object.Category.UNIT, Object.Category.STATIC, Object.Category.SCENERY, Object.Category.WEAPON }, SphereSearch, FindEjectedPilot )
|
||||
|
||||
self.CSAR[CSARName] = {}
|
||||
self.CSAR[CSARName].PilotUnit = PlaneUnit
|
||||
self.CSAR[CSARName].Task = nil
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -247,7 +285,7 @@ do -- TASK_CARGO_DISPATCHER
|
||||
--
|
||||
function TASK_CARGO_DISPATCHER:SetCSARRadius( CSARRadius )
|
||||
|
||||
self.Detection:SetFriendliesRange( CSARRadius or 50000 )
|
||||
self.CSARRadius = CSARRadius or 50000
|
||||
|
||||
return self
|
||||
end
|
||||
@ -336,7 +374,7 @@ do -- TASK_CARGO_DISPATCHER
|
||||
-- New CSAR Task
|
||||
local SetCargo = self:EvaluateCSAR( CSARData.PilotUnit )
|
||||
local CSARTask = TASK_CARGO_CSAR:New( Mission, self.SetGroup, "Rescue Pilot", SetCargo )
|
||||
CSARTask:SetDeployZones( { self.CSARDeployZones } )
|
||||
CSARTask:SetDeployZones( self.CSARDeployZones or {} )
|
||||
Mission:AddTask( CSARTask )
|
||||
TaskReport:Add( CSARTask:GetName() )
|
||||
end
|
||||
|
||||
@ -117,7 +117,7 @@ do -- TASK_MANAGER
|
||||
end
|
||||
|
||||
function TASK_MANAGER:onafterStartTasks( From, Event, To )
|
||||
self:Report()
|
||||
self:Manage()
|
||||
end
|
||||
|
||||
function TASK_MANAGER:onafterManage( From, Event, To )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user