From 9f5b9ab04ccf7bf273e3b1544a1f2433aea9c63b Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 6 Jul 2017 08:51:08 +0200 Subject: [PATCH 1/5] Progress --- Moose Development/Moose/Core/Cargo.lua | 81 +++++++++++++++++------ Moose Development/Moose/Core/Set.lua | 4 +- Moose Development/Moose/Wrapper/Group.lua | 39 ++++++----- 3 files changed, 85 insertions(+), 39 deletions(-) diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index 1ce873dcb..0741e867a 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -210,8 +210,7 @@ do -- CARGO -- The state transition method needs to start with the name **OnEnter + the name of the state**. -- These state transition methods need to provide a return value, which is specified at the function description. -- - -- @field #CARGO CARGO - -- + -- @field #CARGO CARGO = { ClassName = "CARGO", Type = nil, @@ -265,6 +264,8 @@ function CARGO:New( Type, Name, Weight ) --R2.1 self.Slingloadable = false self.Moveable = false self.Containable = false + + self:SetDeployed( false ) self.CargoScheduler = SCHEDULER:New() @@ -276,6 +277,15 @@ function CARGO:New( Type, Name, Weight ) --R2.1 return self end +--- Destroy the cargo. +-- @param #CARGO self +function CARGO:Destroy() + if self.CargoObject then + self.CargoObject:Destroy() + end + self:Destroyed() +end + --- Get the name of the Cargo. -- @param #CARGO self -- @return #string The name of the Cargo. @@ -335,6 +345,19 @@ function CARGO:IsAlive() end end +--- Set the cargo as deployed +-- @param #CARGO self +function CARGO:SetDeployed( Deployed ) + self.Deployed = Deployed +end + +--- Is the cargo deployed +-- @param #CARGO self +-- @return #boolean +function CARGO:IsDeployed() + return self.Deployed +end + @@ -486,6 +509,8 @@ end -- CARGO_REPRESENTABLE local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPORTABLE self:F( { Type, Name, Weight, ReportRadius } ) + self.CargoSet = SET_CARGO:New() -- Core.Set#SET_CARGO + self.ReportRadius = ReportRadius or 1000 self.CargoObject = CargoObject @@ -517,7 +542,7 @@ end -- CARGO_REPRESENTABLE end --- Send a CC message to a GROUP. - -- @param #COMMANDCENTER self + -- @param #CARGO_REPORTABLE 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. @@ -530,11 +555,44 @@ end -- CARGO_REPRESENTABLE end --- Get the range till cargo will board. - -- @param #CARGO self + -- @param #CARGO_REPORTABLE self -- @return #number The range till cargo will board. function CARGO_REPORTABLE:GetBoardingRange() return self.ReportRadius end + + --- Respawn the cargo. + -- @param #CARGO_REPORTABLE self + function CARGO_REPORTABLE:Respawn() + + for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do + local Cargo = CargoData -- #CARGO + Cargo:Destroy() + end + + local CargoObject = self.CargoObject -- Wrapper.Group#GROUP + local Template = CargoObject:GetTemplate() + CargoObject:Respawn( Template ) + + self:SetDeployed( false ) + + local WeightGroup = 0 + + for UnitID, UnitData in pairs( CargoObject:GetUnits() ) do + local Unit = UnitData -- Wrapper.Unit#UNIT + local WeightUnit = Unit:GetDesc().massEmpty + WeightGroup = WeightGroup + WeightUnit + local CargoUnit = CARGO_UNIT:New( Unit, self.Type, Unit:GetName(), WeightUnit ) + self.CargoSet:Add( CargoUnit:GetName(), CargoUnit ) + end + + self:SetWeight( WeightGroup ) + + self:T( { "Weight Cargo", WeightGroup } ) + + self:SetStartState( "UnLoaded" ) + + end end @@ -922,8 +980,6 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius ) local self = BASE:Inherit( self, CARGO_REPORTABLE:New( CargoGroup, Type, Name, 0, ReportRadius ) ) -- #CARGO_GROUP self:F( { Type, Name, ReportRadius } ) - self.CargoSet = SET_CARGO:New() - self.CargoObject = CargoGroup self:SetDeployed( false ) @@ -1051,19 +1107,6 @@ function CARGO_GROUP:GetCount() return self.CargoSet:Count() end ---- Set the cargo as deployed --- @param #CARGO_GROUP self -function CARGO_GROUP:SetDeployed( Deployed ) - self.Deployed = Deployed -end - ---- Is the cargo deployed --- @param #CARGO_GROUP self --- @return #boolean -function CARGO_GROUP:IsDeployed() - return self.Deployed -end - --- Enter UnBoarding State. -- @param #CARGO_GROUP self diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 0152e5cb8..3b8ece2df 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -2748,13 +2748,13 @@ SET_CARGO = { --- (R2.1) Creates a new SET_CARGO object, building a set of cargos belonging to a coalitions and categories. -- @param #SET_CARGO self --- @return #SET_CARGO self +-- @return #SET_CARGO -- @usage -- -- Define a new SET_CARGO Object. The DatabaseSet will contain a reference to all Cargos. -- DatabaseSet = SET_CARGO:New() function SET_CARGO:New() --R2.1 -- Inherits from BASE - local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.CARGOS ) ) + local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.CARGOS ) ) -- #SET_CARGO return self end diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 8e1deed6e..652e13c7e 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -869,25 +869,28 @@ end -- @param #table Template The template of the Group retrieved with GROUP:GetTemplate() function GROUP:Respawn( Template ) - local Vec3 = self:GetVec3() - Template.x = Vec3.x - Template.y = Vec3.z - --Template.x = nil - --Template.y = nil - - self:E( #Template.units ) - for UnitID, UnitData in pairs( self:GetUnits() ) do - local GroupUnit = UnitData -- Wrapper.Unit#UNIT - self:E( GroupUnit:GetName() ) - if GroupUnit:IsAlive() then - local GroupUnitVec3 = GroupUnit:GetVec3() - local GroupUnitHeading = GroupUnit:GetHeading() - Template.units[UnitID].alt = GroupUnitVec3.y - Template.units[UnitID].x = GroupUnitVec3.x - Template.units[UnitID].y = GroupUnitVec3.z - Template.units[UnitID].heading = GroupUnitHeading - self:E( { UnitID, Template.units[UnitID], Template.units[UnitID] } ) + if self:IsAlive() then + local Vec3 = self:GetVec3() + Template.x = Vec3.x + Template.y = Vec3.z + --Template.x = nil + --Template.y = nil + + self:E( #Template.units ) + for UnitID, UnitData in pairs( self:GetUnits() ) do + local GroupUnit = UnitData -- Wrapper.Unit#UNIT + self:E( GroupUnit:GetName() ) + if GroupUnit:IsAlive() then + local GroupUnitVec3 = GroupUnit:GetVec3() + local GroupUnitHeading = GroupUnit:GetHeading() + Template.units[UnitID].alt = GroupUnitVec3.y + Template.units[UnitID].x = GroupUnitVec3.x + Template.units[UnitID].y = GroupUnitVec3.z + Template.units[UnitID].heading = GroupUnitHeading + self:E( { UnitID, Template.units[UnitID], Template.units[UnitID] } ) + end end + end self:Destroy() From 71da9933d7dfa3a4be85e16f7d674d16b22de548 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 6 Jul 2017 11:23:04 +0200 Subject: [PATCH 2/5] Cargo auto respawn first part is working When all CARGO UNITS of a CARGO_GROUP are destroyed, then when RespawnOnDestroyed( true ) is used, the CARGO will respawn automatically. --- Moose Development/Moose/Core/Cargo.lua | 73 ++++++++++++++++++++------ 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index 0741e867a..5d16a4240 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -271,9 +271,7 @@ function CARGO:New( Type, Name, Weight ) --R2.1 CARGOS[self.Name] = self - self:SetEventPriority( 5 ) - return self end @@ -318,6 +316,13 @@ function CARGO:GetCoordinate() return self.CargoObject:GetCoordinate() end +--- Check if cargo is destroyed. +-- @param #CARGO self +-- @return #boolean true if destroyed +function CARGO:IsDestroyed() + return self:Is( "Destroyed" ) +end + --- Check if cargo is loaded. -- @param #CARGO self @@ -513,6 +518,8 @@ end -- CARGO_REPRESENTABLE self.ReportRadius = ReportRadius or 1000 self.CargoObject = CargoObject + + return self end @@ -565,9 +572,12 @@ end -- CARGO_REPRESENTABLE -- @param #CARGO_REPORTABLE self function CARGO_REPORTABLE:Respawn() + self:F({"Respawning"}) + for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do local Cargo = CargoData -- #CARGO Cargo:Destroy() + Cargo:SetStartState( "UnLoaded" ) end local CargoObject = self.CargoObject -- Wrapper.Group#GROUP @@ -577,23 +587,12 @@ end -- CARGO_REPRESENTABLE self:SetDeployed( false ) local WeightGroup = 0 - - for UnitID, UnitData in pairs( CargoObject:GetUnits() ) do - local Unit = UnitData -- Wrapper.Unit#UNIT - local WeightUnit = Unit:GetDesc().massEmpty - WeightGroup = WeightGroup + WeightUnit - local CargoUnit = CARGO_UNIT:New( Unit, self.Type, Unit:GetName(), WeightUnit ) - self.CargoSet:Add( CargoUnit:GetName(), CargoUnit ) - end - - self:SetWeight( WeightGroup ) - - self:T( { "Weight Cargo", WeightGroup } ) - + self:SetStartState( "UnLoaded" ) end + end do -- CARGO_UNIT @@ -644,6 +643,8 @@ function CARGO_UNIT:New( CargoUnit, Type, Name, Weight, NearRadius ) end ) + self:SetEventPriority( 5 ) + return self end @@ -653,6 +654,7 @@ end function CARGO_UNIT:Destroy() -- Cargo objects are deleted from the _DATABASE and SET_CARGO objects. + self:F( { CargoName = self:GetName() } ) _EVENTDISPATCHER:CreateEventDeleteCargo( self ) return self @@ -1000,6 +1002,30 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius ) -- Cargo objects are added to the _DATABASE and SET_CARGO objects. _EVENTDISPATCHER:CreateEventNewCargo( self ) + self:HandleEvent( EVENTS.Dead, + --- @param #CARGO Cargo + -- @param Core.Event#EVENTDATA EventData + function( Cargo, EventData ) + + local Destroyed = true + for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do + local Cargo = CargoData -- #CARGO + if Cargo:IsAlive() then + Destroyed = false + else + Cargo:Destroyed() + end + end + + if Destroyed then + self:Destroyed() + self:E( { "Cargo destroyed", Cargo } ) + end + end + ) + + self:SetEventPriority( 4 ) + return self end @@ -1213,6 +1239,23 @@ function CARGO_GROUP:onenterUnLoaded( From, Event, To, ToPointVec2, ... ) end + + --- Respawn the cargo when destroyed + -- @param #CARGO_GROUP self + -- @param #boolean RespawnDestroyed + function CARGO_GROUP:RespawnOnDestroyed( RespawnDestroyed ) + self:F({"In function RespawnOnDestroyed"}) + if RespawnDestroyed then + self.onenterDestroyed = function( self ) + self:F("IN FUNCTION") + self:Respawn() + end + else + self.onenterDestroyed = nil + end + + end + end -- CARGO_GROUP do -- CARGO_PACKAGE From 532a311db665c60f685a25f00908fc940e760b8b Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 6 Jul 2017 17:00:53 +0200 Subject: [PATCH 3/5] Cargo is now respawning correctly when: The cargo is destroyed The carrier crashes with cargo on board The player exits the carrier with cargo on board. --- Moose Development/Moose/Core/Cargo.lua | 79 +++++++++++++++----------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index 5d16a4240..d16e55f3c 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -581,6 +581,7 @@ end -- CARGO_REPRESENTABLE end local CargoObject = self.CargoObject -- Wrapper.Group#GROUP + CargoObject:Destroy() local Template = CargoObject:GetTemplate() CargoObject:Respawn( Template ) @@ -632,16 +633,16 @@ function CARGO_UNIT:New( CargoUnit, Type, Name, Weight, NearRadius ) self:T( self.ClassName ) - self:HandleEvent( EVENTS.Dead, - --- @param #CARGO Cargo - -- @param Core.Event#EVENTDATA EventData - function( Cargo, EventData ) - if Cargo:GetObjectName() == EventData.IniUnit:GetName() then - self:E( { "Cargo destroyed", Cargo } ) - Cargo:Destroyed() - end - end - ) +-- self:HandleEvent( EVENTS.Dead, +-- --- @param #CARGO Cargo +-- -- @param Core.Event#EVENTDATA EventData +-- function( Cargo, EventData ) +-- if Cargo:GetObjectName() == EventData.IniUnit:GetName() then +-- self:E( { "Cargo destroyed", Cargo } ) +-- Cargo:Destroyed() +-- end +-- end +-- ) self:SetEventPriority( 5 ) @@ -984,6 +985,7 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius ) self.CargoObject = CargoGroup self:SetDeployed( false ) + self.CargoGroup = CargoGroup local WeightGroup = 0 @@ -1002,33 +1004,44 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius ) -- Cargo objects are added to the _DATABASE and SET_CARGO objects. _EVENTDISPATCHER:CreateEventNewCargo( self ) - self:HandleEvent( EVENTS.Dead, - --- @param #CARGO Cargo - -- @param Core.Event#EVENTDATA EventData - function( Cargo, EventData ) - - local Destroyed = true - for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do - local Cargo = CargoData -- #CARGO - if Cargo:IsAlive() then - Destroyed = false - else - Cargo:Destroyed() - end - end - - if Destroyed then - self:Destroyed() - self:E( { "Cargo destroyed", Cargo } ) - end - end - ) - + self:HandleEvent( EVENTS.Dead, self.OnEventCargoDead ) + self:HandleEvent( EVENTS.Crash, self.OnEventCargoDead ) + self:HandleEvent( EVENTS.PlayerLeaveUnit, self.OnEventCargoDead ) + self:SetEventPriority( 4 ) return self end +--- @param #CARGO Cargo +-- @param Core.Event#EVENTDATA EventData +function CARGO_GROUP:OnEventCargoDead( EventData ) + + local Destroyed = false + + if self:IsDestroyed() or self:IsUnLoaded() then + Destroyed = true + for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do + local Cargo = CargoData -- #CARGO + if Cargo:IsAlive() then + Destroyed = false + else + Cargo:Destroyed() + end + end + else + if self.CargoCarrier:GetName() == EventData.IniUnitName then + Destroyed = true + end + end + + if Destroyed then + self:Destroyed() + self:E( { "Cargo group destroyed" } ) + end + +end + --- Enter Boarding State. -- @param #CARGO_GROUP self -- @param Wrapper.Unit#UNIT CargoCarrier @@ -1070,7 +1083,7 @@ function CARGO_GROUP:onenterLoaded( From, Event, To, CargoCarrier, ... ) end end - self.CargoObject:Destroy() + --self.CargoObject:Destroy() self.CargoCarrier = CargoCarrier end From 70f48a3d5352087ff521587919f9576390fee079 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 6 Jul 2017 19:13:15 +0200 Subject: [PATCH 4/5] Progress --- Moose Development/Moose/Tasking/Mission.lua | 2 +- Moose Development/Moose/Tasking/Task_CARGO.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Tasking/Mission.lua b/Moose Development/Moose/Tasking/Mission.lua index 0c5633ea9..832dd9d6c 100644 --- a/Moose Development/Moose/Tasking/Mission.lua +++ b/Moose Development/Moose/Tasking/Mission.lua @@ -450,7 +450,7 @@ do -- Group Assignment local MissionGroupName = MissionGroup:GetName() self.AssignedGroups[MissionGroupName] = nil - self:E( string.format( "Mission %s is unassigned to %s", MissionName, MissionGroupName ) ) + --self:E( string.format( "Mission %s is unassigned to %s", MissionName, MissionGroupName ) ) return self end diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index 492c543ec..74eacb8f5 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -168,6 +168,8 @@ do -- TASK_CARGO local Fsm = self:GetUnitProcess() + + Fsm:SetStartState( "Planned" ) Fsm:AddProcess ( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "SelectAction", Rejected = "Reject" } ) From edb53013b259d6e817a1ab7d0210a3b85c219e41 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 6 Jul 2017 21:47:02 +0200 Subject: [PATCH 5/5] Progress --- Moose Development/Moose/Core/Cargo.lua | 3 +- Moose Development/Moose/Tasking/Task.lua | 4 +-- .../Moose/Tasking/Task_CARGO.lua | 35 +++++++------------ .../Moose/Wrapper/Positionable.lua | 6 ++++ 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Moose Development/Moose/Core/Cargo.lua b/Moose Development/Moose/Core/Cargo.lua index d16e55f3c..4da31341a 100644 --- a/Moose Development/Moose/Core/Cargo.lua +++ b/Moose Development/Moose/Core/Cargo.lua @@ -164,7 +164,7 @@ do -- CARGO -- @field #number Weight A number defining the weight of the cargo. The weight is expressed in kg. -- @field #number NearRadius (optional) A number defining the radius in meters when the cargo is near to a Carrier, so that it can be loaded. -- @field Wrapper.Controllable#CONTROLLABLE CargoObject The alive DCS object representing the cargo. This value can be nil, meaning, that the cargo is not represented anywhere... - -- @field Wrapper.Controllable#CONTROLLABLE CargoCarrier The alive DCS object carrying the cargo. This value can be nil, meaning, that the cargo is not contained anywhere... + -- @field Wrapper.Client#CLIENT CargoCarrier The alive DCS object carrying the cargo. This value can be nil, meaning, that the cargo is not contained anywhere... -- @field #boolean Slingloadable This flag defines if the cargo can be slingloaded. -- @field #boolean Moveable This flag defines if the cargo is moveable. -- @field #boolean Representable This flag defines if the cargo can be represented by a DCS Unit. @@ -1032,6 +1032,7 @@ function CARGO_GROUP:OnEventCargoDead( EventData ) else if self.CargoCarrier:GetName() == EventData.IniUnitName then Destroyed = true + self.CargoCarrier:ClearCargo() end end diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 244f8200a..93522f3f0 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -309,7 +309,7 @@ function TASK:AbortGroup( PlayerGroup ) self:E( { IsGroupAssigned = IsGroupAssigned } ) if IsGroupAssigned then local PlayerName = PlayerGroup:GetUnit(1):GetPlayerName() - self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() ) + --self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() ) self:UnAssignFromGroup( PlayerGroup ) --self:Abort() @@ -469,7 +469,7 @@ do -- Group Assignment local TaskGroupName = TaskGroup:GetName() self.AssignedGroups[TaskGroupName] = nil - self:E( string.format( "Task %s is unassigned to %s", TaskName, TaskGroupName ) ) + --self:E( string.format( "Task %s is unassigned to %s", TaskName, TaskGroupName ) ) -- Set the group to be assigned at mission level. This allows to decide the menu options on mission level for this group. self:GetMission():ClearGroupAssignment( TaskGroup ) diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index 74eacb8f5..77b17c4bc 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -316,8 +316,7 @@ do -- TASK_CARGO --#Wrapper.Unit#UNIT - --- Route to Cargo - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task -- @param From @@ -337,8 +336,7 @@ do -- TASK_CARGO - --- - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterArriveAtPickup( TaskUnit, Task ) @@ -346,6 +344,7 @@ do -- TASK_CARGO if self.Cargo:IsAlive() then TaskUnit:Smoke( Task:GetSmokeColor(), 15 ) if TaskUnit:IsAir() then + Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() ) self:__Land( -0.1, "Pickup" ) else self:__SelectAction( -0.1 ) @@ -354,8 +353,7 @@ do -- TASK_CARGO end - --- - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterCancelRouteToPickup( TaskUnit, Task ) @@ -365,8 +363,7 @@ do -- TASK_CARGO end - --- Route to DeployZone - -- @param #FSM_PROCESS self + --- @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() } ) @@ -378,14 +375,14 @@ do -- TASK_CARGO end - --- - -- @param #FSM_PROCESS self + --- @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:IsAir() then + Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() ) self:__Land( -0.1, "Deploy" ) else self:__SelectAction( -0.1 ) @@ -393,8 +390,7 @@ do -- TASK_CARGO end - --- - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterCancelRouteToDeploy( TaskUnit, Task ) @@ -405,7 +401,7 @@ do -- TASK_CARGO - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterLand( TaskUnit, Task, From, Event, To, Action ) @@ -414,7 +410,6 @@ do -- TASK_CARGO if self.Cargo:IsAlive() then if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then if TaskUnit:InAir() then - Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() ) self:__Land( -10, Action ) else Task:GetMission():GetCommandCenter():MessageToGroup( "Landed ...", TaskUnit:GetGroup() ) @@ -430,8 +425,7 @@ do -- TASK_CARGO end end - --- - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterLanded( TaskUnit, Task, From, Event, To, Action ) @@ -454,8 +448,7 @@ do -- TASK_CARGO end end - --- - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterPrepareBoarding( TaskUnit, Task, From, Event, To, Cargo ) @@ -467,8 +460,7 @@ do -- TASK_CARGO end end - --- - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterBoard( TaskUnit, Task ) @@ -494,8 +486,7 @@ do -- TASK_CARGO end - --- - -- @param #FSM_PROCESS self + --- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterBoarded( TaskUnit, Task ) diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index c258ae2de..bca3967cf 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -708,6 +708,12 @@ function POSITIONABLE:HasCargo( Cargo ) return self.__.Cargo[Cargo] end +--- Clear all cargo. +-- @param #POSITIONABLE self +function POSITIONABLE:ClearCargo() + self.__.Cargo = {} +end + --- Get cargo item count. -- @param #POSITIONABLE self -- @return Core.Cargo#CARGO Cargo