Converted SPAWN:FromCarrier function

SPAWN:FromCarrier now spawns from a Unit instead of a Group. It was
confusing from the beginning anyway :-)
This commit is contained in:
svenvandevelde 2016-02-19 19:00:40 +01:00
parent d197e87fb5
commit b8148a7950
2 changed files with 53 additions and 64 deletions

View File

@ -249,12 +249,12 @@ trace.f( self.ClassName )
end
function CARGO_ZONE:GetCargoHostGroup()
function CARGO_ZONE:GetCargoHostUnit()
trace.f( self.ClassName )
local CargoHostGroup = Group.getByName( self.CargoHostSpawn:SpawnGroupName() )
if CargoHostGroup and CargoHostGroup:isExist() then
return CargoHostGroup
local CargoHostUnit = Group.getByName( self.CargoHostSpawn:SpawnGroupName() ):getUnit(1)
if CargoHostUnit and CargoHostUnit:isExist() then
return CargoHostUnit
end
return nil
@ -462,9 +462,9 @@ trace.f( self.ClassName )
end
if SpawnCargo then
if self.CargoZone:GetCargoHostGroup() then
if self.CargoZone:GetCargoHostUnit() then
--- ReSpawn the Cargo from the CargoHost
self.CargoGroupName = self.CargoSpawn:FromCarrier( self.CargoZone:GetCargoHostGroup(), self.CargoZone:GetCargoZoneName(), self.CargoName, false ).name
self.CargoGroupName = self.CargoSpawn:FromCarrier( self.CargoZone:GetCargoHostUnit(), self.CargoZone:GetCargoZoneName(), self.CargoName, false ).name
else
--- ReSpawn the Cargo in the CargoZone without a host ...
self.CargoGroupName = self.CargoSpawn:InZone( self.CargoZone:GetCargoZoneName(), self.CargoName ).name
@ -589,7 +589,7 @@ trace.f( self.ClassName )
trace.i( self.ClassName, 'self.CargoName = ' .. self.CargoName )
trace.i( self.ClassName, 'self.CargoGroupName = ' .. self.CargoGroupName )
self.CargoSpawn:FromCarrier( Client:ClientGroup(), TargetZoneName, self.CargoGroupName )
self.CargoSpawn:FromCarrier( Client:GetClientGroupUnit(), TargetZoneName, self.CargoGroupName )
self:StatusUnLoaded()
local Cargo = Client:RemoveCargo( self )

View File

@ -298,25 +298,16 @@ end
--- Will SPAWN a Group from a Carrier. This function is mostly advisable to be used if you want to simulate SPAWNing from air units, like helicopters, which are dropping infantry into a defined Landing Zone.
-- @tparam Group CarrierGroup is the Group of the AIR unit or GROUND unit dropping or unloading other units.
-- @tparam Group CarrierUnit is the AIR unit or GROUND unit dropping or unloading the Spawn group.
-- @tparam string TargetZonePrefix is the Prefix of the Zone defined in the ME where the Group should be moving to after drop.
-- @tparam string NewGroupName (forgot this).
-- @tparam bool LateActivate (optional) does the SPAWNing with Lateactivation on.
function SPAWN:FromCarrier( CarrierGroup, TargetZonePrefix, NewGroupName, LateActivate )
trace.f( self.ClassName, { CarrierGroup, TargetZonePrefix, NewGroupName, LateActivate } )
function SPAWN:FromCarrier( CarrierUnit, TargetZonePrefix, NewGroupName, LateActivate )
trace.f( self.ClassName, { CarrierUnit, TargetZonePrefix, NewGroupName, LateActivate } )
local SpawnTemplate
if CarrierGroup and CarrierGroup:isExist() and CarrierGroup:getUnit(1) then -- and CarrierGroup:getUnit(1):inAir() == false then
local GroupUnits = CarrierGroup:getUnits()
local GroupUnitCount = table.getn(GroupUnits)
trace.i( self.ClassName, "CarrierGroup:getSize() = " .. CarrierGroup:getSize() )
trace.i( self.ClassName, 'GroupUnitCount = ' .. GroupUnitCount )
for UnitId, UnitData in pairs(GroupUnits) do
UnitDeploy = UnitData
if CarrierUnit and CarrierUnit:isExist() then -- and CarrierUnit:getUnit(1):inAir() == false then
SpawnTemplate = self:_Prepare( NewGroupName )
@ -340,7 +331,7 @@ trace.f( self.ClassName, { CarrierGroup, TargetZonePrefix, NewGroupName, LateAct
local RouteCount = table.getn( SpawnTemplate.route.points )
trace.i( self.ClassName, "RouteCount = " .. RouteCount )
local UnitDeployPosition = UnitDeploy:getPoint()
local UnitDeployPosition = CarrierUnit:getPoint()
SpawnTemplate.route.points[1].x = UnitDeployPosition.x - 50
SpawnTemplate.route.points[1].y = UnitDeployPosition.z
SpawnTemplate.route.points[1].alt = nil
@ -368,8 +359,6 @@ trace.f( self.ClassName, { CarrierGroup, TargetZonePrefix, NewGroupName, LateAct
end
end
end
trace.r( self.ClassName, "" )
return SpawnTemplate