mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
-- Fixed a lot of issues with cargo when the cargo representative is destroyed.
This commit is contained in:
parent
b1a1c6c552
commit
7a579a0ab5
@ -126,7 +126,7 @@ function AI_CARGO_TROOPS:onafterMonitor( CargoCarrier, From, Event, To )
|
|||||||
local Coordinate = CargoCarrier:GetCoordinate()
|
local Coordinate = CargoCarrier:GetCoordinate()
|
||||||
self.Zone:Scan( { Object.Category.UNIT } )
|
self.Zone:Scan( { Object.Category.UNIT } )
|
||||||
if self.Zone:IsAllInZoneOfCoalition( self.Coalition ) then
|
if self.Zone:IsAllInZoneOfCoalition( self.Coalition ) then
|
||||||
if self:Is( "Unloaded" ) or self:Is( "Guarding" ) then
|
if self:Is( "Unloaded" ) or self:Is( "Guarding" ) or self:Is( "Following" ) then
|
||||||
-- There are no enemies within combat range. Load the CargoCarrier.
|
-- There are no enemies within combat range. Load the CargoCarrier.
|
||||||
self:__Load( 1 )
|
self:__Load( 1 )
|
||||||
end
|
end
|
||||||
@ -158,7 +158,7 @@ function AI_CARGO_TROOPS:onafterLoad( CargoCarrier, From, Event, To )
|
|||||||
if CargoCarrier and CargoCarrier:IsAlive() then
|
if CargoCarrier and CargoCarrier:IsAlive() then
|
||||||
CargoCarrier:RouteStop()
|
CargoCarrier:RouteStop()
|
||||||
self:Board()
|
self:Board()
|
||||||
self.CargoGroup:Board( CargoCarrier, 5 )
|
self.CargoGroup:Board( CargoCarrier, 25 )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -760,6 +760,8 @@ do -- CARGO_UNIT
|
|||||||
|
|
||||||
if From == "Loaded" then
|
if From == "Loaded" then
|
||||||
|
|
||||||
|
if not self:IsDestroyed() then
|
||||||
|
|
||||||
local CargoCarrier = self.CargoCarrier -- Wrapper.Controllable#CONTROLLABLE
|
local CargoCarrier = self.CargoCarrier -- Wrapper.Controllable#CONTROLLABLE
|
||||||
|
|
||||||
local CargoCarrierPointVec2 = CargoCarrier:GetPointVec2()
|
local CargoCarrierPointVec2 = CargoCarrier:GetPointVec2()
|
||||||
@ -797,6 +799,7 @@ do -- CARGO_UNIT
|
|||||||
self:__UnBoarding( 1, ToPointVec2, NearRadius )
|
self:__UnBoarding( 1, ToPointVec2, NearRadius )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -949,7 +952,7 @@ do -- CARGO_UNIT
|
|||||||
self:F( { From, Event, To, CargoCarrier.UnitName, NearRadius } )
|
self:F( { From, Event, To, CargoCarrier.UnitName, NearRadius } )
|
||||||
|
|
||||||
|
|
||||||
if CargoCarrier and CargoCarrier:IsAlive() then
|
if CargoCarrier and CargoCarrier:IsAlive() and self.CargoObject and self.CargoObject:IsAlive() then
|
||||||
if CargoCarrier:InAir() == false then
|
if CargoCarrier:InAir() == false then
|
||||||
if self:IsNear( CargoCarrier:GetPointVec2(), NearRadius ) then
|
if self:IsNear( CargoCarrier:GetPointVec2(), NearRadius ) then
|
||||||
self:__Load( 1, CargoCarrier, ... )
|
self:__Load( 1, CargoCarrier, ... )
|
||||||
@ -1200,9 +1203,11 @@ do -- CARGO_GROUP
|
|||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function CARGO_GROUP:OnEventCargoDead( EventData )
|
function CARGO_GROUP:OnEventCargoDead( EventData )
|
||||||
|
|
||||||
|
self:_F( { "Dead Event", EventData = EventData } )
|
||||||
|
|
||||||
local Destroyed = false
|
local Destroyed = false
|
||||||
|
|
||||||
if self:IsDestroyed() or self:IsUnLoaded() then
|
if self:IsDestroyed() or self:IsUnLoaded() or self:IsBoarding() then
|
||||||
Destroyed = true
|
Destroyed = true
|
||||||
for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do
|
for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do
|
||||||
local Cargo = CargoData -- #CARGO
|
local Cargo = CargoData -- #CARGO
|
||||||
@ -1392,7 +1397,7 @@ do -- CARGO_GROUP
|
|||||||
-- For each Cargo object within the CARGO_GROUP, route each object to the CargoLoadPointVec2
|
-- For each Cargo object within the CARGO_GROUP, route each object to the CargoLoadPointVec2
|
||||||
for CargoID, Cargo in pairs( self.CargoSet:GetSet() ) do
|
for CargoID, Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||||
self:T( Cargo.current )
|
self:T( Cargo.current )
|
||||||
if not Cargo:is( "UnLoaded" ) then
|
if not Cargo:is( "UnLoaded" ) and not Cargo:IsDestroyed() then
|
||||||
UnBoarded = false
|
UnBoarded = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user