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
aadd529093
commit
c22492f051
@ -307,6 +307,7 @@ trace.f( self.ClassName )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function CARGO:IsLoadedInClient()
|
function CARGO:IsLoadedInClient()
|
||||||
|
trace.f( self.ClassName )
|
||||||
|
|
||||||
if self:IsStatusLoaded() or self:IsStatusLoading() then
|
if self:IsStatusLoaded() or self:IsStatusLoading() then
|
||||||
return self.CargoClient
|
return self.CargoClient
|
||||||
@ -656,7 +657,8 @@ trace.f( self.ClassName )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if SpawnCargo then
|
if SpawnCargo then
|
||||||
self:StatusNone()
|
self.CargoClient = CLIENT:New( self.CargoClientInitGroupName )
|
||||||
|
self:StatusLoaded( self.CargoClient )
|
||||||
end
|
end
|
||||||
|
|
||||||
local CargoClientInitGroup = Group.getByName( self.CargoClientInitGroupName )
|
local CargoClientInitGroup = Group.getByName( self.CargoClientInitGroupName )
|
||||||
@ -782,7 +784,7 @@ trace.f(self.ClassName )
|
|||||||
local OnBoarded = false
|
local OnBoarded = false
|
||||||
|
|
||||||
if self.CargoClient and self.CargoClient:ClientGroup() then
|
if self.CargoClient and self.CargoClient:ClientGroup() then
|
||||||
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupUnit(), CargoClient:ClientPosition(), 25 ) then
|
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupUnit(), self.CargoClient:ClientPosition(), 10 ) then
|
||||||
|
|
||||||
-- Switch Cargo from self.CargoClient to Client ... Each cargo can have only one client. So assigning the new client for the cargo is enough.
|
-- Switch Cargo from self.CargoClient to Client ... Each cargo can have only one client. So assigning the new client for the cargo is enough.
|
||||||
self:StatusLoaded( Client )
|
self:StatusLoaded( Client )
|
||||||
|
|||||||
@ -86,10 +86,12 @@ trace.f(self.ClassName)
|
|||||||
local ClientGroup = Group.getByName( self.ClientName )
|
local ClientGroup = Group.getByName( self.ClientName )
|
||||||
if ClientGroup then
|
if ClientGroup then
|
||||||
trace.i( self.ClassName, "ClientGroup = " .. self.ClientName )
|
trace.i( self.ClassName, "ClientGroup = " .. self.ClientName )
|
||||||
if ClientGroup:isExist() and ClientGroup:getID() == UnitData:getGroup():getID() then
|
if ClientGroup:isExist() then
|
||||||
trace.i( self.ClassName, "Normal logic" )
|
if ClientGroup:getID() == UnitData:getGroup():getID() then
|
||||||
trace.i( self.ClassName, self.ClientName .. " : group found!" )
|
trace.i( self.ClassName, "Normal logic" )
|
||||||
return ClientGroup
|
trace.i( self.ClassName, self.ClientName .. " : group found!" )
|
||||||
|
return ClientGroup
|
||||||
|
end
|
||||||
else
|
else
|
||||||
-- Now we need to resolve the bugs in DCS 1.5 ...
|
-- Now we need to resolve the bugs in DCS 1.5 ...
|
||||||
-- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil)
|
-- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil)
|
||||||
@ -113,6 +115,17 @@ trace.f(self.ClassName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- For non player clients
|
||||||
|
local ClientGroup = Group.getByName( self.ClientName )
|
||||||
|
if ClientGroup then
|
||||||
|
trace.i( self.ClassName, "ClientGroup = " .. self.ClientName )
|
||||||
|
if ClientGroup:isExist() then
|
||||||
|
trace.i( self.ClassName, "Normal logic" )
|
||||||
|
trace.i( self.ClassName, self.ClientName .. " : group found!" )
|
||||||
|
return ClientGroup
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.ClientGroupID = nil
|
self.ClientGroupID = nil
|
||||||
self.ClientGroupUnit = nil
|
self.ClientGroupUnit = nil
|
||||||
|
|||||||
@ -98,7 +98,7 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
trace.i( self.ClassName, { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo.CargoWeight } )
|
trace.i( self.ClassName, { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo.CargoWeight } )
|
||||||
|
|
||||||
if Cargo:IsStatusLoaded() then
|
if Cargo:IsStatusLoaded() and Client == Cargo:IsLoadedInClient() then
|
||||||
|
|
||||||
if Client._Menus[Cargo.CargoType] == nil then
|
if Client._Menus[Cargo.CargoType] == nil then
|
||||||
Client._Menus[Cargo.CargoType] = {}
|
Client._Menus[Cargo.CargoType] = {}
|
||||||
|
|||||||
@ -78,7 +78,7 @@ trace.f( self.ClassName )
|
|||||||
|
|
||||||
trace.i( self.ClassName, { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } )
|
trace.i( self.ClassName, { Cargo.ClassName, Cargo.CargoName, Cargo.CargoType, Cargo:IsStatusNone(), Cargo:IsStatusLoaded(), Cargo:IsStatusLoading(), Cargo:IsStatusUnLoaded() } )
|
||||||
|
|
||||||
if Cargo:IsStatusNone() then
|
if Cargo:IsStatusNone() or ( Cargo:IsStatusLoaded() and Client ~= Cargo:IsLoadedInClient() ) then
|
||||||
|
|
||||||
local MenuAdd = false
|
local MenuAdd = false
|
||||||
if Cargo:IsNear( Client, self.CurrentCargoZone ) then
|
if Cargo:IsNear( Client, self.CurrentCargoZone ) then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user