mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
parent
bad2e81c56
commit
2e2aabdcc9
@ -302,7 +302,12 @@ end
|
||||
function AI_CARGO:IsInRadius( PointVec2 )
|
||||
self:F( { PointVec2 } )
|
||||
|
||||
local Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
|
||||
local Distance = 0
|
||||
if self:IsLoaded() then
|
||||
Distance = PointVec2:DistanceFromPointVec2( self.CargoCarrier:GetPointVec2() )
|
||||
else
|
||||
Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
|
||||
end
|
||||
self:T( Distance )
|
||||
|
||||
if Distance <= self.ReportRadius then
|
||||
@ -313,6 +318,24 @@ function AI_CARGO:IsInRadius( PointVec2 )
|
||||
end
|
||||
|
||||
|
||||
--- Check if Cargo is the given @{Zone}.
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Core.Zone#ZONE_BASE Zone
|
||||
-- @return #boolean **true** if cargo is in the Zone, **false** if cargo is not in the Zone.
|
||||
function AI_CARGO:IsInZone( Zone )
|
||||
self:F( { Zone } )
|
||||
|
||||
if self:IsLoaded() then
|
||||
return Zone:IsPointVec2InZone( self.CargoCarrier:GetPointVec2() )
|
||||
else
|
||||
return Zone:IsPointVec2InZone( self.CargoObject:GetPointVec2() )
|
||||
end
|
||||
|
||||
return nil
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- Check if CargoCarrier is near the Cargo to be Loaded.
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Core.Point#POINT_VEC2 PointVec2
|
||||
|
||||
@ -73,41 +73,41 @@
|
||||
-- @extends Core.Base#BASE
|
||||
|
||||
|
||||
--- # 1) ZONE_BASE class, extends @{Base#BASE}
|
||||
--- # ZONE_BASE class, extends @{Base#BASE}
|
||||
--
|
||||
-- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
||||
--
|
||||
-- ## 1.1) Each zone has a name:
|
||||
-- ## Each zone has a name:
|
||||
--
|
||||
-- * @{#ZONE_BASE.GetName}(): Returns the name of the zone.
|
||||
--
|
||||
-- ## 1.2) Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}:
|
||||
-- ## Each zone implements two polymorphic functions defined in @{Zone#ZONE_BASE}:
|
||||
--
|
||||
-- * @{#ZONE_BASE.IsVec2InZone}(): Returns if a Vec2 is within the zone.
|
||||
-- * @{#ZONE_BASE.IsVec3InZone}(): Returns if a Vec3 is within the zone.
|
||||
--
|
||||
-- ## 1.3) A zone has a probability factor that can be set to randomize a selection between zones:
|
||||
-- ## A zone has a probability factor that can be set to randomize a selection between zones:
|
||||
--
|
||||
-- * @{#ZONE_BASE.SetRandomizeProbability}(): Set the randomization probability of a zone to be selected, taking a value between 0 and 1 ( 0 = 0%, 1 = 100% )
|
||||
-- * @{#ZONE_BASE.GetRandomizeProbability}(): Get the randomization probability of a zone to be selected, passing a value between 0 and 1 ( 0 = 0%, 1 = 100% )
|
||||
-- * @{#ZONE_BASE.GetZoneMaybe}(): Get the zone taking into account the randomization probability. nil is returned if this zone is not a candidate.
|
||||
--
|
||||
-- ## 1.4) A zone manages Vectors:
|
||||
-- ## A zone manages Vectors:
|
||||
--
|
||||
-- * @{#ZONE_BASE.GetVec2}(): Returns the @{DCSTypes#Vec2} coordinate of the zone.
|
||||
-- * @{#ZONE_BASE.GetRandomVec2}(): Define a random @{DCSTypes#Vec2} within the zone.
|
||||
--
|
||||
-- ## 1.5) A zone has a bounding square:
|
||||
-- ## A zone has a bounding square:
|
||||
--
|
||||
-- * @{#ZONE_BASE.GetBoundingSquare}(): Get the outer most bounding square of the zone.
|
||||
--
|
||||
-- ## 1.6) A zone can be marked:
|
||||
-- ## A zone can be marked:
|
||||
--
|
||||
-- * @{#ZONE_BASE.SmokeZone}(): Smokes the zone boundaries in a color.
|
||||
-- * @{#ZONE_BASE.FlareZone}(): Flares the zone boundaries in a color.
|
||||
--
|
||||
-- ===
|
||||
-- @field #ZONE_BASE ZONE_BASE
|
||||
--
|
||||
ZONE_BASE = {
|
||||
ClassName = "ZONE_BASE",
|
||||
ZoneName = "",
|
||||
@ -144,20 +144,21 @@ function ZONE_BASE:GetName()
|
||||
|
||||
return self.ZoneName
|
||||
end
|
||||
--- Returns if a location is within the zone.
|
||||
|
||||
--- Returns if a Vec2 is within the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param Dcs.DCSTypes#Vec2 Vec2 The location to test.
|
||||
-- @return #boolean true if the location is within the zone.
|
||||
-- @param Dcs.DCSTypes#Vec2 Vec2 The Vec2 to test.
|
||||
-- @return #boolean true if the Vec2 is within the zone.
|
||||
function ZONE_BASE:IsVec2InZone( Vec2 )
|
||||
self:F2( Vec2 )
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--- Returns if a point is within the zone.
|
||||
--- Returns if a Vec3 is within the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param Dcs.DCSTypes#Vec3 Vec3 The point to test.
|
||||
-- @return #boolean true if the point is within the zone.
|
||||
-- @return #boolean true if the Vec3 is within the zone.
|
||||
function ZONE_BASE:IsVec3InZone( Vec3 )
|
||||
self:F2( Vec3 )
|
||||
|
||||
@ -166,6 +167,31 @@ function ZONE_BASE:IsVec3InZone( Vec3 )
|
||||
return InZone
|
||||
end
|
||||
|
||||
--- Returns if a PointVec2 is within the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param Core.Point#POINT_VEC2 PointVec2 The PointVec2 to test.
|
||||
-- @return #boolean true if the PointVec2 is within the zone.
|
||||
function ZONE_BASE:IsPointVec2InZone( PointVec2 )
|
||||
self:F2( PointVec2 )
|
||||
|
||||
local InZone = self:IsVec2InZone( PointVec2:GetVec2() )
|
||||
|
||||
return InZone
|
||||
end
|
||||
|
||||
--- Returns if a PointVec3 is within the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param Core.Point#POINT_VEC3 PointVec3 The PointVec3 to test.
|
||||
-- @return #boolean true if the PointVec3 is within the zone.
|
||||
function ZONE_BASE:IsPointVec3InZone( PointVec3 )
|
||||
self:F2( PointVec3 )
|
||||
|
||||
local InZone = self:IsPointVec2InZone( PointVec3 )
|
||||
|
||||
return InZone
|
||||
end
|
||||
|
||||
|
||||
--- Returns the @{DCSTypes#Vec2} coordinate of the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @return #nil.
|
||||
@ -310,29 +336,29 @@ end
|
||||
-- @type ZONE_RADIUS
|
||||
-- @field Dcs.DCSTypes#Vec2 Vec2 The current location of the zone.
|
||||
-- @field Dcs.DCSTypes#Distance Radius The radius of the zone.
|
||||
-- @extends Core.Zone#ZONE_BASE
|
||||
-- @extends #ZONE_BASE
|
||||
|
||||
--- # 2) @{Zone#ZONE_RADIUS} class, extends @{Zone#ZONE_BASE}
|
||||
--- # ZONE_RADIUS class, extends @{Zone#ZONE_BASE}
|
||||
--
|
||||
-- The ZONE_RADIUS class defined by a zone name, a location and a radius.
|
||||
-- This class implements the inherited functions from Core.Zone#ZONE_BASE taking into account the own zone format and properties.
|
||||
--
|
||||
-- ## 2.1) @{Zone#ZONE_RADIUS} constructor
|
||||
-- ## ZONE_RADIUS constructor
|
||||
--
|
||||
-- * @{#ZONE_RADIUS.New}(): Constructor.
|
||||
--
|
||||
-- ## 2.2) Manage the radius of the zone
|
||||
-- ## Manage the radius of the zone
|
||||
--
|
||||
-- * @{#ZONE_RADIUS.SetRadius}(): Sets the radius of the zone.
|
||||
-- * @{#ZONE_RADIUS.GetRadius}(): Returns the radius of the zone.
|
||||
--
|
||||
-- ## 2.3) Manage the location of the zone
|
||||
-- ## Manage the location of the zone
|
||||
--
|
||||
-- * @{#ZONE_RADIUS.SetVec2}(): Sets the @{DCSTypes#Vec2} of the zone.
|
||||
-- * @{#ZONE_RADIUS.GetVec2}(): Returns the @{DCSTypes#Vec2} of the zone.
|
||||
-- * @{#ZONE_RADIUS.GetVec3}(): Returns the @{DCSTypes#Vec3} of the zone, taking an additional height parameter.
|
||||
--
|
||||
-- ## 2.4) Zone point randomization
|
||||
-- ## Zone point randomization
|
||||
--
|
||||
-- Various functions exist to find random points within the zone.
|
||||
--
|
||||
@ -340,8 +366,6 @@ end
|
||||
-- * @{#ZONE_RADIUS.GetRandomPointVec2}(): Gets a @{Point#POINT_VEC2} object representing a random 2D point in the zone.
|
||||
-- * @{#ZONE_RADIUS.GetRandomPointVec3}(): Gets a @{Point#POINT_VEC3} object representing a random 3D point in the zone. Note that the height of the point is at landheight.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @field #ZONE_RADIUS ZONE_RADIUS
|
||||
--
|
||||
ZONE_RADIUS = {
|
||||
@ -615,17 +639,15 @@ end
|
||||
|
||||
|
||||
|
||||
-- @type ZONE
|
||||
-- @extends Core.Zone#ZONE_RADIUS
|
||||
--- @type ZONE
|
||||
-- @extends #ZONE_RADIUS
|
||||
|
||||
|
||||
--- # 3) ZONE class, extends @{Zone#ZONE_RADIUS}
|
||||
--- # ZONE class, extends @{Zone#ZONE_RADIUS}
|
||||
--
|
||||
-- The ZONE class, defined by the zone name as defined within the Mission Editor.
|
||||
-- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @field #ZONE ZONE
|
||||
--
|
||||
ZONE = {
|
||||
@ -655,18 +677,15 @@ function ZONE:New( ZoneName )
|
||||
end
|
||||
|
||||
|
||||
--- The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius.
|
||||
-- @type ZONE_UNIT
|
||||
--- @type ZONE_UNIT
|
||||
-- @field Wrapper.Unit#UNIT ZoneUNIT
|
||||
-- @extends Core.Zone#ZONE_RADIUS
|
||||
|
||||
--- # 4) #ZONE_UNIT class, extends @{Zone#ZONE_RADIUS}
|
||||
--- # ZONE_UNIT class, extends @{Zone#ZONE_RADIUS}
|
||||
--
|
||||
-- The ZONE_UNIT class defined by a zone around a @{Unit#UNIT} with a radius.
|
||||
-- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @field #ZONE_UNIT ZONE_UNIT
|
||||
--
|
||||
ZONE_UNIT = {
|
||||
@ -751,16 +770,14 @@ end
|
||||
|
||||
--- @type ZONE_GROUP
|
||||
-- @field Wrapper.Group#GROUP ZoneGROUP
|
||||
-- @extends Core.Zone#ZONE_RADIUS
|
||||
-- @extends #ZONE_RADIUS
|
||||
|
||||
|
||||
--- # 5) #ZONE_GROUP class, extends @{Zone#ZONE_RADIUS}
|
||||
--- # ZONE_GROUP class, extends @{Zone#ZONE_RADIUS}
|
||||
--
|
||||
-- The ZONE_GROUP class defines by a zone around a @{Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
|
||||
-- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @field #ZONE_GROUP ZONE_GROUP
|
||||
--
|
||||
ZONE_GROUP = {
|
||||
@ -818,16 +835,16 @@ end
|
||||
|
||||
--- @type ZONE_POLYGON_BASE
|
||||
-- @field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCSTypes#Vec2}.
|
||||
-- @extends Core.Zone#ZONE_BASE
|
||||
-- @extends #ZONE_BASE
|
||||
|
||||
|
||||
--- # 6) ZONE_POLYGON_BASE class, extends @{Zone#ZONE_BASE}
|
||||
--- # ZONE_POLYGON_BASE class, extends @{Zone#ZONE_BASE}
|
||||
--
|
||||
-- The ZONE_POLYGON_BASE class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||
-- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
-- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
||||
--
|
||||
-- ## 6.1) Zone point randomization
|
||||
-- ## Zone point randomization
|
||||
--
|
||||
-- Various functions exist to find random points within the zone.
|
||||
--
|
||||
@ -835,8 +852,6 @@ end
|
||||
-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec2}(): Return a @{Point#POINT_VEC2} object representing a random 2D point within the zone.
|
||||
-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec3}(): Return a @{Point#POINT_VEC3} object representing a random 3D point at landheight within the zone.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @field #ZONE_POLYGON_BASE ZONE_POLYGON_BASE
|
||||
--
|
||||
ZONE_POLYGON_BASE = {
|
||||
@ -870,6 +885,17 @@ function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Returns the center location of the polygon.
|
||||
-- @param #ZONE_GROUP self
|
||||
-- @return Dcs.DCSTypes#Vec2 The location of the zone based on the @{Group} location.
|
||||
function ZONE_POLYGON_BASE:GetVec2()
|
||||
self:F( self.ZoneName )
|
||||
|
||||
local Bounds = self:GetBoundingSquare()
|
||||
|
||||
return { x = ( Bounds.x2 + Bounds.x1 ) / 2, y = ( Bounds.y2 + Bounds.y1 ) / 2 }
|
||||
end
|
||||
|
||||
--- Flush polygon coordinates as a table in DCS.log.
|
||||
-- @param #ZONE_POLYGON_BASE self
|
||||
-- @return #ZONE_POLYGON_BASE self
|
||||
@ -1073,16 +1099,14 @@ end
|
||||
|
||||
|
||||
--- @type ZONE_POLYGON
|
||||
-- @extends Core.Zone#ZONE_POLYGON_BASE
|
||||
-- @extends #ZONE_POLYGON_BASE
|
||||
|
||||
|
||||
--- # 7) ZONE_POLYGON class, extends @{Zone#ZONE_POLYGON_BASE}
|
||||
--- # ZONE_POLYGON class, extends @{Zone#ZONE_POLYGON_BASE}
|
||||
--
|
||||
-- The ZONE_POLYGON class defined by a sequence of @{Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||
-- This class implements the inherited functions from @{Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @field #ZONE_POLYGON ZONE_POLYGON
|
||||
--
|
||||
ZONE_POLYGON = {
|
||||
|
||||
@ -75,6 +75,8 @@ do -- TASK_CARGO
|
||||
|
||||
self.SetCargo = SetCargo
|
||||
self.TaskType = TaskType
|
||||
|
||||
self.DeployZones = {} -- setmetatable( {}, { __mode = "v" } ) -- weak table on value
|
||||
|
||||
Mission:AddTask( self )
|
||||
|
||||
@ -83,14 +85,14 @@ do -- TASK_CARGO
|
||||
|
||||
Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "SelectAction", Rejected = "Reject" } )
|
||||
|
||||
Fsm:AddTransition( { "Assigned", "Landed", "Boarded", "Deployed" } , "SelectAction", "WaitingForCommand" )
|
||||
Fsm:AddTransition( "*", "SelectAction", "WaitingForCommand" )
|
||||
|
||||
Fsm:AddTransition( "WaitingForCommand", "RouteToPickup", "RoutingToPickup" )
|
||||
Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup" } )
|
||||
Fsm:AddTransition( "Arrived", "ArriveAtPickup", "ArrivedAtPickup" )
|
||||
|
||||
Fsm:AddTransition( "WaitingForCommand", "RouteToDeploy", "RoutingToDeploy" )
|
||||
Fsm:AddProcess ( "RoutingToDeploy", "RouteToDeployPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtDeploy" } )
|
||||
Fsm:AddProcess ( "RoutingToDeploy", "RouteToDeployZone", ACT_ROUTE_ZONE:New(), { Arrived = "ArriveAtDeploy" } )
|
||||
Fsm:AddTransition( "ArrivedAtDeploy", "ArriveAtDeploy", "ArrivedAtDeploy" )
|
||||
|
||||
Fsm:AddTransition( { "ArrivedAtPickup", "ArrivedAtDeploy" }, "Land", "Landing" )
|
||||
@ -146,14 +148,27 @@ do -- TASK_CARGO
|
||||
end
|
||||
|
||||
if Cargo:IsLoaded() then
|
||||
MENU_GROUP_COMMAND:New(
|
||||
TaskUnit:GetGroup(),
|
||||
"Deploy cargo " .. Cargo.Name,
|
||||
TaskUnit.Menu,
|
||||
self.MenuBoardCargo,
|
||||
self,
|
||||
Cargo
|
||||
)
|
||||
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
||||
if Cargo:IsInZone( DeployZone ) then
|
||||
MENU_GROUP_COMMAND:New(
|
||||
TaskUnit:GetGroup(),
|
||||
"Deploy cargo " .. Cargo.Name,
|
||||
TaskUnit.Menu,
|
||||
self.MenuUnBoardCargo,
|
||||
self,
|
||||
Cargo
|
||||
)
|
||||
else
|
||||
MENU_GROUP_COMMAND:New(
|
||||
TaskUnit:GetGroup(),
|
||||
"Route to deploy zone " .. DeployZoneName,
|
||||
TaskUnit.Menu,
|
||||
self.MenuRouteToDeploy,
|
||||
self,
|
||||
DeployZone
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -174,10 +189,18 @@ do -- TASK_CARGO
|
||||
self:__PrepareBoarding( 1.0, Cargo )
|
||||
end
|
||||
|
||||
function Fsm:MenuUnBoardCargo( Cargo )
|
||||
self:__PrepareUnBoarding( 1.0, Cargo )
|
||||
end
|
||||
|
||||
function Fsm:MenuRouteToPickup( Cargo )
|
||||
self:__RouteToPickup( 1.0, Cargo )
|
||||
end
|
||||
|
||||
function Fsm:MenuRouteToDeploy( DeployZone )
|
||||
self:__RouteToDeploy( 1.0, DeployZone )
|
||||
end
|
||||
|
||||
--- Route to Cargo
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
@ -196,16 +219,54 @@ do -- TASK_CARGO
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @param Tasking.Task_CARGO#TASK_CARGO Task
|
||||
function Fsm:OnAfterArriveAtPickup( TaskUnit, Task )
|
||||
function Fsm:onafterArriveAtPickup( TaskUnit, Task )
|
||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||
|
||||
if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then
|
||||
self:__Land( -0.1 )
|
||||
if TaskUnit:IsAir() then
|
||||
self:__Land( -0.1 )
|
||||
else
|
||||
self:__SelectAction( -0.1 )
|
||||
end
|
||||
else
|
||||
self:__ArriveAtCargo( -10 )
|
||||
self:__ArriveAtPickup( -10 )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Route to DeployZone
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
function Fsm:onafterRouteToDeploy( TaskUnit, Task, From, Event, To, DeployZone )
|
||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||
|
||||
|
||||
self.DeployZone = DeployZone
|
||||
Task:SetDeployZone( self.DeployZone, TaskUnit )
|
||||
self:__RouteToDeployZone( 0.1 )
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @param Tasking.Task_CARGO#TASK_CARGO Task
|
||||
function Fsm:onafterArriveAtDeploy( TaskUnit, Task )
|
||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||
|
||||
if TaskUnit:IsInZone( self.DeployZone ) then
|
||||
if TaskUnit:IsAir() then
|
||||
self:__Land( -0.1 )
|
||||
else
|
||||
self:__SelectAction( -0.1 )
|
||||
end
|
||||
else
|
||||
self:__ArriveAtDeploy( -10 )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
@ -291,7 +352,8 @@ do -- TASK_CARGO
|
||||
self:__ArriveAtCargo( -0.1 )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
@ -300,8 +362,53 @@ do -- TASK_CARGO
|
||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||
|
||||
Task:GetMission():GetCommandCenter():MessageToGroup( "Boarded ...", TaskUnit:GetGroup(), "Boarding" )
|
||||
self:__SelectAction( 1 )
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @param Tasking.Task_CARGO#TASK_CARGO Task
|
||||
function Fsm:OnAfterPrepareUnBoarding( TaskUnit, Task, From, Event, To, Cargo, DeployZone )
|
||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||
|
||||
self.DeployZone = DeployZone
|
||||
self.Cargo:__UnBoard( -0.1, DeployZone )
|
||||
end
|
||||
|
||||
---
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @param Tasking.Task_CARGO#TASK_CARGO Task
|
||||
function Fsm:OnAfterUnBoard( TaskUnit, Task )
|
||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||
|
||||
function self.Cargo:OnEnterUnLoaded( From, Event, To, TaskUnit, TaskProcess )
|
||||
|
||||
self:E({From, Event, To, TaskUnit, TaskProcess })
|
||||
|
||||
TaskProcess:__UnBoarded( 0.1 )
|
||||
|
||||
end
|
||||
|
||||
Task:GetMission():GetCommandCenter():MessageToGroup( "UnBoarding ...", TaskUnit:GetGroup(), "UnBoarding" )
|
||||
self.Cargo:__UnBoard( -0.1, self.DeployZone )
|
||||
end
|
||||
|
||||
|
||||
---
|
||||
-- @param #FSM_PROCESS self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @param Tasking.Task_CARGO#TASK_CARGO Task
|
||||
function Fsm:OnAfterUnBoarded( TaskUnit, Task )
|
||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||
|
||||
Task:GetMission():GetCommandCenter():MessageToGroup( "UnBoarded ...", TaskUnit:GetGroup(), "UnBoarding" )
|
||||
self:__SelectAction( 1 )
|
||||
end
|
||||
|
||||
|
||||
return self
|
||||
|
||||
end
|
||||
@ -311,6 +418,7 @@ do -- TASK_CARGO
|
||||
return self:GetStateString() .. " - " .. self:GetTaskName() .. " ( " .. self.TargetSetUnit:GetUnitTypesText() .. " )"
|
||||
end
|
||||
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param AI.AI_Cargo#AI_CARGO Cargo The cargo.
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
@ -326,41 +434,57 @@ do -- TASK_CARGO
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param Core.Point#POINT_VEC2 TargetPointVec2 The PointVec2 object where the Target is located on the map.
|
||||
-- @param Core.Zone#ZONE DeployZone
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
function TASK_CARGO:SetTargetPointVec2( TargetPointVec2, TaskUnit )
|
||||
-- @return #TASK_CARGO
|
||||
function TASK_CARGO:SetDeployZone( DeployZone, TaskUnit )
|
||||
|
||||
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
||||
|
||||
local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetPoint" ) -- Actions.Act_Route#ACT_ROUTE_POINT
|
||||
ActRouteTarget:SetPointVec2( TargetPointVec2 )
|
||||
local ActRouteDeployZone = ProcessUnit:GetProcess( "RoutingToDeploy", "RouteToDeployZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE
|
||||
ActRouteDeployZone:SetZone( DeployZone )
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @return Core.Point#POINT_VEC2 The PointVec2 object where the Target is located on the map.
|
||||
function TASK_CARGO:GetTargetPointVec2( TaskUnit )
|
||||
|
||||
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
||||
|
||||
local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetPoint" ) -- Actions.Act_Route#ACT_ROUTE_POINT
|
||||
return ActRouteTarget:GetPointVec2()
|
||||
end
|
||||
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param Core.Zone#ZONE_BASE TargetZone The Zone object where the Target is located on the map.
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
function TASK_CARGO:SetTargetZone( TargetZone, TaskUnit )
|
||||
|
||||
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param Core.Zone#ZONE DeployZone
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @return #TASK_CARGO
|
||||
function TASK_CARGO:AddDeployZone( DeployZone, TaskUnit )
|
||||
|
||||
self.DeployZones[DeployZone:GetName()] = DeployZone
|
||||
|
||||
local ActRouteTarget = ProcessUnit:GetProcess( "Engaging", "RouteToTargetZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE
|
||||
ActRouteTarget:SetZone( TargetZone )
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param Core.Zone#ZONE DeployZone
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @return #TASK_CARGO
|
||||
function TASK_CARGO:RemoveDeployZone( DeployZone, TaskUnit )
|
||||
|
||||
self.DeployZones[DeployZone:GetName()] = nil
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param @list<Core.Zone#ZONE> DeployZones
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
-- @return #TASK_CARGO
|
||||
function TASK_CARGO:SetDeployZones( DeployZones, TaskUnit )
|
||||
|
||||
for DeployZoneID, DeployZone in pairs( DeployZones ) do
|
||||
self.DeployZones[DeployZone:GetName()] = DeployZone
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
---
|
||||
-- Name: TAD-100 - A2G Task Dispatching DETECTION_AREAS
|
||||
-- Author: FlightControl
|
||||
-- Date Created: 06 Mar 2017
|
||||
--
|
||||
-- # Situation:
|
||||
--
|
||||
-- This mission demonstrates the dynamic task dispatching for Air to Ground operations.
|
||||
-- FACA's and FAC's are patrolling around the battle zone, while detecting targets.
|
||||
-- The detection method used is the DETECTION_AREAS method, which groups detected targets into zones.
|
||||
--
|
||||
-- # Test cases:
|
||||
--
|
||||
-- 1. Observe the FAC(A)'s detecting targets and grouping them.
|
||||
-- For test, each zone will have a circle of tyres, that are visible on the map too.
|
||||
-- 2. Check that the HQ provides menus to engage on a task set by the FACs.
|
||||
--
|
||||
HQ = GROUP:FindByName( "HQ", "Bravo HQ" )
|
||||
|
||||
CommandCenter = COMMANDCENTER:New( HQ, "Lima" )
|
||||
|
||||
Scoring = SCORING:New( "Detect Demo" )
|
||||
|
||||
Mission = MISSION
|
||||
:New( CommandCenter, "Overlord", "High", "Attack Detect Mission Briefing", coalition.side.RED )
|
||||
:AddScoring( Scoring )
|
||||
|
||||
FACSet = SET_GROUP:New():FilterPrefixes( "FAC" ):FilterCoalitions("red"):FilterStart()
|
||||
|
||||
FACAreas = DETECTION_AREAS:New( FACSet, 500 )
|
||||
FACAreas:BoundDetectedZones()
|
||||
|
||||
AttackGroups = SET_GROUP:New():FilterCoalitions( "red" ):FilterPrefixes( "Attack" ):FilterStart()
|
||||
TaskDispatcher = TASK_A2G_DISPATCHER:New( Mission, HQ, AttackGroups, FACAreas )
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
---
|
||||
-- Name: TSK-100 - Cargo Pickup
|
||||
-- Author: FlightControl
|
||||
-- Date Created: 25 Mar 2017
|
||||
--
|
||||
-- # Situation:
|
||||
--
|
||||
-- This mission demonstrates the pickup of cargo.
|
||||
--
|
||||
-- # Test cases:
|
||||
--
|
||||
--
|
||||
|
||||
do
|
||||
HQ = GROUP:FindByName( "HQ", "Bravo HQ" )
|
||||
|
||||
CommandCenter = COMMANDCENTER:New( HQ, "Lima" )
|
||||
|
||||
Scoring = SCORING:New( "Pickup Demo" )
|
||||
|
||||
Mission = MISSION
|
||||
:New( CommandCenter, "Transport", "High", "Pickup the team", coalition.side.BLUE )
|
||||
:AddScoring( Scoring )
|
||||
|
||||
TransportHelicopters = SET_GROUP:New():FilterPrefixes( "Transport" ):FilterStart()
|
||||
|
||||
CargoEngineer = UNIT:FindByName( "Engineer" )
|
||||
InfantryCargo = AI_CARGO_UNIT:New( CargoEngineer, "Engineer", "Engineer Sven", "81", 500, 25 )
|
||||
|
||||
SetCargo = SET_CARGO:New():FilterTypes( "Engineer" ):FilterStart()
|
||||
|
||||
Task_Cargo_Pickup = TASK_CARGO_TRANSPORT:New( Mission, TransportHelicopters, "Transport.001", SetCargo )
|
||||
|
||||
end
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user