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
|
return self
|
||||||
end
|
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.
|
--- Destroy the cargo.
|
||||||
-- @param #CARGO self
|
-- @param #CARGO self
|
||||||
function CARGO:Destroy()
|
function CARGO:Destroy()
|
||||||
|
|||||||
@ -727,10 +727,11 @@ do -- TASK_CARGO
|
|||||||
|
|
||||||
--- @param #TASK_CARGO self
|
--- @param #TASK_CARGO self
|
||||||
-- @param #list<Core.Zone#ZONE> DeployZones
|
-- @param #list<Core.Zone#ZONE> DeployZones
|
||||||
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @return #TASK_CARGO
|
-- @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
|
self.DeployZones[DeployZone:GetName()] = DeployZone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -205,7 +205,7 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
-- @param #string PlayerName
|
-- @param #string PlayerName
|
||||||
|
|
||||||
self:SetCSARRadius()
|
self:SetCSARRadius()
|
||||||
self:__Start( 5 )
|
self:__StartTasks( 5 )
|
||||||
|
|
||||||
-- For CSAR missions, we process the event when a pilot ejects.
|
-- 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 )
|
function TASK_CARGO_DISPATCHER:OnEventEjection( EventData )
|
||||||
|
|
||||||
self:E( { EventData = EventData } )
|
self:E( { EventData = EventData } )
|
||||||
|
|
||||||
local PilotUnit = EventData.IniUnit
|
local PlaneUnit = EventData.IniUnit
|
||||||
local CSARName = EventData.IniUnitName
|
local CSARName = EventData.IniUnitName
|
||||||
|
|
||||||
self.CSAR[CSARName] = {}
|
local PilotUnit = nil
|
||||||
self.CSAR[CSARName].PilotUnit = PilotUnit
|
|
||||||
self.CSAR[CSARName].Task = 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
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -247,7 +285,7 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
--
|
--
|
||||||
function TASK_CARGO_DISPATCHER:SetCSARRadius( CSARRadius )
|
function TASK_CARGO_DISPATCHER:SetCSARRadius( CSARRadius )
|
||||||
|
|
||||||
self.Detection:SetFriendliesRange( CSARRadius or 50000 )
|
self.CSARRadius = CSARRadius or 50000
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -336,7 +374,7 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
-- New CSAR Task
|
-- New CSAR Task
|
||||||
local SetCargo = self:EvaluateCSAR( CSARData.PilotUnit )
|
local SetCargo = self:EvaluateCSAR( CSARData.PilotUnit )
|
||||||
local CSARTask = TASK_CARGO_CSAR:New( Mission, self.SetGroup, "Rescue Pilot", SetCargo )
|
local CSARTask = TASK_CARGO_CSAR:New( Mission, self.SetGroup, "Rescue Pilot", SetCargo )
|
||||||
CSARTask:SetDeployZones( { self.CSARDeployZones } )
|
CSARTask:SetDeployZones( self.CSARDeployZones or {} )
|
||||||
Mission:AddTask( CSARTask )
|
Mission:AddTask( CSARTask )
|
||||||
TaskReport:Add( CSARTask:GetName() )
|
TaskReport:Add( CSARTask:GetName() )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -117,7 +117,7 @@ do -- TASK_MANAGER
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TASK_MANAGER:onafterStartTasks( From, Event, To )
|
function TASK_MANAGER:onafterStartTasks( From, Event, To )
|
||||||
self:Report()
|
self:Manage()
|
||||||
end
|
end
|
||||||
|
|
||||||
function TASK_MANAGER:onafterManage( From, Event, To )
|
function TASK_MANAGER:onafterManage( From, Event, To )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user