mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Made it. Now cargo can be defined in the Mission Editor as #CARGO
This commit is contained in:
@@ -610,7 +610,7 @@ do -- CARGO
|
|||||||
-- @param #number NearRadius The radius when the cargo will board the Carrier (to avoid collision).
|
-- @param #number NearRadius The radius when the cargo will board the Carrier (to avoid collision).
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function CARGO:IsNear( PointVec2, NearRadius )
|
function CARGO:IsNear( PointVec2, NearRadius )
|
||||||
--self:F2( { PointVec2 = PointVec2, NearRadius = NearRadius } )
|
--self:F( { PointVec2 = PointVec2, NearRadius = NearRadius } )
|
||||||
|
|
||||||
if self.CargoObject:IsAlive() then
|
if self.CargoObject:IsAlive() then
|
||||||
--local Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
|
--local Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
|
||||||
|
|||||||
@@ -242,35 +242,96 @@ function DATABASE:FindAirbase( AirbaseName )
|
|||||||
return AirbaseFound
|
return AirbaseFound
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds a Cargo based on the Cargo Name in the DATABASE.
|
|
||||||
-- @param #DATABASE self
|
|
||||||
-- @param #string CargoName The name of the airbase
|
|
||||||
function DATABASE:AddCargo( Cargo )
|
|
||||||
|
|
||||||
if not self.CARGOS[Cargo.Name] then
|
|
||||||
self.CARGOS[Cargo.Name] = Cargo
|
do -- cargo
|
||||||
|
|
||||||
|
--- Adds a Cargo based on the Cargo Name in the DATABASE.
|
||||||
|
-- @param #DATABASE self
|
||||||
|
-- @param #string CargoName The name of the airbase
|
||||||
|
function DATABASE:AddCargo( Cargo )
|
||||||
|
|
||||||
|
if not self.CARGOS[Cargo.Name] then
|
||||||
|
self.CARGOS[Cargo.Name] = Cargo
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Deletes a Cargo from the DATABASE based on the Cargo Name.
|
--- Deletes a Cargo from the DATABASE based on the Cargo Name.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string CargoName The name of the airbase
|
-- @param #string CargoName The name of the airbase
|
||||||
function DATABASE:DeleteCargo( CargoName )
|
function DATABASE:DeleteCargo( CargoName )
|
||||||
|
|
||||||
self.CARGOS[CargoName] = nil
|
self.CARGOS[CargoName] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Finds an CARGO based on the CargoName.
|
--- Finds an CARGO based on the CargoName.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string CargoName
|
-- @param #string CargoName
|
||||||
-- @return Wrapper.Cargo#CARGO The found CARGO.
|
-- @return Wrapper.Cargo#CARGO The found CARGO.
|
||||||
function DATABASE:FindCargo( CargoName )
|
function DATABASE:FindCargo( CargoName )
|
||||||
|
|
||||||
local CargoFound = self.CARGOS[CargoName]
|
local CargoFound = self.CARGOS[CargoName]
|
||||||
return CargoFound
|
return CargoFound
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Checks if the Template name has a ~CARGO tag.
|
||||||
|
-- If yes, the group is a cargo.
|
||||||
|
-- @param #DATABASE self
|
||||||
|
-- @param #string TemplateName
|
||||||
|
-- @return #boolean
|
||||||
|
function DATABASE:IsCargo( TemplateName )
|
||||||
|
|
||||||
|
TemplateName = env.getValueDictByKey( TemplateName )
|
||||||
|
|
||||||
|
local Cargo = TemplateName:match( "#(CARGO)" )
|
||||||
|
|
||||||
|
return Cargo and Cargo == "CARGO"
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Private method that registers new Static Templates within the DATABASE Object.
|
||||||
|
-- @param #DATABASE self
|
||||||
|
-- @return #DATABASE self
|
||||||
|
function DATABASE:RegisterCargos()
|
||||||
|
|
||||||
|
for CargoGroupName, CargoGroup in pairs( self.GROUPS ) do
|
||||||
|
if self:IsCargo( CargoGroupName ) then
|
||||||
|
local CargoInfo = CargoGroupName:match("~CARGO(.*)")
|
||||||
|
local CargoParam = CargoInfo and CargoInfo:match( "%((.*)%)")
|
||||||
|
local CargoName = CargoGroupName:match("(.*)~CARGO")
|
||||||
|
local Type = CargoParam and CargoParam:match( "T=([%a%d ]+),?")
|
||||||
|
local Name = CargoParam and CargoParam:match( "N=([%a%d]+),?")
|
||||||
|
local LoadRadius = CargoParam and CargoParam:match( "RR=([%a%d]+),?")
|
||||||
|
local NearRadius = CargoParam and CargoParam:match( "NR=([%a%d]+),?")
|
||||||
|
|
||||||
|
CARGO_GROUP:New( CargoGroup, Type, Name or CargoName, LoadRadius, NearRadius )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for CargoStaticName, CargoStatic in pairs( self.STATICS ) do
|
||||||
|
if self:IsCargo( CargoStaticName ) then
|
||||||
|
local CargoInfo = CargoStaticName:match("~CARGO(.*)")
|
||||||
|
local CargoParam = CargoInfo and CargoInfo:match( "%((.*)%)")
|
||||||
|
local CargoName = CargoStaticName:match("(.*)~CARGO")
|
||||||
|
local Type = CargoParam and CargoParam:match( "T=([%a%d ]+),?")
|
||||||
|
local Category = CargoParam and CargoParam:match( "C=([%a%d ]+),?")
|
||||||
|
local Name = CargoParam and CargoParam:match( "N=([%a%d]+),?")
|
||||||
|
local LoadRadius = CargoParam and tonumber( CargoParam:match( "RR=([%a%d]+),?") )
|
||||||
|
local NearRadius = CargoParam and tonumber( CargoParam:match( "NR=([%a%d]+),?") )
|
||||||
|
|
||||||
|
if Category == "SLING" then
|
||||||
|
CARGO_SLINGLOAD:New( CargoStatic, Type, Name or CargoName, LoadRadius, NearRadius )
|
||||||
|
else
|
||||||
|
if Category == "CRATE" then
|
||||||
|
CARGO_CRATE:New( CargoStatic, Type, Name or CargoName, LoadRadius, NearRadius )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end -- cargo
|
||||||
|
|
||||||
--- Finds a CLIENT based on the ClientName.
|
--- Finds a CLIENT based on the ClientName.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
|
|||||||
@@ -13,3 +13,5 @@ _DATABASE = DATABASE:New() -- Core.Database#DATABASE
|
|||||||
_SETTINGS = SETTINGS:Set()
|
_SETTINGS = SETTINGS:Set()
|
||||||
_SETTINGS:SetPlayerMenuOn()
|
_SETTINGS:SetPlayerMenuOn()
|
||||||
|
|
||||||
|
_DATABASE:RegisterCargos()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user