Merge pull request #607 from FlightControl-Master/601-Respawn-Cargo

601 respawn cargo
This commit is contained in:
Sven Van de Velde 2017-07-06 21:49:09 +02:00 committed by GitHub
commit b4c8fbf75a
7 changed files with 180 additions and 78 deletions

View File

@ -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 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 #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 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 Slingloadable This flag defines if the cargo can be slingloaded.
-- @field #boolean Moveable This flag defines if the cargo is moveable. -- @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. -- @field #boolean Representable This flag defines if the cargo can be represented by a DCS Unit.
@ -210,8 +210,7 @@ do -- CARGO
-- The state transition method needs to start with the name **OnEnter + the name of the state**. -- 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. -- These state transition methods need to provide a return value, which is specified at the function description.
-- --
-- @field #CARGO CARGO -- @field #CARGO
--
CARGO = { CARGO = {
ClassName = "CARGO", ClassName = "CARGO",
Type = nil, Type = nil,
@ -266,16 +265,25 @@ function CARGO:New( Type, Name, Weight ) --R2.1
self.Moveable = false self.Moveable = false
self.Containable = false self.Containable = false
self:SetDeployed( false )
self.CargoScheduler = SCHEDULER:New() self.CargoScheduler = SCHEDULER:New()
CARGOS[self.Name] = self CARGOS[self.Name] = self
self:SetEventPriority( 5 )
return self return self
end 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. --- Get the name of the Cargo.
-- @param #CARGO self -- @param #CARGO self
-- @return #string The name of the Cargo. -- @return #string The name of the Cargo.
@ -308,6 +316,13 @@ function CARGO:GetCoordinate()
return self.CargoObject:GetCoordinate() return self.CargoObject:GetCoordinate()
end 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. --- Check if cargo is loaded.
-- @param #CARGO self -- @param #CARGO self
@ -335,6 +350,19 @@ function CARGO:IsAlive()
end end
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,9 +514,13 @@ end -- CARGO_REPRESENTABLE
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPORTABLE local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPORTABLE
self:F( { Type, Name, Weight, ReportRadius } ) self:F( { Type, Name, Weight, ReportRadius } )
self.CargoSet = SET_CARGO:New() -- Core.Set#SET_CARGO
self.ReportRadius = ReportRadius or 1000 self.ReportRadius = ReportRadius or 1000
self.CargoObject = CargoObject self.CargoObject = CargoObject
return self return self
end end
@ -517,7 +549,7 @@ end -- CARGO_REPRESENTABLE
end end
--- Send a CC message to a GROUP. --- Send a CC message to a GROUP.
-- @param #COMMANDCENTER self -- @param #CARGO_REPORTABLE self
-- @param #string Message -- @param #string Message
-- @param Wrapper.Group#GROUP TaskGroup -- @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. -- @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,12 +562,38 @@ end -- CARGO_REPRESENTABLE
end end
--- Get the range till cargo will board. --- Get the range till cargo will board.
-- @param #CARGO self -- @param #CARGO_REPORTABLE self
-- @return #number The range till cargo will board. -- @return #number The range till cargo will board.
function CARGO_REPORTABLE:GetBoardingRange() function CARGO_REPORTABLE:GetBoardingRange()
return self.ReportRadius return self.ReportRadius
end end
--- Respawn the cargo.
-- @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
CargoObject:Destroy()
local Template = CargoObject:GetTemplate()
CargoObject:Respawn( Template )
self:SetDeployed( false )
local WeightGroup = 0
self:SetStartState( "UnLoaded" )
end
end end
do -- CARGO_UNIT do -- CARGO_UNIT
@ -575,16 +633,18 @@ function CARGO_UNIT:New( CargoUnit, Type, Name, Weight, NearRadius )
self:T( self.ClassName ) self:T( self.ClassName )
self:HandleEvent( EVENTS.Dead, -- self:HandleEvent( EVENTS.Dead,
--- @param #CARGO Cargo -- --- @param #CARGO Cargo
-- @param Core.Event#EVENTDATA EventData -- -- @param Core.Event#EVENTDATA EventData
function( Cargo, EventData ) -- function( Cargo, EventData )
if Cargo:GetObjectName() == EventData.IniUnit:GetName() then -- if Cargo:GetObjectName() == EventData.IniUnit:GetName() then
self:E( { "Cargo destroyed", Cargo } ) -- self:E( { "Cargo destroyed", Cargo } )
Cargo:Destroyed() -- Cargo:Destroyed()
end -- end
end -- end
) -- )
self:SetEventPriority( 5 )
return self return self
end end
@ -595,6 +655,7 @@ end
function CARGO_UNIT:Destroy() function CARGO_UNIT:Destroy()
-- Cargo objects are deleted from the _DATABASE and SET_CARGO objects. -- Cargo objects are deleted from the _DATABASE and SET_CARGO objects.
self:F( { CargoName = self:GetName() } )
_EVENTDISPATCHER:CreateEventDeleteCargo( self ) _EVENTDISPATCHER:CreateEventDeleteCargo( self )
return self return self
@ -922,10 +983,9 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius )
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( CargoGroup, Type, Name, 0, ReportRadius ) ) -- #CARGO_GROUP local self = BASE:Inherit( self, CARGO_REPORTABLE:New( CargoGroup, Type, Name, 0, ReportRadius ) ) -- #CARGO_GROUP
self:F( { Type, Name, ReportRadius } ) self:F( { Type, Name, ReportRadius } )
self.CargoSet = SET_CARGO:New()
self.CargoObject = CargoGroup self.CargoObject = CargoGroup
self:SetDeployed( false ) self:SetDeployed( false )
self.CargoGroup = CargoGroup
local WeightGroup = 0 local WeightGroup = 0
@ -944,9 +1004,45 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius )
-- Cargo objects are added to the _DATABASE and SET_CARGO objects. -- Cargo objects are added to the _DATABASE and SET_CARGO objects.
_EVENTDISPATCHER:CreateEventNewCargo( self ) _EVENTDISPATCHER:CreateEventNewCargo( self )
self:HandleEvent( EVENTS.Dead, self.OnEventCargoDead )
self:HandleEvent( EVENTS.Crash, self.OnEventCargoDead )
self:HandleEvent( EVENTS.PlayerLeaveUnit, self.OnEventCargoDead )
self:SetEventPriority( 4 )
return self return self
end 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
self.CargoCarrier:ClearCargo()
end
end
if Destroyed then
self:Destroyed()
self:E( { "Cargo group destroyed" } )
end
end
--- Enter Boarding State. --- Enter Boarding State.
-- @param #CARGO_GROUP self -- @param #CARGO_GROUP self
-- @param Wrapper.Unit#UNIT CargoCarrier -- @param Wrapper.Unit#UNIT CargoCarrier
@ -988,7 +1084,7 @@ function CARGO_GROUP:onenterLoaded( From, Event, To, CargoCarrier, ... )
end end
end end
self.CargoObject:Destroy() --self.CargoObject:Destroy()
self.CargoCarrier = CargoCarrier self.CargoCarrier = CargoCarrier
end end
@ -1051,19 +1147,6 @@ function CARGO_GROUP:GetCount()
return self.CargoSet:Count() return self.CargoSet:Count()
end 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. --- Enter UnBoarding State.
-- @param #CARGO_GROUP self -- @param #CARGO_GROUP self
@ -1170,6 +1253,23 @@ function CARGO_GROUP:onenterUnLoaded( From, Event, To, ToPointVec2, ... )
end 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 end -- CARGO_GROUP
do -- CARGO_PACKAGE do -- CARGO_PACKAGE

View File

@ -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. --- (R2.1) Creates a new SET_CARGO object, building a set of cargos belonging to a coalitions and categories.
-- @param #SET_CARGO self -- @param #SET_CARGO self
-- @return #SET_CARGO self -- @return #SET_CARGO
-- @usage -- @usage
-- -- Define a new SET_CARGO Object. The DatabaseSet will contain a reference to all Cargos. -- -- Define a new SET_CARGO Object. The DatabaseSet will contain a reference to all Cargos.
-- DatabaseSet = SET_CARGO:New() -- DatabaseSet = SET_CARGO:New()
function SET_CARGO:New() --R2.1 function SET_CARGO:New() --R2.1
-- Inherits from BASE -- 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 return self
end end

View File

@ -450,7 +450,7 @@ do -- Group Assignment
local MissionGroupName = MissionGroup:GetName() local MissionGroupName = MissionGroup:GetName()
self.AssignedGroups[MissionGroupName] = nil 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 return self
end end

View File

@ -309,7 +309,7 @@ function TASK:AbortGroup( PlayerGroup )
self:E( { IsGroupAssigned = IsGroupAssigned } ) self:E( { IsGroupAssigned = IsGroupAssigned } )
if IsGroupAssigned then if IsGroupAssigned then
local PlayerName = PlayerGroup:GetUnit(1):GetPlayerName() local PlayerName = PlayerGroup:GetUnit(1):GetPlayerName()
self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() ) --self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() )
self:UnAssignFromGroup( PlayerGroup ) self:UnAssignFromGroup( PlayerGroup )
--self:Abort() --self:Abort()
@ -469,7 +469,7 @@ do -- Group Assignment
local TaskGroupName = TaskGroup:GetName() local TaskGroupName = TaskGroup:GetName()
self.AssignedGroups[TaskGroupName] = nil 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. -- 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 ) self:GetMission():ClearGroupAssignment( TaskGroup )

View File

@ -169,6 +169,8 @@ do -- TASK_CARGO
local Fsm = self:GetUnitProcess() local Fsm = self:GetUnitProcess()
Fsm:SetStartState( "Planned" )
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( { "Assigned", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Landed", "Boarding" }, "SelectAction", "*" ) Fsm:AddTransition( { "Assigned", "WaitingForCommand", "ArrivedAtPickup", "ArrivedAtDeploy", "Boarded", "UnBoarded", "Landed", "Boarding" }, "SelectAction", "*" )
@ -314,8 +316,7 @@ do -- TASK_CARGO
--#Wrapper.Unit#UNIT --#Wrapper.Unit#UNIT
--- Route to 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
-- @param From -- @param From
@ -335,8 +336,7 @@ 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:onafterArriveAtPickup( TaskUnit, Task ) function Fsm:onafterArriveAtPickup( TaskUnit, Task )
@ -344,6 +344,7 @@ do -- TASK_CARGO
if self.Cargo:IsAlive() then if self.Cargo:IsAlive() then
TaskUnit:Smoke( Task:GetSmokeColor(), 15 ) TaskUnit:Smoke( Task:GetSmokeColor(), 15 )
if TaskUnit:IsAir() then if TaskUnit:IsAir() then
Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() )
self:__Land( -0.1, "Pickup" ) self:__Land( -0.1, "Pickup" )
else else
self:__SelectAction( -0.1 ) self:__SelectAction( -0.1 )
@ -352,8 +353,7 @@ do -- TASK_CARGO
end end
--- --- @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:onafterCancelRouteToPickup( TaskUnit, Task ) function Fsm:onafterCancelRouteToPickup( TaskUnit, Task )
@ -363,8 +363,7 @@ do -- TASK_CARGO
end end
--- Route to DeployZone --- @param #FSM_PROCESS self
-- @param #FSM_PROCESS self
-- @param Wrapper.Unit#UNIT TaskUnit -- @param Wrapper.Unit#UNIT TaskUnit
function Fsm:onafterRouteToDeploy( TaskUnit, Task, From, Event, To, DeployZone ) function Fsm:onafterRouteToDeploy( TaskUnit, Task, From, Event, To, DeployZone )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
@ -376,14 +375,14 @@ do -- TASK_CARGO
end end
--- --- @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:onafterArriveAtDeploy( TaskUnit, Task ) function Fsm:onafterArriveAtDeploy( TaskUnit, Task )
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
if TaskUnit:IsAir() then if TaskUnit:IsAir() then
Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() )
self:__Land( -0.1, "Deploy" ) self:__Land( -0.1, "Deploy" )
else else
self:__SelectAction( -0.1 ) self:__SelectAction( -0.1 )
@ -391,8 +390,7 @@ do -- TASK_CARGO
end end
--- --- @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:onafterCancelRouteToDeploy( TaskUnit, Task ) function Fsm:onafterCancelRouteToDeploy( TaskUnit, Task )
@ -403,7 +401,7 @@ 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:onafterLand( TaskUnit, Task, From, Event, To, Action ) function Fsm:onafterLand( TaskUnit, Task, From, Event, To, Action )
@ -412,7 +410,6 @@ do -- TASK_CARGO
if self.Cargo:IsAlive() then if self.Cargo:IsAlive() then
if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then if self.Cargo:IsInRadius( TaskUnit:GetPointVec2() ) then
if TaskUnit:InAir() then if TaskUnit:InAir() then
Task:GetMission():GetCommandCenter():MessageToGroup( "Land", TaskUnit:GetGroup() )
self:__Land( -10, Action ) self:__Land( -10, Action )
else else
Task:GetMission():GetCommandCenter():MessageToGroup( "Landed ...", TaskUnit:GetGroup() ) Task:GetMission():GetCommandCenter():MessageToGroup( "Landed ...", TaskUnit:GetGroup() )
@ -428,8 +425,7 @@ do -- TASK_CARGO
end end
end end
--- --- @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:onafterLanded( TaskUnit, Task, From, Event, To, Action ) function Fsm:onafterLanded( TaskUnit, Task, From, Event, To, Action )
@ -452,8 +448,7 @@ do -- TASK_CARGO
end end
end end
--- --- @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:onafterPrepareBoarding( TaskUnit, Task, From, Event, To, Cargo ) function Fsm:onafterPrepareBoarding( TaskUnit, Task, From, Event, To, Cargo )
@ -465,8 +460,7 @@ do -- TASK_CARGO
end end
end end
--- --- @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 )
@ -492,8 +486,7 @@ do -- TASK_CARGO
end end
--- --- @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 )

View File

@ -869,6 +869,7 @@ end
-- @param #table Template The template of the Group retrieved with GROUP:GetTemplate() -- @param #table Template The template of the Group retrieved with GROUP:GetTemplate()
function GROUP:Respawn( Template ) function GROUP:Respawn( Template )
if self:IsAlive() then
local Vec3 = self:GetVec3() local Vec3 = self:GetVec3()
Template.x = Vec3.x Template.x = Vec3.x
Template.y = Vec3.z Template.y = Vec3.z
@ -890,6 +891,8 @@ function GROUP:Respawn( Template )
end end
end end
end
self:Destroy() self:Destroy()
_DATABASE:Spawn( Template ) _DATABASE:Spawn( Template )

View File

@ -708,6 +708,12 @@ function POSITIONABLE:HasCargo( Cargo )
return self.__.Cargo[Cargo] return self.__.Cargo[Cargo]
end end
--- Clear all cargo.
-- @param #POSITIONABLE self
function POSITIONABLE:ClearCargo()
self.__.Cargo = {}
end
--- Get cargo item count. --- Get cargo item count.
-- @param #POSITIONABLE self -- @param #POSITIONABLE self
-- @return Core.Cargo#CARGO Cargo -- @return Core.Cargo#CARGO Cargo