mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
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.
This commit is contained in:
parent
71da9933d7
commit
532a311db6
@ -581,6 +581,7 @@ end -- CARGO_REPRESENTABLE
|
|||||||
end
|
end
|
||||||
|
|
||||||
local CargoObject = self.CargoObject -- Wrapper.Group#GROUP
|
local CargoObject = self.CargoObject -- Wrapper.Group#GROUP
|
||||||
|
CargoObject:Destroy()
|
||||||
local Template = CargoObject:GetTemplate()
|
local Template = CargoObject:GetTemplate()
|
||||||
CargoObject:Respawn( Template )
|
CargoObject:Respawn( Template )
|
||||||
|
|
||||||
@ -632,16 +633,16 @@ 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 )
|
self:SetEventPriority( 5 )
|
||||||
|
|
||||||
@ -984,6 +985,7 @@ function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius )
|
|||||||
|
|
||||||
self.CargoObject = CargoGroup
|
self.CargoObject = CargoGroup
|
||||||
self:SetDeployed( false )
|
self:SetDeployed( false )
|
||||||
|
self.CargoGroup = CargoGroup
|
||||||
|
|
||||||
local WeightGroup = 0
|
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.
|
-- Cargo objects are added to the _DATABASE and SET_CARGO objects.
|
||||||
_EVENTDISPATCHER:CreateEventNewCargo( self )
|
_EVENTDISPATCHER:CreateEventNewCargo( self )
|
||||||
|
|
||||||
self:HandleEvent( EVENTS.Dead,
|
self:HandleEvent( EVENTS.Dead, self.OnEventCargoDead )
|
||||||
--- @param #CARGO Cargo
|
self:HandleEvent( EVENTS.Crash, self.OnEventCargoDead )
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
self:HandleEvent( EVENTS.PlayerLeaveUnit, self.OnEventCargoDead )
|
||||||
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 )
|
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
|
||||||
|
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
|
||||||
@ -1070,7 +1083,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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user