mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Cargo Troops
This commit is contained in:
parent
e7518d69e6
commit
b6fc46fdd0
@ -36,15 +36,16 @@ function AI_CARGO_TROOPS:New( CargoCarrier, CargoGroup, CombatRadius )
|
|||||||
self.Zone = ZONE_UNIT:New( self.CargoCarrier:GetName() .. "-Zone", self.CargoCarrier, CombatRadius )
|
self.Zone = ZONE_UNIT:New( self.CargoCarrier:GetName() .. "-Zone", self.CargoCarrier, CombatRadius )
|
||||||
self.Coalition = self.CargoCarrier:GetCoalition()
|
self.Coalition = self.CargoCarrier:GetCoalition()
|
||||||
|
|
||||||
self:SetControllable( self.CargoCarrier )
|
self:SetControllable( CargoCarrier )
|
||||||
|
|
||||||
self:SetStartState( "UnLoaded" )
|
self:SetStartState( "UnLoaded" )
|
||||||
|
|
||||||
self:AddTransition( "*", "Load", "Boarding" )
|
self:AddTransition( "*", "Load", "Boarding" )
|
||||||
self:AddTransition( "Boarding", "Boarding", "Boarding" )
|
self:AddTransition( "Boarding", "Board", "Boarding" )
|
||||||
self:AddTransition( "Boarding", "Loaded", "Loaded" )
|
self:AddTransition( "Boarding", "Loaded", "Loaded" )
|
||||||
self:AddTransition( "Loaded", "Unload", "Unboarding" )
|
self:AddTransition( "Loaded", "Unload", "Unboarding" )
|
||||||
self:AddTransition( "UnBoarding", "Unloaded", "Unloaded" )
|
self:AddTransition( "Unboarding", "Unboard", "Unboarding" )
|
||||||
|
self:AddTransition( "Unboarding", "Unloaded", "Unloaded" )
|
||||||
|
|
||||||
self:AddTransition( "*", "Monitor", "*" )
|
self:AddTransition( "*", "Monitor", "*" )
|
||||||
|
|
||||||
@ -63,17 +64,24 @@ function AI_CARGO_TROOPS:onafterMonitor( CargoCarrier, From, Event, To )
|
|||||||
if CargoCarrier and CargoCarrier:IsAlive() then
|
if CargoCarrier and CargoCarrier:IsAlive() then
|
||||||
if self.Coordinate then
|
if self.Coordinate then
|
||||||
local Coordinate = CargoCarrier:GetCoordinate()
|
local Coordinate = CargoCarrier:GetCoordinate()
|
||||||
if Coordinate:IsAtCoordinate2D( self.Coordinate, 2 ) then
|
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" ) then
|
||||||
else
|
-- -- There are no enemies within combat range. Load the CargoCarrier.
|
||||||
if not self:Is( "Unloaded" ) then
|
-- self:__Load( 1 )
|
||||||
-- There are enemies within combat range. Unload the CargoCarrier.
|
-- end
|
||||||
self:__Unload( 1 )
|
else
|
||||||
self.CargoCarrier:RouteStop()
|
if self:Is( "Loaded" ) then
|
||||||
end
|
-- There are enemies within combat range. Unload the CargoCarrier.
|
||||||
|
self:__Unload( 1 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if self:Is( "Unloaded" ) then
|
||||||
|
if not Coordinate:IsAtCoordinate2D( self.Coordinate, 2 ) then
|
||||||
|
--self.CargoGroup:RouteTo( Coordinate, 30 )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
self.Coordinate = CargoCarrier:GetCoordinate()
|
self.Coordinate = CargoCarrier:GetCoordinate()
|
||||||
end
|
end
|
||||||
@ -90,23 +98,23 @@ function AI_CARGO_TROOPS:onafterLoad( CargoCarrier, From, Event, To )
|
|||||||
self:F( { CargoCarrier, From, Event, To } )
|
self:F( { CargoCarrier, From, Event, To } )
|
||||||
|
|
||||||
if CargoCarrier and CargoCarrier:IsAlive() then
|
if CargoCarrier and CargoCarrier:IsAlive() then
|
||||||
self.CargoGroup:__Board( 1, CargoCarrier, 100 )
|
CargoCarrier:RouteStop()
|
||||||
self:__Boarding( 1 )
|
self:Board()
|
||||||
|
self.CargoGroup:Board( CargoCarrier, 100 )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_CARGO_TROOPS self
|
--- @param #AI_CARGO_TROOPS self
|
||||||
-- @param Wrapper.Unit#UNIT CargoCarrier
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
function AI_CARGO_TROOPS:onafterBoarding( CargoCarrier, From, Event, To )
|
function AI_CARGO_TROOPS:onafterBoard( CargoCarrier, From, Event, To )
|
||||||
self:F( { CargoCarrier, From, Event, To } )
|
self:F( { CargoCarrier, From, Event, To } )
|
||||||
|
|
||||||
if CargoCarrier and CargoCarrier:IsAlive() then
|
if CargoCarrier and CargoCarrier:IsAlive() then
|
||||||
if self.CargoGroup:IsBoarding() then
|
self:F({ IsLoaded = self.CargoGroup:IsLoaded() } )
|
||||||
self:__Boarding( 1 )
|
if not self.CargoGroup:IsLoaded() then
|
||||||
end
|
self:__Board( 1 )
|
||||||
|
else
|
||||||
if self.CargoGroup:IsLoaded() then
|
|
||||||
self:__Loaded( 1 )
|
self:__Loaded( 1 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -119,8 +127,47 @@ function AI_CARGO_TROOPS:onafterLoaded( CargoCarrier, From, Event, To )
|
|||||||
self:F( { CargoCarrier, From, Event, To } )
|
self:F( { CargoCarrier, From, Event, To } )
|
||||||
|
|
||||||
if CargoCarrier and CargoCarrier:IsAlive() then
|
if CargoCarrier and CargoCarrier:IsAlive() then
|
||||||
CargoCarrier:RouteStop()
|
CargoCarrier:RouteResume()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- @param #AI_CARGO_TROOPS self
|
||||||
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
function AI_CARGO_TROOPS:onafterUnload( CargoCarrier, From, Event, To )
|
||||||
|
self:F( { CargoCarrier, From, Event, To } )
|
||||||
|
|
||||||
|
if CargoCarrier and CargoCarrier:IsAlive() then
|
||||||
|
CargoCarrier:RouteStop()
|
||||||
|
self.CargoGroup:UnBoard( )
|
||||||
|
self:__Unboard( 1 )
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @param #AI_CARGO_TROOPS self
|
||||||
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
function AI_CARGO_TROOPS:onafterUnboard( CargoCarrier, From, Event, To )
|
||||||
|
self:F( { CargoCarrier, From, Event, To } )
|
||||||
|
|
||||||
|
if CargoCarrier and CargoCarrier:IsAlive() then
|
||||||
|
if not self.CargoGroup:IsUnLoaded() then
|
||||||
|
self:__Unboard( 1 )
|
||||||
|
else
|
||||||
|
self:Unloaded()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @param #AI_CARGO_TROOPS self
|
||||||
|
-- @param Wrapper.Unit#UNIT CargoCarrier
|
||||||
|
function AI_CARGO_TROOPS:onafterUnloaded( CargoCarrier, From, Event, To )
|
||||||
|
self:F( { CargoCarrier, From, Event, To } )
|
||||||
|
|
||||||
|
if CargoCarrier and CargoCarrier:IsAlive() then
|
||||||
|
CargoCarrier:RouteResume()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|||||||
@ -1312,6 +1312,7 @@ function CARGO_GROUP:onafterBoarding( From, Event, To, CargoCarrier, NearRadius,
|
|||||||
if not Boarded then
|
if not Boarded then
|
||||||
self:__Boarding( 1, CargoCarrier, NearRadius, ... )
|
self:__Boarding( 1, CargoCarrier, NearRadius, ... )
|
||||||
else
|
else
|
||||||
|
self:F("Group Cargo is loaded")
|
||||||
self:__Load( 1, CargoCarrier, ... )
|
self:__Load( 1, CargoCarrier, ... )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1459,6 +1460,27 @@ end
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Route Cargo to Coordinate and randomize locations.
|
||||||
|
-- @param #CARGO_GROUP self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate
|
||||||
|
function CARGO_GROUP:RouteTo( Coordinate )
|
||||||
|
self:F( )
|
||||||
|
|
||||||
|
--local NearRadius = NearRadius or 25
|
||||||
|
|
||||||
|
if From == "UnLoaded" then
|
||||||
|
|
||||||
|
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
|
||||||
|
self.CargoSet:ForEach(
|
||||||
|
function( Cargo, Coordinate )
|
||||||
|
Cargo.CargoObject:RouteTo( Coordinate )
|
||||||
|
end, Coordinate
|
||||||
|
)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end -- CARGO_GROUP
|
end -- CARGO_GROUP
|
||||||
|
|
||||||
do -- CARGO_PACKAGE
|
do -- CARGO_PACKAGE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user