mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
xxx
This commit is contained in:
parent
0dec9418ca
commit
1b072e11ad
@ -24,7 +24,7 @@
|
|||||||
-- @module Ops.CTLD
|
-- @module Ops.CTLD
|
||||||
-- @image OPS_CTLD.jpg
|
-- @image OPS_CTLD.jpg
|
||||||
|
|
||||||
-- Last Update February 2024
|
-- Last Update March 2024
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
@ -45,6 +45,7 @@ do
|
|||||||
-- @field #number Stock Number of builds available, -1 for unlimited.
|
-- @field #number Stock Number of builds available, -1 for unlimited.
|
||||||
-- @field #string Subcategory Sub-category name.
|
-- @field #string Subcategory Sub-category name.
|
||||||
-- @field #boolean DontShowInMenu Show this item in menu or not.
|
-- @field #boolean DontShowInMenu Show this item in menu or not.
|
||||||
|
-- @field Core.Zone#ZONE Location Location (if set) where to get this cargo item.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -64,6 +65,7 @@ CTLD_CARGO = {
|
|||||||
Stock = nil,
|
Stock = nil,
|
||||||
Mark = nil,
|
Mark = nil,
|
||||||
DontShowInMenu = false,
|
DontShowInMenu = false,
|
||||||
|
Location = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Define cargo types.
|
--- Define cargo types.
|
||||||
@ -100,8 +102,9 @@ CTLD_CARGO = {
|
|||||||
-- @param #number Stock Number of builds available, nil for unlimited
|
-- @param #number Stock Number of builds available, nil for unlimited
|
||||||
-- @param #string Subcategory Name of subcategory, handy if using > 10 types to load.
|
-- @param #string Subcategory Name of subcategory, handy if using > 10 types to load.
|
||||||
-- @param #boolean DontShowInMenu Show this item in menu or not (default: false == show it).
|
-- @param #boolean DontShowInMenu Show this item in menu or not (default: false == show it).
|
||||||
|
-- @param Core.Zone#ZONE Location (optional) Where the cargo is available (one location only).
|
||||||
-- @return #CTLD_CARGO self
|
-- @return #CTLD_CARGO self
|
||||||
function CTLD_CARGO:New(ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped, PerCrateMass, Stock, Subcategory,DontShowInMenu)
|
function CTLD_CARGO:New(ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped, PerCrateMass, Stock, Subcategory, DontShowInMenu, Location)
|
||||||
-- Inherit everything from BASE class.
|
-- Inherit everything from BASE class.
|
||||||
local self=BASE:Inherit(self, BASE:New()) -- #CTLD_CARGO
|
local self=BASE:Inherit(self, BASE:New()) -- #CTLD_CARGO
|
||||||
self:T({ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped})
|
self:T({ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped})
|
||||||
@ -119,9 +122,20 @@ CTLD_CARGO = {
|
|||||||
self.Mark = nil
|
self.Mark = nil
|
||||||
self.Subcategory = Subcategory or "Other"
|
self.Subcategory = Subcategory or "Other"
|
||||||
self.DontShowInMenu = DontShowInMenu or false
|
self.DontShowInMenu = DontShowInMenu or false
|
||||||
|
if type(Location) == "string" then
|
||||||
|
Location = ZONE:New("Location")
|
||||||
|
end
|
||||||
|
self.Location = Location
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Query Location.
|
||||||
|
-- @param #CTLD_CARGO self
|
||||||
|
-- @return Core.Zone#ZONE location or `nil` if not set
|
||||||
|
function CTLD_CARGO:GetLocation()
|
||||||
|
return self.Location
|
||||||
|
end
|
||||||
|
|
||||||
--- Query ID.
|
--- Query ID.
|
||||||
-- @param #CTLD_CARGO self
|
-- @param #CTLD_CARGO self
|
||||||
-- @return #number ID
|
-- @return #number ID
|
||||||
@ -1233,7 +1247,7 @@ CTLD.UnitTypeCapabilities = {
|
|||||||
|
|
||||||
--- CTLD class version.
|
--- CTLD class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CTLD.version="1.0.48"
|
CTLD.version="1.0.49"
|
||||||
|
|
||||||
--- Instantiate a new CTLD.
|
--- Instantiate a new CTLD.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
@ -2356,6 +2370,20 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop, pack)
|
|||||||
if not self.debug then return self end
|
if not self.debug then return self end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Check cargo location if available
|
||||||
|
local location = Cargo:GetLocation()
|
||||||
|
|
||||||
|
if location then
|
||||||
|
local unitcoord = Unit:GetCoordinate() or Group:GetCoordinate()
|
||||||
|
if unitcoord then
|
||||||
|
if not location:IsCoordinateInZone(unitcoord) then
|
||||||
|
-- no we're not at the right spot
|
||||||
|
self:_SendMessage("The requested cargo is not available in this zone!", 10, false, Group)
|
||||||
|
if not self.debug then return self end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- avoid crate spam
|
-- avoid crate spam
|
||||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitTypeCapabilities
|
||||||
local canloadcratesno = capabilities.cratelimit
|
local canloadcratesno = capabilities.cratelimit
|
||||||
@ -3853,7 +3881,9 @@ end
|
|||||||
-- @param #number PerCrateMass Mass in kg of each crate
|
-- @param #number PerCrateMass Mass in kg of each crate
|
||||||
-- @param #number Stock Number of buildable groups in stock. Nil for unlimited.
|
-- @param #number Stock Number of buildable groups in stock. Nil for unlimited.
|
||||||
-- @param #string SubCategory Name of sub-category (optional).
|
-- @param #string SubCategory Name of sub-category (optional).
|
||||||
function CTLD:AddCratesCargo(Name,Templates,Type,NoCrates,PerCrateMass,Stock,SubCategory)
|
-- @param #boolean DontShowInMenu (optional) If set to "true" this won't show up in the menu.
|
||||||
|
-- @param Core.Zone#ZONE Location (optional) If set, the cargo item is **only** available here. Can be a #ZONE object or the name of a zone as #string.
|
||||||
|
function CTLD:AddCratesCargo(Name,Templates,Type,NoCrates,PerCrateMass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
self:T(self.lid .. " AddCratesCargo")
|
self:T(self.lid .. " AddCratesCargo")
|
||||||
if not self:_CheckTemplates(Templates) then
|
if not self:_CheckTemplates(Templates) then
|
||||||
self:E(self.lid .. "Crates Cargo for " .. Name .. " has missing template(s)!" )
|
self:E(self.lid .. "Crates Cargo for " .. Name .. " has missing template(s)!" )
|
||||||
@ -3861,7 +3891,7 @@ function CTLD:AddCratesCargo(Name,Templates,Type,NoCrates,PerCrateMass,Stock,Sub
|
|||||||
end
|
end
|
||||||
self.CargoCounter = self.CargoCounter + 1
|
self.CargoCounter = self.CargoCounter + 1
|
||||||
-- Crates are not directly loadable
|
-- Crates are not directly loadable
|
||||||
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Templates,Type,false,false,NoCrates,nil,nil,PerCrateMass,Stock,SubCategory)
|
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Templates,Type,false,false,NoCrates,nil,nil,PerCrateMass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
table.insert(self.Cargo_Crates,cargo)
|
table.insert(self.Cargo_Crates,cargo)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -3872,13 +3902,15 @@ end
|
|||||||
-- @param #number Mass Mass in kg of each static in kg, e.g. 100.
|
-- @param #number Mass Mass in kg of each static in kg, e.g. 100.
|
||||||
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
||||||
-- @param #string SubCategory Name of sub-category (optional).
|
-- @param #string SubCategory Name of sub-category (optional).
|
||||||
function CTLD:AddStaticsCargo(Name,Mass,Stock,SubCategory)
|
-- @param #boolean DontShowInMenu (optional) If set to "true" this won't show up in the menu.
|
||||||
|
-- @param Core.Zone#ZONE Location (optional) If set, the cargo item is **only** available here. Can be a #ZONE object or the name of a zone as #string.
|
||||||
|
function CTLD:AddStaticsCargo(Name,Mass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
self:T(self.lid .. " AddStaticsCargo")
|
self:T(self.lid .. " AddStaticsCargo")
|
||||||
self.CargoCounter = self.CargoCounter + 1
|
self.CargoCounter = self.CargoCounter + 1
|
||||||
local type = CTLD_CARGO.Enum.STATIC
|
local type = CTLD_CARGO.Enum.STATIC
|
||||||
local template = STATIC:FindByName(Name,true):GetTypeName()
|
local template = STATIC:FindByName(Name,true):GetTypeName()
|
||||||
-- Crates are not directly loadable
|
-- Crates are not directly loadable
|
||||||
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,template,type,false,false,1,nil,nil,Mass,Stock,SubCategory)
|
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,template,type,false,false,1,nil,nil,Mass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
table.insert(self.Cargo_Statics,cargo)
|
table.insert(self.Cargo_Statics,cargo)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -3908,7 +3940,9 @@ end
|
|||||||
-- @param #number PerCrateMass Mass in kg of each crate
|
-- @param #number PerCrateMass Mass in kg of each crate
|
||||||
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
-- @param #number Stock Number of groups in stock. Nil for unlimited.
|
||||||
-- @param #string SubCategory Name of the sub-category (optional).
|
-- @param #string SubCategory Name of the sub-category (optional).
|
||||||
function CTLD:AddCratesRepair(Name,Template,Type,NoCrates, PerCrateMass,Stock,SubCategory)
|
-- @param #boolean DontShowInMenu (optional) If set to "true" this won't show up in the menu.
|
||||||
|
-- @param Core.Zone#ZONE Location (optional) If set, the cargo item is **only** available here. Can be a #ZONE object or the name of a zone as #string.
|
||||||
|
function CTLD:AddCratesRepair(Name,Template,Type,NoCrates, PerCrateMass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
self:T(self.lid .. " AddCratesRepair")
|
self:T(self.lid .. " AddCratesRepair")
|
||||||
if not self:_CheckTemplates(Template) then
|
if not self:_CheckTemplates(Template) then
|
||||||
self:E(self.lid .. "Repair Cargo for " .. Name .. " has a missing template!" )
|
self:E(self.lid .. "Repair Cargo for " .. Name .. " has a missing template!" )
|
||||||
@ -3916,7 +3950,7 @@ function CTLD:AddCratesRepair(Name,Template,Type,NoCrates, PerCrateMass,Stock,Su
|
|||||||
end
|
end
|
||||||
self.CargoCounter = self.CargoCounter + 1
|
self.CargoCounter = self.CargoCounter + 1
|
||||||
-- Crates are not directly loadable
|
-- Crates are not directly loadable
|
||||||
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Template,Type,false,false,NoCrates,nil,nil,PerCrateMass,Stock,SubCategory)
|
local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Template,Type,false,false,NoCrates,nil,nil,PerCrateMass,Stock,SubCategory,DontShowInMenu,Location)
|
||||||
table.insert(self.Cargo_Crates,cargo)
|
table.insert(self.Cargo_Crates,cargo)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user