mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Optimized Cargo Logic
This commit is contained in:
parent
a3acab9288
commit
aadd529093
197
Moose/Cargo.lua
197
Moose/Cargo.lua
@ -272,7 +272,7 @@ CARGO = {
|
|||||||
UNLOADED = 2,
|
UNLOADED = 2,
|
||||||
LOADING = 3
|
LOADING = 3
|
||||||
},
|
},
|
||||||
CargoCarrierGroupName = nil
|
CargoClient = 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...
|
||||||
@ -285,7 +285,7 @@ trace.f( self.ClassName, { CargoType, CargoName, CargoWeight } )
|
|||||||
self.CargoName = CargoName
|
self.CargoName = CargoName
|
||||||
self.CargoWeight = CargoWeight
|
self.CargoWeight = CargoWeight
|
||||||
|
|
||||||
self.Status = self:StatusNone()
|
self:StatusNone()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -308,36 +308,21 @@ end
|
|||||||
|
|
||||||
function CARGO:IsLoadedInClient()
|
function CARGO:IsLoadedInClient()
|
||||||
|
|
||||||
if self:IsStatusLoaded() then
|
if self:IsStatusLoaded() or self:IsStatusLoading() then
|
||||||
return self.Client
|
return self.CargoClient
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CARGO:Load( Client )
|
|
||||||
trace.f( self.ClassName )
|
|
||||||
|
|
||||||
Client:AddCargo( self )
|
|
||||||
|
|
||||||
self.Client = Client
|
|
||||||
self:StatusLoaded()
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function CARGO:UnLoad( Client, TargetZoneName )
|
function CARGO:UnLoad( Client, TargetZoneName )
|
||||||
trace.f( self.ClassName )
|
trace.f( self.ClassName )
|
||||||
|
|
||||||
local Cargo = Client:RemoveCargo( self )
|
self:StatusUnLoaded()
|
||||||
if Cargo then
|
|
||||||
env.info( 'STAGEUNLOAD:Executing() Cargo.CargoName = ' .. Cargo.CargoName )
|
|
||||||
|
|
||||||
Cargo:StatusUnLoaded()
|
return self
|
||||||
end
|
|
||||||
|
|
||||||
return Cargo
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CARGO:OnBoard( Client, LandingZone )
|
function CARGO:OnBoard( Client, LandingZone )
|
||||||
@ -345,6 +330,7 @@ trace.f(self.ClassName )
|
|||||||
|
|
||||||
local Valid = true
|
local Valid = true
|
||||||
|
|
||||||
|
self.CargoClient = Client
|
||||||
local ClientUnit = Client:GetClientGroupUnit()
|
local ClientUnit = Client:GetClientGroupUnit()
|
||||||
|
|
||||||
return Valid
|
return Valid
|
||||||
@ -358,6 +344,14 @@ trace.f(self.ClassName )
|
|||||||
return OnBoarded
|
return OnBoarded
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function CARGO:Load( Client )
|
||||||
|
trace.f( self.ClassName )
|
||||||
|
|
||||||
|
self:StatusLoaded( Client )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
function CARGO:IsLandingRequired()
|
function CARGO:IsLandingRequired()
|
||||||
trace.f( self.ClassName )
|
trace.f( self.ClassName )
|
||||||
return true
|
return true
|
||||||
@ -372,15 +366,26 @@ end
|
|||||||
function CARGO:StatusNone()
|
function CARGO:StatusNone()
|
||||||
trace.f(self.ClassName )
|
trace.f(self.ClassName )
|
||||||
|
|
||||||
self.Status = CARGO.STATUS.NONE
|
self.CargoClient = nil
|
||||||
|
self.CargoStatus = CARGO.STATUS.NONE
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function CARGO:StatusLoaded()
|
function CARGO:StatusLoading( Client )
|
||||||
trace.f(self.ClassName )
|
trace.f(self.ClassName )
|
||||||
|
|
||||||
self.Status = CARGO.STATUS.LOADED
|
self.CargoClient = Client
|
||||||
|
self.CargoStatus = CARGO.STATUS.LOADING
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function CARGO:StatusLoaded( Client )
|
||||||
|
trace.f(self.ClassName )
|
||||||
|
|
||||||
|
self.CargoClient = Client
|
||||||
|
self.CargoStatus = CARGO.STATUS.LOADED
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -388,43 +393,38 @@ end
|
|||||||
function CARGO:StatusUnLoaded()
|
function CARGO:StatusUnLoaded()
|
||||||
trace.f(self.ClassName )
|
trace.f(self.ClassName )
|
||||||
|
|
||||||
self.Status = CARGO.STATUS.UNLOADED
|
self.CargoClient = nil
|
||||||
|
self.CargoStatus = CARGO.STATUS.UNLOADED
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function CARGO:StatusLoading()
|
|
||||||
trace.f(self.ClassName )
|
|
||||||
|
|
||||||
self.Status = CARGO.STATUS.LOADING
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
function CARGO:IsStatusNone()
|
function CARGO:IsStatusNone()
|
||||||
trace.f(self.ClassName )
|
trace.f(self.ClassName )
|
||||||
|
|
||||||
return self.Status == CARGO.STATUS.NONE
|
return self.CargoStatus == CARGO.STATUS.NONE
|
||||||
end
|
|
||||||
|
|
||||||
function CARGO:IsStatusLoaded()
|
|
||||||
trace.f(self.ClassName )
|
|
||||||
|
|
||||||
return self.Status == CARGO.STATUS.LOADED
|
|
||||||
end
|
|
||||||
|
|
||||||
function CARGO:IsStatusUnLoaded()
|
|
||||||
trace.f(self.ClassName )
|
|
||||||
|
|
||||||
return self.Status == CARGO.STATUS.UNLOADED
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CARGO:IsStatusLoading()
|
function CARGO:IsStatusLoading()
|
||||||
trace.f(self.ClassName )
|
trace.f(self.ClassName )
|
||||||
|
|
||||||
return self.Status == CARGO.STATUS.LOADING
|
return self.CargoStatus == CARGO.STATUS.LOADING
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function CARGO:IsStatusLoaded()
|
||||||
|
trace.f(self.ClassName )
|
||||||
|
|
||||||
|
return self.CargoStatus == CARGO.STATUS.LOADED
|
||||||
|
end
|
||||||
|
|
||||||
|
function CARGO:IsStatusUnLoaded()
|
||||||
|
trace.f(self.ClassName )
|
||||||
|
|
||||||
|
return self.CargoStatus == CARGO.STATUS.UNLOADED
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
CARGO_GROUP = {
|
CARGO_GROUP = {
|
||||||
ClassName = "CARGO_GROUP"
|
ClassName = "CARGO_GROUP"
|
||||||
}
|
}
|
||||||
@ -450,13 +450,19 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
local SpawnCargo = true
|
local SpawnCargo = true
|
||||||
|
|
||||||
if self.CargoGroupName then
|
if self:IsStatusNone() then
|
||||||
|
|
||||||
|
elseif self:IsStatusLoaded() or self:IsStatusLoading() then
|
||||||
|
|
||||||
local Client = self:IsLoadedInClient()
|
local Client = self:IsLoadedInClient()
|
||||||
if Client and Client:ClientGroup() then
|
if Client and Client:ClientGroup() then
|
||||||
if Client:FindCargo( self.CargoName ) then
|
|
||||||
SpawnCargo = false
|
SpawnCargo = false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
elseif self:IsStatusUnLoaded() then
|
||||||
|
|
||||||
|
SpawnCargo = false
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if SpawnCargo then
|
if SpawnCargo then
|
||||||
@ -466,9 +472,10 @@ trace.f( self.ClassName )
|
|||||||
else
|
else
|
||||||
--- ReSpawn the Cargo in the CargoZone without a host ...
|
--- ReSpawn the Cargo in the CargoZone without a host ...
|
||||||
self.CargoGroupName = self.CargoSpawn:InZone( self.CargoZone:GetCargoZoneName(), self.CargoName ).name
|
self.CargoGroupName = self.CargoSpawn:InZone( self.CargoZone:GetCargoZoneName(), self.CargoName ).name
|
||||||
|
end
|
||||||
|
self:StatusNone()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
trace.i( self.ClassName, { self.CargoGroupName, CARGOS[self.CargoName].CargoGroupName } )
|
trace.i( self.ClassName, { self.CargoGroupName, CARGOS[self.CargoName].CargoGroupName } )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -562,6 +569,8 @@ trace.f(self.ClassName )
|
|||||||
|
|
||||||
routines.scheduleFunction( routines.goRoute, { self.CargoGroupName, Points}, timer.getTime() + 4 )
|
routines.scheduleFunction( routines.goRoute, { self.CargoGroupName, Points}, timer.getTime() + 4 )
|
||||||
|
|
||||||
|
self:StatusLoading( Client )
|
||||||
|
|
||||||
return Valid
|
return Valid
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -575,6 +584,7 @@ trace.f(self.ClassName )
|
|||||||
local CargoGroup = Group.getByName( self.CargoGroupName )
|
local CargoGroup = Group.getByName( self.CargoGroupName )
|
||||||
if routines.IsPartOfGroupInRadius( CargoGroup, Client:ClientPosition(), 25 ) then
|
if routines.IsPartOfGroupInRadius( CargoGroup, Client:ClientPosition(), 25 ) then
|
||||||
CargoGroup:destroy()
|
CargoGroup:destroy()
|
||||||
|
self:StatusLoaded( Client )
|
||||||
OnBoarded = true
|
OnBoarded = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -588,9 +598,8 @@ trace.f( self.ClassName )
|
|||||||
trace.i( self.ClassName, 'self.CargoGroupName = ' .. self.CargoGroupName )
|
trace.i( self.ClassName, 'self.CargoGroupName = ' .. self.CargoGroupName )
|
||||||
|
|
||||||
self.CargoSpawn:FromCarrier( Client:GetClientGroupUnit(), TargetZoneName, self.CargoGroupName )
|
self.CargoSpawn:FromCarrier( Client:GetClientGroupUnit(), TargetZoneName, self.CargoGroupName )
|
||||||
self:StatusUnLoaded()
|
|
||||||
local Cargo = Client:RemoveCargo( self )
|
|
||||||
|
|
||||||
|
self:StatusUnLoaded()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -601,15 +610,18 @@ CARGO_PACKAGE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function CARGO_PACKAGE:New( CargoType, CargoName, CargoWeight, CargoHostName )
|
function CARGO_PACKAGE:New( CargoType, CargoName, CargoWeight, CargoClientInitGroupName )
|
||||||
trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, CargoHostName } )
|
trace.f( self.ClassName, { CargoType, CargoName, CargoWeight, CargoClientInitGroupName } )
|
||||||
|
|
||||||
-- 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.CargoHostName = CargoHostName
|
self.CargoClientInitGroupName = CargoClientInitGroupName
|
||||||
|
|
||||||
self.CargoHostSpawn = SPAWN:New( self.CargoHostName )
|
self.CargoClient = CLIENT:New( self.CargoClientInitGroupName )
|
||||||
|
self:StatusLoaded( self.CargoClient )
|
||||||
|
|
||||||
|
self.CargoClientInitGroupSpawn = SPAWN:New( self.CargoClientInitGroupName )
|
||||||
|
|
||||||
CARGOS[self.CargoName] = self
|
CARGOS[self.CargoName] = self
|
||||||
|
|
||||||
@ -622,34 +634,34 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
-- this needs to be checked thoroughly
|
-- this needs to be checked thoroughly
|
||||||
|
|
||||||
|
|
||||||
local SpawnCargo = true
|
local SpawnCargo = true
|
||||||
|
|
||||||
trace.i( self.ClassName, self.CargoHostName )
|
trace.i( self.ClassName, self.CargoClientInitGroupName )
|
||||||
|
|
||||||
if self.Client and self.Client:ClientGroup() then
|
if self:IsStatusNone() then
|
||||||
trace.i( self.ClassName, 'There is a Client ' .. self.Client.ClientName )
|
|
||||||
if self.Client:FindCargo( self.CargoName ) then
|
elseif self:IsStatusLoading() or self:IsStatusLoaded() then
|
||||||
if self.Client:GetClientGroupUnit():getPlayerName() then -- this needs to be checked thoroughly
|
|
||||||
trace.i( self.ClassName, 'ok, Client is of player ' .. self.Client:GetClientGroupUnit():getPlayerName() .. ' and contains the Cargo, do nothing' )
|
local Client = self:IsLoadedInClient()
|
||||||
|
if Client and Client:ClientGroup() then
|
||||||
SpawnCargo = false
|
SpawnCargo = false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
elseif self:IsStatusUnLoaded() then
|
||||||
|
|
||||||
|
SpawnCargo = false
|
||||||
|
|
||||||
else
|
else
|
||||||
if self.CargoHostName then
|
|
||||||
local CargoHostGroup = Group.getByName( self.CargoHostName )
|
|
||||||
if not CargoHostGroup then
|
|
||||||
self.CargoHostSpawn:ReSpawn()
|
|
||||||
end
|
|
||||||
local CargoHostGroup = Group.getByName( self.CargoHostName )
|
|
||||||
if CargoHostGroup and CargoHostGroup:isExist() then
|
|
||||||
self.Client = CLIENT:New( self.CargoHostGroup, '' )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if SpawnCargo then
|
if SpawnCargo then
|
||||||
self.Client:AddCargo( self ) -- Adding cargo to the AI client
|
self:StatusNone()
|
||||||
|
end
|
||||||
|
|
||||||
|
local CargoClientInitGroup = Group.getByName( self.CargoClientInitGroupName )
|
||||||
|
if CargoClientInitGroup then
|
||||||
|
self.CargoClientInitGroupSpawn:Spawn( self.CargoClientInitGroupName )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -660,20 +672,14 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
local Near = false
|
local Near = false
|
||||||
|
|
||||||
if self.Client and self.Client:ClientGroup():getName() then
|
if self.CargoClient and self.CargoClient:ClientGroup() then
|
||||||
trace.i( self.ClassName, self.Client.ClientName )
|
trace.i( self.ClassName, self.CargoClient.ClientName )
|
||||||
trace.i( self.ClassName, 'Client Exists.' )
|
trace.i( self.ClassName, 'Client Exists.' )
|
||||||
trace.i( self.ClassName, 'self.Client:ClientGroup():getName() = ' .. self.Client:ClientGroup():getName() )
|
|
||||||
|
|
||||||
-- Find the cargo in the client
|
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupUnit(), Client:ClientPosition(), 150 ) then
|
||||||
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
|
||||||
end
|
|
||||||
|
|
||||||
return Near
|
return Near
|
||||||
|
|
||||||
@ -691,8 +697,8 @@ trace.f(self.ClassName )
|
|||||||
local CarrierPosOnBoard = ClientUnit:getPoint()
|
local CarrierPosOnBoard = ClientUnit:getPoint()
|
||||||
local CarrierPosMoveAway = ClientUnit:getPoint()
|
local CarrierPosMoveAway = ClientUnit:getPoint()
|
||||||
|
|
||||||
local CargoHostGroup = self.Client:ClientGroup()
|
local CargoHostGroup = self.CargoClient:ClientGroup()
|
||||||
local CargoHostName = self.Client:ClientGroup():getName()
|
local CargoHostName = self.CargoClient:ClientGroup():getName()
|
||||||
|
|
||||||
local CargoHostUnits = CargoHostGroup:getUnits()
|
local CargoHostUnits = CargoHostGroup:getUnits()
|
||||||
local CargoPos = CargoHostUnits[1]:getPoint()
|
local CargoPos = CargoHostUnits[1]:getPoint()
|
||||||
@ -775,17 +781,11 @@ trace.f(self.ClassName )
|
|||||||
|
|
||||||
local OnBoarded = false
|
local OnBoarded = false
|
||||||
|
|
||||||
if self.Client and self.Client:ClientGroup() then
|
if self.CargoClient and self.CargoClient:ClientGroup() then
|
||||||
if routines.IsPartOfGroupInRadius( self.Client:ClientGroup(), Client:ClientPosition(), 25 ) then
|
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupUnit(), CargoClient:ClientPosition(), 25 ) then
|
||||||
|
|
||||||
-- Switch Cargo from self.Client to Client ...
|
-- Switch Cargo from self.CargoClient to Client ... Each cargo can have only one client. So assigning the new client for the cargo is enough.
|
||||||
Client:AddCargo( self )
|
self:StatusLoaded( Client )
|
||||||
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.
|
-- All done, onboarded the Cargo to the new Client.
|
||||||
OnBoarded = true
|
OnBoarded = true
|
||||||
@ -803,7 +803,6 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
--self.CargoSpawn:FromCarrier( Client:ClientGroup(), TargetZoneName, self.CargoHostName )
|
--self.CargoSpawn:FromCarrier( Client:ClientGroup(), TargetZoneName, self.CargoHostName )
|
||||||
self:StatusUnLoaded()
|
self:StatusUnLoaded()
|
||||||
local Cargo = Client:RemoveCargo( self )
|
|
||||||
|
|
||||||
return Cargo
|
return Cargo
|
||||||
end
|
end
|
||||||
@ -948,8 +947,6 @@ trace.f( self.ClassName )
|
|||||||
trace.i( self.ClassName, 'self.CargoGroupName = ' .. self.CargoGroupName )
|
trace.i( self.ClassName, 'self.CargoGroupName = ' .. self.CargoGroupName )
|
||||||
|
|
||||||
self:StatusUnLoaded()
|
self:StatusUnLoaded()
|
||||||
local Cargo = Client:RemoveCargo( self )
|
|
||||||
|
|
||||||
|
|
||||||
return Cargo
|
return Cargo
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,7 +23,6 @@ CLIENT = {
|
|||||||
ClientTransport = false,
|
ClientTransport = false,
|
||||||
ClientBriefingShown = false,
|
ClientBriefingShown = false,
|
||||||
_Menus = {},
|
_Menus = {},
|
||||||
_Cargos = {},
|
|
||||||
_Tasks = {},
|
_Tasks = {},
|
||||||
Messages = {
|
Messages = {
|
||||||
}
|
}
|
||||||
@ -61,7 +60,6 @@ end
|
|||||||
function CLIENT:Reset( ClientName )
|
function CLIENT:Reset( ClientName )
|
||||||
trace.f(self.ClassName)
|
trace.f(self.ClassName)
|
||||||
self._Menus = {}
|
self._Menus = {}
|
||||||
self._Cargos = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- ClientGroup returns the Group of a Client.
|
--- ClientGroup returns the Group of a Client.
|
||||||
@ -199,15 +197,6 @@ trace.f(self.ClassName)
|
|||||||
return self.ClientTransport
|
return self.ClientTransport
|
||||||
end
|
end
|
||||||
|
|
||||||
--- FindCargo finds loaded Cargo within a CLIENT instance.
|
|
||||||
-- Cargo is loaded when certain PICK-UP or DEPLOY Tasks are properly executed.
|
|
||||||
-- @tparam string CargoName is the name of the cargo.
|
|
||||||
-- @treturn CARGO_TYPE
|
|
||||||
function CLIENT:FindCargo( CargoName )
|
|
||||||
trace.f(self.ClassName)
|
|
||||||
return self._Cargos[CargoName]
|
|
||||||
end
|
|
||||||
|
|
||||||
--- ShowCargo shows the @{CARGO} within the CLIENT to the Player.
|
--- ShowCargo shows the @{CARGO} within the CLIENT to the Player.
|
||||||
-- The @{CARGO} is shown throught the MESSAGE system of DCS World.
|
-- The @{CARGO} is shown throught the MESSAGE system of DCS World.
|
||||||
function CLIENT:ShowCargo()
|
function CLIENT:ShowCargo()
|
||||||
@ -215,14 +204,13 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
local CargoMsg = ""
|
local CargoMsg = ""
|
||||||
|
|
||||||
for CargoName, Cargo in pairs( self._Cargos ) do
|
for CargoName, Cargo in pairs( CARGOS ) do
|
||||||
if CargoMsg ~= "" then
|
if self == Cargo:IsLoadedInClient() then
|
||||||
CargoMsg = CargoMsg .. "\n"
|
CargoMsg = CargoMsg .. Cargo.CargoName .. " Type:" .. Cargo.CargoType .. " Weight: " .. Cargo.CargoWeight .. "\n"
|
||||||
end
|
end
|
||||||
CargoMsg = CargoMsg .. Cargo.CargoName .. " Type:" .. Cargo.CargoType .. " Weight: " .. Cargo.CargoWeight
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if CargoMsg == '' then
|
if CargoMsg == "" then
|
||||||
CargoMsg = "empty"
|
CargoMsg = "empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -230,61 +218,6 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- InitCargo allows to initialize @{CARGO} on the CLIENT when the client initializes.
|
|
||||||
-- @tparam string InitCargoNames is a string or a table containing the names of the @{CARGO}s initialized in the Mission.
|
|
||||||
-- @treturn CLIENT
|
|
||||||
function CLIENT:InitCargo( InitCargoNames )
|
|
||||||
trace.f(self.ClassName, { InitCargoNames } )
|
|
||||||
|
|
||||||
local Valid = true
|
|
||||||
|
|
||||||
if Valid then
|
|
||||||
if type( InitCargoNames ) == "table" then
|
|
||||||
self.InitCargoNames = InitCargoNames
|
|
||||||
else
|
|
||||||
self.InitCargoNames = { InitCargoNames }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- AddCargo allows to add @{CARGO} on the CLIENT.
|
|
||||||
-- @tparam string Cargo is the @{CARGO}.
|
|
||||||
-- @treturn CLIENT
|
|
||||||
function CLIENT:AddCargo( Cargo )
|
|
||||||
trace.f(self.ClassName, { Cargo.CargoName } )
|
|
||||||
|
|
||||||
local Valid = true
|
|
||||||
|
|
||||||
if Valid then
|
|
||||||
self._Cargos[Cargo.CargoName] = Cargo
|
|
||||||
self:ShowCargo()
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- RemoveCargo removes @{CARGO} from the CLIENT.
|
|
||||||
-- @tparam string CargoName is the name of the @{CARGO}.
|
|
||||||
-- @treturn Cargo
|
|
||||||
function CLIENT:RemoveCargo( Cargo )
|
|
||||||
trace.f(self.ClassName, { Cargo.CargoName } )
|
|
||||||
|
|
||||||
local Valid = true
|
|
||||||
|
|
||||||
if Valid then
|
|
||||||
trace.i( "CLIENT", "RemoveCargo: CargoName = " .. Cargo.CargoName )
|
|
||||||
--local CargoNew = self._Cargos[Cargo.CargoName]
|
|
||||||
self._Cargos[Cargo.CargoName] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
return Cargo
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- SwitchMessages is a local function called by the DCS World Menu system to switch off messages.
|
--- SwitchMessages is a local function called by the DCS World Menu system to switch off messages.
|
||||||
function CLIENT.SwitchMessages( PrmTable )
|
function CLIENT.SwitchMessages( PrmTable )
|
||||||
PrmTable[1].MessageSwitch = PrmTable[2]
|
PrmTable[1].MessageSwitch = PrmTable[2]
|
||||||
|
|||||||
@ -15,7 +15,6 @@ MISSION = {
|
|||||||
_Clients = {},
|
_Clients = {},
|
||||||
_Tasks = {},
|
_Tasks = {},
|
||||||
_ActiveTasks = {},
|
_ActiveTasks = {},
|
||||||
_Cargos = {},
|
|
||||||
GoalFunction = nil,
|
GoalFunction = nil,
|
||||||
MissionReportTrigger = 0,
|
MissionReportTrigger = 0,
|
||||||
MissionProgressTrigger = 0,
|
MissionProgressTrigger = 0,
|
||||||
@ -360,20 +359,6 @@ function MISSION:GetTasks()
|
|||||||
return self._Tasks
|
return self._Tasks
|
||||||
end
|
end
|
||||||
|
|
||||||
--- 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...
|
|
||||||
SpawnCargo = {}
|
|
||||||
function MISSION:AddCargo( Cargos )
|
|
||||||
self:T( { Cargos } )
|
|
||||||
|
|
||||||
if type( Cargos ) == "table" then
|
|
||||||
for CargoID, Cargo in pairs( Cargos ) do
|
|
||||||
self._Cargos[Cargo.CargoName] = Cargo
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self._Cargos[Cargos.CargoName] = Cargos
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
_TransportExecuteStage: Defines the different stages of Transport unload/load execution. This table is internal and is used to control the validity of Transport load/unload timing.
|
_TransportExecuteStage: Defines the different stages of Transport unload/load execution. This table is internal and is used to control the validity of Transport load/unload timing.
|
||||||
@ -443,8 +428,6 @@ trace.scheduled("MISSIONSCHEDULER","Scheduler")
|
|||||||
Client._Tasks[TaskNumber].LandingZones = Mission._Tasks[TaskNumber].LandingZones
|
Client._Tasks[TaskNumber].LandingZones = Mission._Tasks[TaskNumber].LandingZones
|
||||||
end
|
end
|
||||||
|
|
||||||
Client._Cargos = {}
|
|
||||||
|
|
||||||
Mission:Ongoing()
|
Mission:Ongoing()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -543,9 +526,6 @@ trace.scheduled("MISSIONSCHEDULER","Scheduler")
|
|||||||
-- So first sanitize Client._Tasks[TaskNumber].MissionTask, after that, sanitize only the whole _Tasks structure...
|
-- So first sanitize Client._Tasks[TaskNumber].MissionTask, after that, sanitize only the whole _Tasks structure...
|
||||||
--Client._Tasks[TaskNumber].MissionTask = nil
|
--Client._Tasks[TaskNumber].MissionTask = nil
|
||||||
--Client._Tasks = nil
|
--Client._Tasks = nil
|
||||||
|
|
||||||
-- Sanitize the Client._Cargos. Any cargo within the Client will be lost when the client crashes. This is an important statement.
|
|
||||||
Client._Cargos = nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -76,9 +76,9 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
for CargoID, Cargo in pairs( Cargos ) do
|
for CargoID, Cargo in pairs( Cargos ) do
|
||||||
|
|
||||||
trace.i( self.ClassName, { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType } )
|
trace.i( self.ClassName, { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } )
|
||||||
|
|
||||||
if not Cargo:IsStatusLoaded() and not Cargo:IsStatusLoading() then
|
if Cargo:IsStatusNone() then
|
||||||
|
|
||||||
local MenuAdd = false
|
local MenuAdd = false
|
||||||
if Cargo:IsNear( Client, self.CurrentCargoZone ) then
|
if Cargo:IsNear( Client, self.CurrentCargoZone ) then
|
||||||
|
|||||||
@ -494,7 +494,6 @@ trace.f(self.ClassName)
|
|||||||
|
|
||||||
if Task.ExecuteStage == _TransportExecuteStage.SUCCESS then
|
if Task.ExecuteStage == _TransportExecuteStage.SUCCESS then
|
||||||
Client:Message( 'The ' .. Task.CargoType .. ' have been sucessfully ' .. Task.TEXT[3] .. ' within the landing zone.', _TransportStageMsgTime.DONE, Mission.Name .. "/Stage", "Co-Pilot: Unload" )
|
Client:Message( 'The ' .. Task.CargoType .. ' have been sucessfully ' .. Task.TEXT[3] .. ' within the landing zone.', _TransportStageMsgTime.DONE, Mission.Name .. "/Stage", "Co-Pilot: Unload" )
|
||||||
Task.Cargo:StatusUnLoaded()
|
|
||||||
Task:RemoveCargoMenus( Client )
|
Task:RemoveCargoMenus( Client )
|
||||||
Task.MissionTask:AddGoalCompletion( Task.MissionTask.GoalVerb, Task.CargoName, 1 ) -- We set the cargo as one more goal completed in the mission.
|
Task.MissionTask:AddGoalCompletion( Task.MissionTask.GoalVerb, Task.CargoName, 1 ) -- We set the cargo as one more goal completed in the mission.
|
||||||
return 1
|
return 1
|
||||||
@ -551,10 +550,8 @@ trace.f(self.ClassName)
|
|||||||
20, Mission.Name .. "/STAGELANDING.LOADING1." .. Task.HostUnitName, Task.HostUnitName .. " (" .. Task.HostUnitTypeName .. ")" .. ":" )
|
20, Mission.Name .. "/STAGELANDING.LOADING1." .. Task.HostUnitName, Task.HostUnitName .. " (" .. Task.HostUnitTypeName .. ")" .. ":" )
|
||||||
Task.ExecuteStage = _TransportExecuteStage.SUCCESS
|
Task.ExecuteStage = _TransportExecuteStage.SUCCESS
|
||||||
|
|
||||||
if Mission.MissionReportFlash then
|
|
||||||
Client:ShowCargo()
|
Client:ShowCargo()
|
||||||
end
|
end
|
||||||
end
|
|
||||||
else
|
else
|
||||||
Client:Message( "Hook the " .. Task.CargoNames .. " onto the helicopter " .. Task.TEXT[3] .. " within the landing zone.",
|
Client:Message( "Hook the " .. Task.CargoNames .. " onto the helicopter " .. Task.TEXT[3] .. " within the landing zone.",
|
||||||
_TransportStageMsgTime.EXECUTING, Mission.Name .. "/STAGELOAD.LOADING.1." .. Task.HostUnitName, Task.HostUnitName .. " (" .. Task.HostUnitTypeName .. ")" .. ":", 10 )
|
_TransportStageMsgTime.EXECUTING, Mission.Name .. "/STAGELOAD.LOADING.1." .. Task.HostUnitName, Task.HostUnitName .. " (" .. Task.HostUnitTypeName .. ")" .. ":", 10 )
|
||||||
@ -613,7 +610,6 @@ trace.f(self.ClassName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Task.ExecuteStage == _TransportExecuteStage.SUCCESS then
|
if Task.ExecuteStage == _TransportExecuteStage.SUCCESS then
|
||||||
Task.Cargo:StatusLoaded()
|
|
||||||
Task:RemoveCargoMenus( Client )
|
Task:RemoveCargoMenus( Client )
|
||||||
Client:Message( "Good Job. The " .. Task.CargoType .. " has been sucessfully " .. Task.TEXT[3] .. " within the landing zone.",
|
Client:Message( "Good Job. The " .. Task.CargoType .. " has been sucessfully " .. Task.TEXT[3] .. " within the landing zone.",
|
||||||
self.MSG.TIME, Mission.Name .. "/STAGELANDING.VALIDATE.3." .. Task.HostUnitName, Task.HostUnitName .. " (" .. Task.HostUnitTypeName .. ")" .. ":" )
|
self.MSG.TIME, Mission.Name .. "/STAGELANDING.VALIDATE.3." .. Task.HostUnitName, Task.HostUnitName .. " (" .. Task.HostUnitTypeName .. ")" .. ":" )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user