mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Further progress, package pickup is now working...
This commit is contained in:
parent
7e098b050e
commit
2f7e3ffb76
@ -231,7 +231,8 @@ CARGO = {
|
|||||||
LOADED = 1,
|
LOADED = 1,
|
||||||
UNLOADED = 2,
|
UNLOADED = 2,
|
||||||
LOADING = 3
|
LOADING = 3
|
||||||
}
|
},
|
||||||
|
CargoCarrierGroupName = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Add Cargo to the mission... Cargo functionality needs to be reworked a bit, so this is still under construction. I need to make a CARGO Class...
|
--- Add Cargo to the mission... Cargo functionality needs to be reworked a bit, so this is still under construction. I need to make a CARGO Class...
|
||||||
@ -549,12 +550,14 @@ CARGO_PACKAGE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function CARGO_PACKAGE:New( CargoType, CargoName, CargoWeight )
|
function CARGO_PACKAGE:New( CargoType, CargoName, CargoWeight, InitClientGroupName )
|
||||||
trace.f( self.ClassName, { CargoType, CargoName, CargoWeight } )
|
trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, InitClientGroupName } )
|
||||||
|
|
||||||
-- Arrange meta tables
|
-- Arrange meta tables
|
||||||
local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
|
local self = BASE:Inherit( self, CARGO:New( CargoType, CargoName, CargoWeight ) )
|
||||||
|
|
||||||
|
self.InitClientGroupName = InitClientGroupName .. '#' -- to fix
|
||||||
|
|
||||||
CARGOS[self.CargoName] = self
|
CARGOS[self.CargoName] = self
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -564,6 +567,32 @@ end
|
|||||||
function CARGO_PACKAGE:Spawn()
|
function CARGO_PACKAGE:Spawn()
|
||||||
trace.f( self.ClassName )
|
trace.f( self.ClassName )
|
||||||
|
|
||||||
|
-- this needs to be checked thoroughly
|
||||||
|
|
||||||
|
|
||||||
|
local SpawnCargo = true
|
||||||
|
|
||||||
|
if self.Client and self.Client:ClientGroup() then
|
||||||
|
trace.i( self.ClassName, 'There is a Client ' .. self.Client.ClientName )
|
||||||
|
if self.Client:FindCargo( self.CargoName ) then
|
||||||
|
if self.Client:ClientUnit():getPlayerName() then -- this needs to be checked thoroughly
|
||||||
|
trace.i( self.ClassName, 'ok, Client is of player ' .. self.Client:ClientUnit():getPlayerName() .. ' and contains the Cargo, do nothing' )
|
||||||
|
SpawnCargo = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if self.InitClientGroupName then
|
||||||
|
local ClientGroup = Group.getByName( self.InitClientGroupName )
|
||||||
|
if ClientGroup and ClientGroup:isExist() then
|
||||||
|
self.Client = CLIENT:New( self.InitClientGroupName, '' )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if SpawnCargo then
|
||||||
|
self.Client:AddCargo( self ) -- Adding cargo to the AI client
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -572,10 +601,20 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
local Near = false
|
local Near = false
|
||||||
|
|
||||||
local CargoHostGroup = LandingZone:GetCargoHostGroup()
|
trace.i( self.ClassName, self.Client.ClientName )
|
||||||
if routines.IsPartOfGroupInRadius( CargoHostGroup, Client:ClientPosition(), 150 ) then
|
if self.Client and self.Client:ClientGroup():getName() then
|
||||||
|
trace.i( self.ClassName, 'Client Exists.' )
|
||||||
|
trace.i( self.ClassName, 'self.Client:ClientGroup():getName() = ' .. self.Client:ClientGroup():getName() )
|
||||||
|
|
||||||
|
-- Find the cargo in the client
|
||||||
|
local Cargo = self.Client:FindCargo( self.CargoName )
|
||||||
|
if Cargo == self then
|
||||||
|
trace.i( self.ClassName, 'Cargo is loaded in Client.' )
|
||||||
|
if routines.IsPartOfGroupInRadius( self.Client:ClientGroup(), Client:ClientPosition(), 150 ) then
|
||||||
Near = true
|
Near = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return Near
|
return Near
|
||||||
|
|
||||||
@ -593,8 +632,8 @@ trace.f(self.ClassName )
|
|||||||
local CarrierPosOnBoard = ClientUnit:getPoint()
|
local CarrierPosOnBoard = ClientUnit:getPoint()
|
||||||
local CarrierPosMoveAway = ClientUnit:getPoint()
|
local CarrierPosMoveAway = ClientUnit:getPoint()
|
||||||
|
|
||||||
local CargoHostGroup = LandingZone:GetCargoHostGroup()
|
local CargoHostGroup = self.Client:ClientGroup()
|
||||||
local CargoHostGroupName = LandingZone:GetCargoHostGroup():getName()
|
local CargoHostGroupName = self.Client:ClientGroup():getName()
|
||||||
|
|
||||||
local CargoHostUnits = CargoHostGroup:getUnits()
|
local CargoHostUnits = CargoHostGroup:getUnits()
|
||||||
local CargoPos = CargoHostUnits[1]:getPoint()
|
local CargoPos = CargoHostUnits[1]:getPoint()
|
||||||
@ -677,11 +716,22 @@ trace.f(self.ClassName )
|
|||||||
|
|
||||||
local OnBoarded = false
|
local OnBoarded = false
|
||||||
|
|
||||||
local CargoHostGroup = LandingZone:GetCargoHostGroup()
|
if self.Client and self.Client:ClientGroup() then
|
||||||
if routines.IsPartOfGroupInRadius( CargoHostGroup, Client:ClientPosition(), 25 ) then
|
if routines.IsPartOfGroupInRadius( self.Client:ClientGroup(), Client:ClientPosition(), 25 ) then
|
||||||
--CargoGroup:destroy()
|
|
||||||
|
-- Switch Cargo from self.Client to Client ...
|
||||||
|
Client:AddCargo( self )
|
||||||
|
self.Client:RemoveCargo( self )
|
||||||
|
trace.i( self.ClassName, 'Cargo switched from ' .. self.Client:ClientGroup():getName() .. ' to ' .. Client:ClientGroup():getName() )
|
||||||
|
trace.i( self.ClassName, 'Cargo is ' .. self.CargoName ) -- Should not be null
|
||||||
|
|
||||||
|
-- ok, so the Cargo has a new Client, thus, change the Owning Client of the Cargo.
|
||||||
|
self.Client = Client
|
||||||
|
|
||||||
|
-- All done, onboarded the Cargo to the new Client.
|
||||||
OnBoarded = true
|
OnBoarded = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return OnBoarded
|
return OnBoarded
|
||||||
end
|
end
|
||||||
|
|||||||
@ -45,7 +45,7 @@ CLIENT = {
|
|||||||
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
|
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
|
||||||
|
|
||||||
function CLIENT:New( ClientName, ClientBriefing )
|
function CLIENT:New( ClientName, ClientBriefing )
|
||||||
trace.f(self.ClassName)
|
trace.f( self.ClassName, { ClientName, ClientBriefing } )
|
||||||
|
|
||||||
-- Arrange meta tables
|
-- Arrange meta tables
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
@ -184,7 +184,7 @@ end
|
|||||||
-- @tparam string Cargo is the @{CARGO}.
|
-- @tparam string Cargo is the @{CARGO}.
|
||||||
-- @treturn CLIENT
|
-- @treturn CLIENT
|
||||||
function CLIENT:AddCargo( Cargo )
|
function CLIENT:AddCargo( Cargo )
|
||||||
trace.f(self.ClassName, { Cargo } )
|
trace.f(self.ClassName, { Cargo.CargoName } )
|
||||||
|
|
||||||
local Valid = true
|
local Valid = true
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ end
|
|||||||
-- @tparam string CargoName is the name of the @{CARGO}.
|
-- @tparam string CargoName is the name of the @{CARGO}.
|
||||||
-- @treturn Cargo
|
-- @treturn Cargo
|
||||||
function CLIENT:RemoveCargo( Cargo )
|
function CLIENT:RemoveCargo( Cargo )
|
||||||
trace.f(self.ClassName )
|
trace.f(self.ClassName, { Cargo.CargoName } )
|
||||||
|
|
||||||
local Valid = true
|
local Valid = true
|
||||||
|
|
||||||
|
|||||||
@ -483,7 +483,7 @@ trace.f(self.ClassName)
|
|||||||
|
|
||||||
-- If the Cargo is ready to be loaded, load it into the Client.
|
-- If the Cargo is ready to be loaded, load it into the Client.
|
||||||
|
|
||||||
trace.i(self.ClassName, Task.Cargo)
|
trace.i(self.ClassName, Task.Cargo.CargoName)
|
||||||
|
|
||||||
if Task.Cargo:OnBoarded( Client, Task.CurrentCargoZone ) then
|
if Task.Cargo:OnBoarded( Client, Task.CurrentCargoZone ) then
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user