Optimizations of cargo deployment.

This commit is contained in:
FlightControl_Master 2018-03-28 16:42:37 +02:00
parent ea069455d3
commit 7a8881974c
2 changed files with 19 additions and 18 deletions

View File

@ -148,7 +148,7 @@ function AI_CARGO_TROOPS:onafterLoad( CargoCarrier, From, Event, To )
if CargoCarrier and CargoCarrier:IsAlive() then
CargoCarrier:RouteStop()
self:Board()
self:__Board( 10 )
self.CargoGroup:Board( CargoCarrier, 25 )
end
@ -162,7 +162,7 @@ function AI_CARGO_TROOPS:onafterBoard( CargoCarrier, From, Event, To )
if CargoCarrier and CargoCarrier:IsAlive() then
self:F({ IsLoaded = self.CargoGroup:IsLoaded() } )
if not self.CargoGroup:IsLoaded() then
self:__Board( 1 )
self:__Board( 10 )
else
self:__Loaded( 1 )
end
@ -190,7 +190,7 @@ function AI_CARGO_TROOPS:onafterUnload( CargoCarrier, From, Event, To )
if CargoCarrier and CargoCarrier:IsAlive() then
CargoCarrier:RouteStop()
self.CargoGroup:UnBoard( )
self:__Unboard( 1 )
self:__Unboard( 10 )
end
end
@ -202,9 +202,9 @@ function AI_CARGO_TROOPS:onafterUnboard( CargoCarrier, From, Event, To )
if CargoCarrier and CargoCarrier:IsAlive() then
if not self.CargoGroup:IsUnLoaded() then
self:__Unboard( 1 )
self:__Unboard( 10 )
else
self:Unloaded()
self:__Unloaded( 1 )
end
end

View File

@ -771,25 +771,26 @@ do -- CARGO_UNIT
-- if there is no ToPointVec2 given, then use the CargoRoutePointVec2
ToPointVec2 = ToPointVec2 or CargoCarrierPointVec2:GetRandomCoordinateInRadius( NearRadius, 5 )
local DirectionVec3 = CargoCarrierPointVec2:GetDirectionVec3(ToPointVec2)
local Angle = CargoCarrierPointVec2:GetAngleDegrees(DirectionVec3)
local CargoDeployPointVec2 = CargoCarrierPointVec2:Translate( DeployDistance, Angle )
local CargoDeployPointVec2 = CargoCarrierPointVec2:GetRandomCoordinateInRadius( NearRadius, 5 )
local FromDirectionVec3 = CargoCarrierPointVec2:GetDirectionVec3( ToPointVec2 or CargoRoutePointVec2 )
local FromAngle = CargoCarrierPointVec2:GetAngleDegrees(FromDirectionVec3)
local FromPointVec2 = CargoCarrierPointVec2:Translate( DeployDistance, FromAngle )
--local CargoDeployPointVec2 = CargoCarrierPointVec2:GetRandomCoordinateInRadius( 10, 5 )
ToPointVec2 = ToPointVec2 or CargoCarrierPointVec2:GetRandomCoordinateInRadius( NearRadius, DeployDistance )
local FromPointVec2 = CargoCarrierPointVec2
-- Respawn the group...
if self.CargoObject then
self.CargoObject:ReSpawn( CargoDeployPointVec2:GetVec3(), CargoDeployHeading )
self.CargoObject:ReSpawn( FromPointVec2:GetVec3(), CargoDeployHeading )
self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
self.CargoCarrier = nil
local Points = {}
Points[#Points+1] = CargoCarrierPointVec2:WaypointGround( Speed )
Points[#Points+1] = ToPointVec2:WaypointGround( Speed )
-- From
Points[#Points+1] = FromPointVec2:WaypointGround( Speed, "Vee" )
-- To
Points[#Points+1] = ToPointVec2:WaypointGround( Speed, "Vee" )
local TaskRoute = self.CargoObject:TaskRoute( Points )
self.CargoObject:SetTask( TaskRoute, 1 )
@ -1375,7 +1376,7 @@ function CARGO_GROUP:OnEventCargoDead( EventData )
function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius, ... )
self:F( {From, Event, To, ToPointVec2, NearRadius } )
NearRadius = NearRadius or 100
NearRadius = NearRadius or 25
local Timer = 1
@ -1390,7 +1391,7 @@ function CARGO_GROUP:OnEventCargoDead( EventData )
function( Cargo, NearRadius )
Cargo:__UnBoard( Timer, ToPointVec2, NearRadius )
Timer = Timer + 10
Timer = Timer + 3
end, { NearRadius }
)