mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1121 from FlightControl-Master/FF/Develop
AIBOSS v0.9.7
This commit is contained in:
commit
81b36ef37d
@ -1719,12 +1719,12 @@ WAREHOUSE.Quantity = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
--- Warehouse database. Note that this is a global array to have easier exchange between warehouses.
|
--- Warehouse database. Note that this is a global array to have easier exchange between warehouses.
|
||||||
-- @type WAREHOUSE.db
|
-- @type _WAREHOUSEDB
|
||||||
-- @field #number AssetID Unique ID of each asset. This is a running number, which is increased each time a new asset is added.
|
-- @field #number AssetID Unique ID of each asset. This is a running number, which is increased each time a new asset is added.
|
||||||
-- @field #table Assets Table holding registered assets, which are of type @{Functional.Warehouse#WAREHOUSE.Assetitem}.#
|
-- @field #table Assets Table holding registered assets, which are of type @{Functional.Warehouse#WAREHOUSE.Assetitem}.#
|
||||||
-- @field #number WarehouseID Unique ID of the warehouse. Running number.
|
-- @field #number WarehouseID Unique ID of the warehouse. Running number.
|
||||||
-- @field #table Warehouses Table holding all defined @{#WAREHOUSE} objects by their unique ids.
|
-- @field #table Warehouses Table holding all defined @{#WAREHOUSE} objects by their unique ids.
|
||||||
WAREHOUSE.db = {
|
_WAREHOUSEDB = {
|
||||||
AssetID = 0,
|
AssetID = 0,
|
||||||
Assets = {},
|
Assets = {},
|
||||||
WarehouseID = 0,
|
WarehouseID = 0,
|
||||||
@ -1733,7 +1733,7 @@ WAREHOUSE.db = {
|
|||||||
|
|
||||||
--- Warehouse class version.
|
--- Warehouse class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
WAREHOUSE.version="0.6.8"
|
WAREHOUSE.version="0.6.9"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO: Warehouse todo list.
|
-- TODO: Warehouse todo list.
|
||||||
@ -1835,10 +1835,10 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
self.warehouse=warehouse
|
self.warehouse=warehouse
|
||||||
|
|
||||||
-- Increase global warehouse counter.
|
-- Increase global warehouse counter.
|
||||||
WAREHOUSE.db.WarehouseID=WAREHOUSE.db.WarehouseID+1
|
_WAREHOUSEDB.WarehouseID=_WAREHOUSEDB.WarehouseID+1
|
||||||
|
|
||||||
-- Set unique ID for this warehouse.
|
-- Set unique ID for this warehouse.
|
||||||
self.uid=WAREHOUSE.db.WarehouseID
|
self.uid=_WAREHOUSEDB.WarehouseID
|
||||||
|
|
||||||
-- As Kalbuth found out, this would fail when using SPAWNSTATIC https://forums.eagle.ru/showthread.php?p=3703488#post3703488
|
-- As Kalbuth found out, this would fail when using SPAWNSTATIC https://forums.eagle.ru/showthread.php?p=3703488#post3703488
|
||||||
--self.uid=tonumber(warehouse:GetID())
|
--self.uid=tonumber(warehouse:GetID())
|
||||||
@ -1854,7 +1854,7 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
self.spawnzone=ZONE_RADIUS:New(string.format("Warehouse %s spawn zone", self.warehouse:GetName()), warehouse:GetVec2(), 250)
|
self.spawnzone=ZONE_RADIUS:New(string.format("Warehouse %s spawn zone", self.warehouse:GetName()), warehouse:GetVec2(), 250)
|
||||||
|
|
||||||
-- Add warehouse to database.
|
-- Add warehouse to database.
|
||||||
WAREHOUSE.db.Warehouses[self.uid]=self
|
_WAREHOUSEDB.Warehouses[self.uid]=self
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
--- FSM Transitions ---
|
--- FSM Transitions ---
|
||||||
@ -2933,7 +2933,7 @@ end
|
|||||||
-- @param #number uid The unique ID of the warehouse.
|
-- @param #number uid The unique ID of the warehouse.
|
||||||
-- @return #WAREHOUSE The warehouse object or nil if no warehouse exists.
|
-- @return #WAREHOUSE The warehouse object or nil if no warehouse exists.
|
||||||
function WAREHOUSE:FindWarehouseInDB(uid)
|
function WAREHOUSE:FindWarehouseInDB(uid)
|
||||||
return WAREHOUSE.db.Warehouses[uid]
|
return _WAREHOUSEDB.Warehouses[uid]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Find nearest warehouse in service, i.e. warehouses which are not started, stopped or destroyed are not considered.
|
--- Find nearest warehouse in service, i.e. warehouses which are not started, stopped or destroyed are not considered.
|
||||||
@ -2977,7 +2977,7 @@ function WAREHOUSE:FindNearestWarehouse(MinAssets, Descriptor, DescriptorValue,
|
|||||||
-- Loop over all warehouses.
|
-- Loop over all warehouses.
|
||||||
local nearest=nil
|
local nearest=nil
|
||||||
local distmin=nil
|
local distmin=nil
|
||||||
for wid,warehouse in pairs(WAREHOUSE.db.Warehouses) do
|
for wid,warehouse in pairs(_WAREHOUSEDB.Warehouses) do
|
||||||
local warehouse=warehouse --#WAREHOUSE
|
local warehouse=warehouse --#WAREHOUSE
|
||||||
|
|
||||||
-- Distance from this warehouse to the other warehouse.
|
-- Distance from this warehouse to the other warehouse.
|
||||||
@ -3029,7 +3029,7 @@ function WAREHOUSE:FindAssetInDB(group)
|
|||||||
|
|
||||||
if aid~=nil then
|
if aid~=nil then
|
||||||
|
|
||||||
local asset=WAREHOUSE.db.Assets[aid]
|
local asset=_WAREHOUSEDB.Assets[aid]
|
||||||
self:E({asset=asset})
|
self:E({asset=asset})
|
||||||
if asset==nil then
|
if asset==nil then
|
||||||
self:_ErrorMessage(string.format("ERROR: Asset for group %s not found in the data base!", group:GetName()), 0)
|
self:_ErrorMessage(string.format("ERROR: Asset for group %s not found in the data base!", group:GetName()), 0)
|
||||||
@ -3210,7 +3210,7 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function WAREHOUSE:onafterStatus(From, Event, To)
|
function WAREHOUSE:onafterStatus(From, Event, To)
|
||||||
self:I(self.wid..string.format("Checking status of warehouse %s. Current FSM state %s. Global warehouse assets = %d.", self.alias, self:GetState(), #WAREHOUSE.db.Assets))
|
self:I(self.wid..string.format("Checking status of warehouse %s. Current FSM state %s. Global warehouse assets = %d.", self.alias, self:GetState(), #_WAREHOUSEDB.Assets))
|
||||||
|
|
||||||
-- Check if any pending jobs are done and can be deleted from the
|
-- Check if any pending jobs are done and can be deleted from the
|
||||||
self:_JobDone()
|
self:_JobDone()
|
||||||
@ -3726,10 +3726,10 @@ function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay,
|
|||||||
local asset={} --#WAREHOUSE.Assetitem
|
local asset={} --#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
-- Increase asset unique id counter.
|
-- Increase asset unique id counter.
|
||||||
WAREHOUSE.db.AssetID=WAREHOUSE.db.AssetID+1
|
_WAREHOUSEDB.AssetID=_WAREHOUSEDB.AssetID+1
|
||||||
|
|
||||||
-- Set parameters.
|
-- Set parameters.
|
||||||
asset.uid=WAREHOUSE.db.AssetID
|
asset.uid=_WAREHOUSEDB.AssetID
|
||||||
asset.templatename=templategroupname
|
asset.templatename=templategroupname
|
||||||
asset.template=UTILS.DeepCopy(_DATABASE.Templates.Groups[templategroupname].Template)
|
asset.template=UTILS.DeepCopy(_DATABASE.Templates.Groups[templategroupname].Template)
|
||||||
asset.category=Category
|
asset.category=Category
|
||||||
@ -3755,7 +3755,7 @@ function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay,
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Add asset to global db.
|
-- Add asset to global db.
|
||||||
WAREHOUSE.db.Assets[asset.uid]=asset
|
_WAREHOUSEDB.Assets[asset.uid]=asset
|
||||||
|
|
||||||
-- Add asset to the table that is retured.
|
-- Add asset to the table that is retured.
|
||||||
table.insert(assets,asset)
|
table.insert(assets,asset)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -782,6 +782,14 @@ function UTILS.VecSubstract(a, b)
|
|||||||
return {x=a.x-b.x, y=a.y-b.y, z=a.z-b.z}
|
return {x=a.x-b.x, y=a.y-b.y, z=a.z-b.z}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Calculate the total vector of two 3D vectors by adding the x,y,z components of each other.
|
||||||
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
|
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||||
|
-- @return DCS#Vec3 Vector c=a+b with c(i)=a(i)+b(i), i=x,y,z.
|
||||||
|
function UTILS.VecAdd(a, b)
|
||||||
|
return {x=a.x+b.x, y=a.y+b.y, z=a.z+b.z}
|
||||||
|
end
|
||||||
|
|
||||||
--- Calculate the angle between two 3D vectors.
|
--- Calculate the angle between two 3D vectors.
|
||||||
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||||
@ -856,6 +864,16 @@ function UTILS.GetDCSMap()
|
|||||||
return env.mission.theatre
|
return env.mission.theatre
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the mission date. This is the date the mission started.
|
||||||
|
-- @return #string Mission date in yyyy/mm/dd format.
|
||||||
|
function UTILS.GetDCSMissionDate()
|
||||||
|
local year=tostring(env.mission.date.Year)
|
||||||
|
local month=tostring(env.mission.date.Month)
|
||||||
|
local day=tostring(env.mission.date.Day)
|
||||||
|
return string.format("%s/%s/%s", year, month, day)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the magnetic declination of the map.
|
--- Returns the magnetic declination of the map.
|
||||||
-- Returned values for the current maps are:
|
-- Returned values for the current maps are:
|
||||||
--
|
--
|
||||||
|
|||||||
@ -326,6 +326,7 @@ end
|
|||||||
-- To raise these events, provide the `GenerateEvent` parameter.
|
-- To raise these events, provide the `GenerateEvent` parameter.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #boolean GenerateEvent If true, a crash or dead event for each unit is generated. If false, if no event is triggered. If nil, a RemoveUnit event is triggered.
|
-- @param #boolean GenerateEvent If true, a crash or dead event for each unit is generated. If false, if no event is triggered. If nil, a RemoveUnit event is triggered.
|
||||||
|
-- @param #number delay Delay in seconds before despawning the group.
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Air unit example: destroy the Helicopter and generate a S_EVENT_CRASH for each unit in the Helicopter group.
|
-- -- Air unit example: destroy the Helicopter and generate a S_EVENT_CRASH for each unit in the Helicopter group.
|
||||||
-- Helicopter = GROUP:FindByName( "Helicopter" )
|
-- Helicopter = GROUP:FindByName( "Helicopter" )
|
||||||
@ -344,30 +345,35 @@ end
|
|||||||
-- Ship = GROUP:FindByName( "Boat" )
|
-- Ship = GROUP:FindByName( "Boat" )
|
||||||
-- Ship:Destroy( false ) -- Don't generate an event upon destruction.
|
-- Ship:Destroy( false ) -- Don't generate an event upon destruction.
|
||||||
--
|
--
|
||||||
function GROUP:Destroy( GenerateEvent )
|
function GROUP:Destroy( GenerateEvent, delay )
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
|
|
||||||
|
if delay and delay>0 then
|
||||||
|
SCHEDULER:New(nil, GROUP.Destroy, {self, GenerateEvent}, delay)
|
||||||
|
else
|
||||||
|
|
||||||
local DCSGroup = self:GetDCSObject()
|
local DCSGroup = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
for Index, UnitData in pairs( DCSGroup:getUnits() ) do
|
for Index, UnitData in pairs( DCSGroup:getUnits() ) do
|
||||||
if GenerateEvent and GenerateEvent == true then
|
if GenerateEvent and GenerateEvent == true then
|
||||||
if self:IsAir() then
|
if self:IsAir() then
|
||||||
self:CreateEventCrash( timer.getTime(), UnitData )
|
self:CreateEventCrash( timer.getTime(), UnitData )
|
||||||
|
else
|
||||||
|
self:CreateEventDead( timer.getTime(), UnitData )
|
||||||
|
end
|
||||||
|
elseif GenerateEvent == false then
|
||||||
|
-- Do nothing!
|
||||||
else
|
else
|
||||||
self:CreateEventDead( timer.getTime(), UnitData )
|
self:CreateEventRemoveUnit( timer.getTime(), UnitData )
|
||||||
end
|
end
|
||||||
elseif GenerateEvent == false then
|
|
||||||
-- Do nothing!
|
|
||||||
else
|
|
||||||
self:CreateEventRemoveUnit( timer.getTime(), UnitData )
|
|
||||||
end
|
end
|
||||||
|
USERFLAG:New( self:GetName() ):Set( 100 )
|
||||||
|
DCSGroup:destroy()
|
||||||
|
DCSGroup = nil
|
||||||
end
|
end
|
||||||
USERFLAG:New( self:GetName() ):Set( 100 )
|
|
||||||
DCSGroup:destroy()
|
|
||||||
DCSGroup = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user