mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
-- Lots of fixes done. Especially on the
- Messaging - Menu system - Crashing DCS - Routing
This commit is contained in:
parent
b1ecdc727c
commit
af23aa3b79
@ -123,15 +123,20 @@ do -- ACT_ROUTE
|
|||||||
--- Set a Cancel Menu item.
|
--- Set a Cancel Menu item.
|
||||||
-- @param #ACT_ROUTE self
|
-- @param #ACT_ROUTE self
|
||||||
-- @return #ACT_ROUTE
|
-- @return #ACT_ROUTE
|
||||||
function ACT_ROUTE:SetMenuCancel( MenuGroup, MenuText, ParentMenu, MenuTime )
|
function ACT_ROUTE:SetMenuCancel( MenuGroup, MenuText, ParentMenu )
|
||||||
|
|
||||||
MENU_GROUP_COMMAND:New(
|
local MenuTime = timer.getTime() + 1
|
||||||
|
|
||||||
|
self.CancelMenuGroupCommand = MENU_GROUP_COMMAND:New(
|
||||||
MenuGroup,
|
MenuGroup,
|
||||||
MenuText,
|
MenuText,
|
||||||
ParentMenu,
|
ParentMenu,
|
||||||
self.MenuCancel,
|
self.MenuCancel,
|
||||||
self
|
self
|
||||||
):SetTime(MenuTime)
|
):SetTime( MenuTime )
|
||||||
|
|
||||||
|
ParentMenu:SetTime( MenuTime )
|
||||||
|
ParentMenu:Remove( MenuTime )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -206,7 +211,9 @@ do -- ACT_ROUTE
|
|||||||
|
|
||||||
|
|
||||||
function ACT_ROUTE:MenuCancel()
|
function ACT_ROUTE:MenuCancel()
|
||||||
self:Cancel()
|
self:F("Cancelled")
|
||||||
|
self.CancelMenuGroupCommand:Remove()
|
||||||
|
self:__Cancel( 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Task Events
|
--- Task Events
|
||||||
|
|||||||
@ -258,7 +258,6 @@ do -- CARGO
|
|||||||
self:AddTransition( "*", "Destroyed", "Destroyed" )
|
self:AddTransition( "*", "Destroyed", "Destroyed" )
|
||||||
self:AddTransition( "*", "Respawn", "UnLoaded" )
|
self:AddTransition( "*", "Respawn", "UnLoaded" )
|
||||||
|
|
||||||
|
|
||||||
self.Type = Type
|
self.Type = Type
|
||||||
self.Name = Name
|
self.Name = Name
|
||||||
self.Weight = Weight or 0
|
self.Weight = Weight or 0
|
||||||
@ -268,6 +267,9 @@ do -- CARGO
|
|||||||
self.Slingloadable = false
|
self.Slingloadable = false
|
||||||
self.Moveable = false
|
self.Moveable = false
|
||||||
self.Containable = false
|
self.Containable = false
|
||||||
|
self.LoadAction = ""
|
||||||
|
|
||||||
|
self.CargoLimit = 0
|
||||||
|
|
||||||
self.LoadRadius = LoadRadius or 500
|
self.LoadRadius = LoadRadius or 500
|
||||||
self.NearRadius = NearRadius or 25
|
self.NearRadius = NearRadius or 25
|
||||||
@ -293,6 +295,12 @@ do -- CARGO
|
|||||||
return CargoFound
|
return CargoFound
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if the cargo can be Slingloaded.
|
||||||
|
-- @param #CARGO self
|
||||||
|
function CARGO:CanSlingload()
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if the cargo can be Boarded.
|
--- Check if the cargo can be Boarded.
|
||||||
-- @param #CARGO self
|
-- @param #CARGO self
|
||||||
function CARGO:CanBoard()
|
function CARGO:CanBoard()
|
||||||
@ -318,9 +326,6 @@ do -- CARGO
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Destroy the cargo.
|
--- Destroy the cargo.
|
||||||
-- @param #CARGO self
|
-- @param #CARGO self
|
||||||
function CARGO:Destroy()
|
function CARGO:Destroy()
|
||||||
@ -362,6 +367,19 @@ do -- CARGO
|
|||||||
return self.Type
|
return self.Type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get the coalition of the Cargo.
|
||||||
|
-- @param #CARGO self
|
||||||
|
-- @return Coalition
|
||||||
|
function CARGO:GetCoalition()
|
||||||
|
if self:IsLoaded() then
|
||||||
|
return self.CargoCarrier:GetCoalition()
|
||||||
|
else
|
||||||
|
return self.CargoObject:GetCoalition()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the current coordinates of the Cargo.
|
--- Get the current coordinates of the Cargo.
|
||||||
-- @param #CARGO self
|
-- @param #CARGO self
|
||||||
-- @return Core.Point#COORDINATE The coordinates of the Cargo.
|
-- @return Core.Point#COORDINATE The coordinates of the Cargo.
|
||||||
@ -792,6 +810,32 @@ do -- CARGO_REPRESENTABLE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Send a message to a @{Group} through a communication channel near the cargo.
|
||||||
|
-- @param #CARGO_REPRESENTABLE self
|
||||||
|
-- @param #string Message
|
||||||
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
|
-- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
|
||||||
|
function CARGO_REPRESENTABLE:MessageToGroup( Message, TaskGroup, Name )
|
||||||
|
|
||||||
|
local CoordinateZone = ZONE_RADIUS:New( "Zone" , self:GetCoordinate():GetVec2(), 500 )
|
||||||
|
CoordinateZone:Scan( { Object.Category.UNIT } )
|
||||||
|
for _, DCSUnit in pairs( CoordinateZone:GetScannedUnits() ) do
|
||||||
|
local NearUnit = UNIT:Find( DCSUnit )
|
||||||
|
self:F({NearUnit=NearUnit})
|
||||||
|
local NearUnitCoalition = NearUnit:GetCoalition()
|
||||||
|
local CargoCoalition = self:GetCoalition()
|
||||||
|
if NearUnitCoalition == CargoCoalition then
|
||||||
|
local Attributes = NearUnit:GetDesc()
|
||||||
|
self:F({Desc=Attributes})
|
||||||
|
if NearUnit:HasAttribute( "Trucks" ) then
|
||||||
|
MESSAGE:New( Message, 20, NearUnit:GetCallsign() .. " reporting - Cargo " .. self:GetName() ):ToGroup( TaskGroup )
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end -- CARGO_REPRESENTABLE
|
end -- CARGO_REPRESENTABLE
|
||||||
|
|
||||||
@ -825,7 +869,7 @@ do -- CARGO_REPORTABLE
|
|||||||
-- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
|
-- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
|
||||||
function CARGO_REPORTABLE:MessageToGroup( Message, TaskGroup, Name )
|
function CARGO_REPORTABLE:MessageToGroup( Message, TaskGroup, Name )
|
||||||
|
|
||||||
MESSAGE:New( Message, 20, "Cargo " .. self:GetName() ):ToGroup( TaskGroup )
|
MESSAGE:New( Message, 20, "Cargo " .. self:GetName() .. " reporting" ):ToGroup( TaskGroup )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -95,6 +95,7 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius )
|
|||||||
|
|
||||||
|
|
||||||
self:SetWeight( WeightGroup )
|
self:SetWeight( WeightGroup )
|
||||||
|
self.CargoLimit = 10
|
||||||
|
|
||||||
self:T( { "Weight Cargo", WeightGroup } )
|
self:T( { "Weight Cargo", WeightGroup } )
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,12 @@ do -- CARGO_SLINGLOAD
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Check if the cargo can be Slingloaded.
|
||||||
|
-- @param #CARGO self
|
||||||
|
function CARGO:CanSlingload()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if the cargo can be Boarded.
|
--- Check if the cargo can be Boarded.
|
||||||
-- @param #CARGO_SLINGLOAD self
|
-- @param #CARGO_SLINGLOAD self
|
||||||
function CARGO_SLINGLOAD:CanBoard()
|
function CARGO_SLINGLOAD:CanBoard()
|
||||||
|
|||||||
@ -174,6 +174,7 @@
|
|||||||
EVENT = {
|
EVENT = {
|
||||||
ClassName = "EVENT",
|
ClassName = "EVENT",
|
||||||
ClassID = 0,
|
ClassID = 0,
|
||||||
|
MissionEnd = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
world.event.S_EVENT_NEW_CARGO = world.event.S_EVENT_MAX + 1000
|
world.event.S_EVENT_NEW_CARGO = world.event.S_EVENT_MAX + 1000
|
||||||
@ -748,8 +749,13 @@ function EVENT:onEvent( Event )
|
|||||||
if self and
|
if self and
|
||||||
self.Events and
|
self.Events and
|
||||||
self.Events[Event.id] and
|
self.Events[Event.id] and
|
||||||
|
self.MissionEnd == false and
|
||||||
( Event.initiator ~= nil or ( Event.initiator == nil and Event.id ~= EVENTS.PlayerLeaveUnit ) ) then
|
( Event.initiator ~= nil or ( Event.initiator == nil and Event.id ~= EVENTS.PlayerLeaveUnit ) ) then
|
||||||
|
|
||||||
|
if Event.id and Event.id == EVENTS.MissionEnd then
|
||||||
|
self.MissionEnd = true
|
||||||
|
end
|
||||||
|
|
||||||
if Event.initiator then
|
if Event.initiator then
|
||||||
|
|
||||||
Event.IniObjectCategory = Event.initiator:getCategory()
|
Event.IniObjectCategory = Event.initiator:getCategory()
|
||||||
|
|||||||
@ -724,6 +724,10 @@ do -- FSM
|
|||||||
return self.current
|
return self.current
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function FSM:GetCurrentState()
|
||||||
|
return self.current
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function FSM:Is( State )
|
function FSM:Is( State )
|
||||||
return self.current == State
|
return self.current == State
|
||||||
|
|||||||
@ -174,17 +174,17 @@ do -- TASK_CARGO
|
|||||||
|
|
||||||
Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "SelectAction", Rejected = "Reject" } )
|
Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "SelectAction", Rejected = "Reject" } )
|
||||||
|
|
||||||
Fsm:AddTransition( { "Planned", "Assigned", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Loaded", "UnLoaded", "Landed", "Boarding" }, "SelectAction", "*" )
|
Fsm:AddTransition( { "Planned", "Assigned", "Cancelled", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Loaded", "UnLoaded", "Landed", "Boarding" }, "SelectAction", "*" )
|
||||||
|
|
||||||
Fsm:AddTransition( "*", "RouteToPickup", "RoutingToPickup" )
|
Fsm:AddTransition( "*", "RouteToPickup", "RoutingToPickup" )
|
||||||
Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup", Cancelled = "CancelRouteToPickup" } )
|
Fsm:AddProcess ( "RoutingToPickup", "RouteToPickupPoint", ACT_ROUTE_POINT:New(), { Arrived = "ArriveAtPickup", Cancelled = "CancelRouteToPickup" } )
|
||||||
Fsm:AddTransition( "Arrived", "ArriveAtPickup", "ArrivedAtPickup" )
|
Fsm:AddTransition( "Arrived", "ArriveAtPickup", "ArrivedAtPickup" )
|
||||||
Fsm:AddTransition( "Cancelled", "CancelRouteToPickup", "WaitingForCommand" )
|
Fsm:AddTransition( "Cancelled", "CancelRouteToPickup", "Cancelled" )
|
||||||
|
|
||||||
Fsm:AddTransition( "*", "RouteToDeploy", "RoutingToDeploy" )
|
Fsm:AddTransition( "*", "RouteToDeploy", "RoutingToDeploy" )
|
||||||
Fsm:AddProcess ( "RoutingToDeploy", "RouteToDeployZone", ACT_ROUTE_ZONE:New(), { Arrived = "ArriveAtDeploy", Cancelled = "CancelRouteToDeploy" } )
|
Fsm:AddProcess ( "RoutingToDeploy", "RouteToDeployZone", ACT_ROUTE_ZONE:New(), { Arrived = "ArriveAtDeploy", Cancelled = "CancelRouteToDeploy" } )
|
||||||
Fsm:AddTransition( "Arrived", "ArriveAtDeploy", "ArrivedAtDeploy" )
|
Fsm:AddTransition( "Arrived", "ArriveAtDeploy", "ArrivedAtDeploy" )
|
||||||
Fsm:AddTransition( "Cancelled", "CancelRouteToDeploy", "WaitingForCommand" )
|
Fsm:AddTransition( "Cancelled", "CancelRouteToDeploy", "Cancelled" )
|
||||||
|
|
||||||
Fsm:AddTransition( { "ArrivedAtPickup", "ArrivedAtDeploy", "Landing" }, "Land", "Landing" )
|
Fsm:AddTransition( { "ArrivedAtPickup", "ArrivedAtDeploy", "Landing" }, "Land", "Landing" )
|
||||||
Fsm:AddTransition( "Landing", "Landed", "Landed" )
|
Fsm:AddTransition( "Landing", "Landed", "Landed" )
|
||||||
@ -249,7 +249,7 @@ do -- TASK_CARGO
|
|||||||
self:F( { CargoUnloaded = Cargo:IsUnLoaded(), CargoLoaded = Cargo:IsLoaded(), CargoItemCount = CargoItemCount } )
|
self:F( { CargoUnloaded = Cargo:IsUnLoaded(), CargoLoaded = Cargo:IsLoaded(), CargoItemCount = CargoItemCount } )
|
||||||
|
|
||||||
if Cargo:IsUnLoaded() then
|
if Cargo:IsUnLoaded() then
|
||||||
if CargoItemCount <= Task.CargoLimit then
|
if CargoItemCount < 1 then
|
||||||
if Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then
|
if Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then
|
||||||
local NotInDeployZones = true
|
local NotInDeployZones = true
|
||||||
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
||||||
@ -261,18 +261,26 @@ do -- TASK_CARGO
|
|||||||
if not TaskUnit:InAir() then
|
if not TaskUnit:InAir() then
|
||||||
if Cargo:CanBoard() == true then
|
if Cargo:CanBoard() == true then
|
||||||
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
||||||
Cargo:Report( "Reporting for boarding at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "board", TaskUnit:GetGroup() )
|
Cargo:Report( "ready for boarding at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "board", TaskUnit:GetGroup() )
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Board cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime)
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Board cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime)
|
||||||
else
|
else
|
||||||
Cargo:Report( "Reporting at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
Cargo:Report( "Board at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Cargo:CanLoad() == true then
|
if Cargo:CanLoad() == true then
|
||||||
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
||||||
Cargo:Report( "Reporting for loading at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "load", TaskUnit:GetGroup() )
|
Cargo:Report( "ready for loading at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "load", TaskUnit:GetGroup() )
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Load cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuLoadCargo, self, Cargo ):SetTime(MenuTime)
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Load cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuLoadCargo, self, Cargo ):SetTime(MenuTime)
|
||||||
else
|
else
|
||||||
Cargo:Report( "Reporting at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
Cargo:Report( "Load at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if Cargo:CanSlingload() == true then
|
||||||
|
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
||||||
|
Cargo:Report( "ready for slingloading at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "slingload", TaskUnit:GetGroup() )
|
||||||
|
else
|
||||||
|
Cargo:Report( "Slingload at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -282,11 +290,15 @@ do -- TASK_CARGO
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
if self:Is( "RoutingToPickup" ) then
|
||||||
|
else
|
||||||
|
self:F("route menu set")
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime)
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime)
|
||||||
TaskUnit.Menu:SetTime( MenuTime )
|
TaskUnit.Menu:SetTime( MenuTime )
|
||||||
Cargo:ReportResetAll( TaskUnit:GetGroup() )
|
Cargo:ReportResetAll( TaskUnit:GetGroup() )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
-- Cargo in deployzones are flagged as deployed.
|
-- Cargo in deployzones are flagged as deployed.
|
||||||
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
||||||
if Cargo:IsInZone( DeployZone ) then
|
if Cargo:IsInZone( DeployZone ) then
|
||||||
@ -405,7 +417,6 @@ do -- TASK_CARGO
|
|||||||
function Fsm:onafterArriveAtPickup( TaskUnit, Task )
|
function Fsm:onafterArriveAtPickup( TaskUnit, Task )
|
||||||
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||||
if self.Cargo:IsAlive() then
|
if self.Cargo:IsAlive() then
|
||||||
self.Cargo:Smoke( Task:GetSmokeColor(), 15 )
|
|
||||||
if TaskUnit:IsAir() then
|
if TaskUnit:IsAir() then
|
||||||
Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() )
|
Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() )
|
||||||
self:__Land( -0.1, "Pickup" )
|
self:__Land( -0.1, "Pickup" )
|
||||||
@ -422,6 +433,7 @@ do -- TASK_CARGO
|
|||||||
function Fsm:onafterCancelRouteToPickup( TaskUnit, Task )
|
function Fsm:onafterCancelRouteToPickup( TaskUnit, Task )
|
||||||
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
|
Task:GetMission():GetCommandCenter():MessageToGroup( "Cancelled routing to Cargo " .. self.Cargo:GetName(), TaskUnit:GetGroup() )
|
||||||
self:__SelectAction( -0.1 )
|
self:__SelectAction( -0.1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -459,6 +471,7 @@ do -- TASK_CARGO
|
|||||||
function Fsm:onafterCancelRouteToDeploy( TaskUnit, Task )
|
function Fsm:onafterCancelRouteToDeploy( TaskUnit, Task )
|
||||||
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
|
Task:GetMission():GetCommandCenter():MessageToGroup( "Cancelled routing to deploy zone " .. self.DeployZone:GetName(), TaskUnit:GetGroup() )
|
||||||
self:__SelectAction( -0.1 )
|
self:__SelectAction( -0.1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -518,8 +531,7 @@ do -- TASK_CARGO
|
|||||||
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
if Cargo and Cargo:IsAlive() then
|
if Cargo and Cargo:IsAlive() then
|
||||||
self.Cargo = Cargo -- Core.Cargo#CARGO_GROUP
|
self:__Board( -0.1, Cargo )
|
||||||
self:__Board( -0.1 )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -527,22 +539,22 @@ do -- TASK_CARGO
|
|||||||
--- @param #FSM_PROCESS self
|
--- @param #FSM_PROCESS self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @param Tasking.Task_Cargo#TASK_CARGO Task
|
-- @param Tasking.Task_Cargo#TASK_CARGO Task
|
||||||
function Fsm:onafterBoard( TaskUnit, Task )
|
function Fsm:onafterBoard( TaskUnit, Task, From, Event, To, Cargo )
|
||||||
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
function self.Cargo:OnEnterLoaded( From, Event, To, TaskUnit, TaskProcess )
|
function Cargo:OnEnterLoaded( From, Event, To, TaskUnit, TaskProcess )
|
||||||
self:F({From, Event, To, TaskUnit, TaskProcess })
|
self:F({From, Event, To, TaskUnit, TaskProcess })
|
||||||
TaskProcess:__Boarded( 0.1 )
|
TaskProcess:__Boarded( 0.1, self )
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Cargo:IsAlive() then
|
if Cargo:IsAlive() then
|
||||||
if self.Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
||||||
if TaskUnit:InAir() then
|
if TaskUnit:InAir() then
|
||||||
--- ABORT the boarding. Split group if any and go back to select action.
|
--- ABORT the boarding. Split group if any and go back to select action.
|
||||||
else
|
else
|
||||||
self.Cargo:MessageToGroup( "Boarding ...", TaskUnit:GetGroup() )
|
Cargo:MessageToGroup( "Boarding ...", TaskUnit:GetGroup() )
|
||||||
if not self.Cargo:IsBoarding() then
|
if not Cargo:IsBoarding() then
|
||||||
self.Cargo:Board( TaskUnit, 20, self )
|
Cargo:Board( TaskUnit, 20, self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -555,14 +567,14 @@ do -- TASK_CARGO
|
|||||||
--- @param #FSM_PROCESS self
|
--- @param #FSM_PROCESS self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @param Tasking.Task_Cargo#TASK_CARGO Task
|
-- @param Tasking.Task_Cargo#TASK_CARGO Task
|
||||||
function Fsm:onafterBoarded( TaskUnit, Task )
|
function Fsm:onafterBoarded( TaskUnit, Task, From, Event, To, Cargo )
|
||||||
|
|
||||||
local TaskUnitName = TaskUnit:GetName()
|
local TaskUnitName = TaskUnit:GetName()
|
||||||
self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
self.Cargo:MessageToGroup( "Boarded ...", TaskUnit:GetGroup() )
|
Cargo:MessageToGroup( "Boarded ...", TaskUnit:GetGroup() )
|
||||||
|
|
||||||
self:Load( self.Cargo )
|
self:__Load( -0.1, Cargo )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -570,16 +582,18 @@ do -- TASK_CARGO
|
|||||||
--- @param #FSM_PROCESS self
|
--- @param #FSM_PROCESS self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @param Tasking.Task_Cargo#TASK_CARGO Task
|
-- @param Tasking.Task_Cargo#TASK_CARGO Task
|
||||||
function Fsm:onafterLoad( TaskUnit, Task, From, Event, To, Cargo )
|
function Fsm:onenterLoaded( TaskUnit, Task, From, Event, To, Cargo )
|
||||||
|
|
||||||
local TaskUnitName = TaskUnit:GetName()
|
local TaskUnitName = TaskUnit:GetName()
|
||||||
self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
if not Cargo:IsLoaded() then
|
if not Cargo:IsLoaded() then
|
||||||
Cargo:Load( TaskUnit )
|
Cargo:Load( TaskUnit )
|
||||||
TaskUnit:AddCargo( Cargo )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Cargo:MessageToGroup( "Loaded ...", TaskUnit:GetGroup() )
|
||||||
|
TaskUnit:AddCargo( Cargo )
|
||||||
|
|
||||||
self:__SelectAction( 1 )
|
self:__SelectAction( 1 )
|
||||||
|
|
||||||
-- TODO:I need to find a more decent solution for this.
|
-- TODO:I need to find a more decent solution for this.
|
||||||
@ -640,9 +654,9 @@ do -- TASK_CARGO
|
|||||||
if self.Cargo:IsAlive() then
|
if self.Cargo:IsAlive() then
|
||||||
self.Cargo:MessageToGroup( "UnBoarding ...", TaskUnit:GetGroup() )
|
self.Cargo:MessageToGroup( "UnBoarding ...", TaskUnit:GetGroup() )
|
||||||
if DeployZone then
|
if DeployZone then
|
||||||
self.Cargo:UnBoard( DeployZone:GetPointVec2(), 400, self )
|
self.Cargo:UnBoard( DeployZone:GetCoordinate():GetRandomCoordinateInRadius( 25, 10 ), 400, self )
|
||||||
else
|
else
|
||||||
self.Cargo:UnBoard( TaskUnit:GetPointVec2():AddX(60), 400, self )
|
self.Cargo:UnBoard( TaskUnit:GetCoordinate():GetRandomCoordinateInRadius( 25, 10 ), 400, self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -673,9 +687,9 @@ do -- TASK_CARGO
|
|||||||
|
|
||||||
if not Cargo:IsUnLoaded() then
|
if not Cargo:IsUnLoaded() then
|
||||||
if DeployZone then
|
if DeployZone then
|
||||||
Cargo:UnLoad( DeployZone:GetPointVec2(), 400, self )
|
Cargo:UnLoad( DeployZone:GetCoordinate():GetRandomCoordinateInRadius( 25, 10 ), 400, self )
|
||||||
else
|
else
|
||||||
Cargo:UnLoad( TaskUnit:GetPointVec2():AddX(60), 400, self )
|
Cargo:UnLoad( TaskUnit:GetCoordinate():GetRandomCoordinateInRadius( 25, 10 ), 400, self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
TaskUnit:RemoveCargo( Cargo )
|
TaskUnit:RemoveCargo( Cargo )
|
||||||
@ -752,6 +766,7 @@ do -- TASK_CARGO
|
|||||||
ActRouteCargo:SetRange( Cargo:GetLoadRadius() )
|
ActRouteCargo:SetRange( Cargo:GetLoadRadius() )
|
||||||
ActRouteCargo:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Cargo " .. Cargo:GetName(), TaskUnit.Menu )
|
ActRouteCargo:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Cargo " .. Cargo:GetName(), TaskUnit.Menu )
|
||||||
ActRouteCargo:Start()
|
ActRouteCargo:Start()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -769,6 +784,7 @@ do -- TASK_CARGO
|
|||||||
ActRouteDeployZone:SetZone( DeployZone )
|
ActRouteDeployZone:SetZone( DeployZone )
|
||||||
ActRouteDeployZone:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Deploy Zone" .. DeployZone:GetName(), TaskUnit.Menu )
|
ActRouteDeployZone:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Deploy Zone" .. DeployZone:GetName(), TaskUnit.Menu )
|
||||||
ActRouteDeployZone:Start()
|
ActRouteDeployZone:Start()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -326,6 +326,9 @@ function UNIT:GetCallsign()
|
|||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
local UnitCallSign = DCSUnit:getCallsign()
|
local UnitCallSign = DCSUnit:getCallsign()
|
||||||
|
if UnitCallSign == "" then
|
||||||
|
UnitCallSign = DCSUnit:getName()
|
||||||
|
end
|
||||||
return UnitCallSign
|
return UnitCallSign
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user