mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
AUFTRAG and WAREHOUSE
- Added check for AUFTRAG that if it is executing and all groups are dead, it's done - Added check in WAREHOUSE find parking that units need to be alive
This commit is contained in:
@@ -7850,7 +7850,9 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
local _coord=unit:GetVec3()
|
local _coord=unit:GetVec3()
|
||||||
local _size=self:_GetObjectSize(unit:GetDCSObject())
|
local _size=self:_GetObjectSize(unit:GetDCSObject())
|
||||||
local _name=unit:GetName()
|
local _name=unit:GetName()
|
||||||
table.insert(obstacles, {coord=_coord, size=_size, name=_name, type="unit"})
|
if unit and unit:IsAlive() then
|
||||||
|
table.insert(obstacles, {coord=_coord, size=_size, name=_name, type="unit"})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check all statics.
|
-- Check all statics.
|
||||||
@@ -7892,6 +7894,9 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
|
|
||||||
-- Loop over all units - each one needs a spot.
|
-- Loop over all units - each one needs a spot.
|
||||||
for i=1,_asset.nunits do
|
for i=1,_asset.nunits do
|
||||||
|
|
||||||
|
-- Asset name
|
||||||
|
local assetname=_asset.spawngroupname.."-"..tostring(i)
|
||||||
|
|
||||||
-- Loop over all parking spots.
|
-- Loop over all parking spots.
|
||||||
local gotit=false
|
local gotit=false
|
||||||
@@ -7916,13 +7921,13 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
|
|
||||||
-- Spot is blocked.
|
-- Spot is blocked.
|
||||||
if not safe then
|
if not safe then
|
||||||
--env.info(string.format("FF asset=%s (id=%d): spot id=%d dist=%.1fm is NOT SAFE", _asset.templatename, _asset.uid, _termid, dist))
|
self:T3(self.lid..string.format("FF asset=%s (id=%d): spot id=%d dist=%.1fm is NOT SAFE", assetname, _asset.uid, _termid, dist))
|
||||||
free=false
|
free=false
|
||||||
problem=obstacle
|
problem=obstacle
|
||||||
problem.dist=dist
|
problem.dist=dist
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
--env.info(string.format("FF asset=%s (id=%d): spot id=%d dist=%.1fm is SAFE", _asset.templatename, _asset.uid, _termid, dist))
|
--env.info(string.format("FF asset=%s (id=%d): spot id=%d dist=%.1fm is SAFE", assetname, _asset.uid, _termid, dist))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -7934,32 +7939,36 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
table.insert(parking[_asset.uid], parkingspot)
|
table.insert(parking[_asset.uid], parkingspot)
|
||||||
|
|
||||||
-- Debug
|
-- Debug
|
||||||
self:T(self.lid..string.format("Parking spot %d is free for asset id=%d!", _termid, _asset.uid))
|
self:T(self.lid..string.format("Parking spot %d is free for asset %s [id=%d]!", _termid, assetname, _asset.uid))
|
||||||
|
|
||||||
-- Add the unit as obstacle so that this spot will not be available for the next unit.
|
-- Add the unit as obstacle so that this spot will not be available for the next unit.
|
||||||
table.insert(obstacles, {coord=_spot, size=_asset.size, name=_asset.templatename, type="asset"})
|
table.insert(obstacles, {coord=_spot, size=_asset.size, name=assetname, type="asset"})
|
||||||
|
|
||||||
gotit=true
|
gotit=true
|
||||||
break
|
break
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Debug output for occupied spots.
|
-- Debug output for occupied spots.
|
||||||
self:T(self.lid..string.format("Parking spot %d is occupied or not big enough!", _termid))
|
|
||||||
if self.Debug then
|
if self.Debug then
|
||||||
local coord=problem.coord --Core.Point#COORDINATE
|
local coord=problem.coord --Core.Point#COORDINATE
|
||||||
local text=string.format("Obstacle blocking spot #%d is %s type %s with size=%.1f m and distance=%.1f m.", _termid, problem.name, problem.type, problem.size, problem.dist)
|
local text=string.format("Obstacle %s [type=%s] blocking spot=%d! Size=%.1f m and distance=%.1f m.", problem.name, problem.type, _termid, problem.size, problem.dist)
|
||||||
|
self:I(self.lid..text)
|
||||||
coord:MarkToAll(string.format(text))
|
coord:MarkToAll(string.format(text))
|
||||||
|
else
|
||||||
|
self:T(self.lid..string.format("Parking spot %d is occupied or not big enough!", _termid))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
self:T2(self.lid..string.format("Terminal ID=%d: type=%s not supported", parkingspot.TerminalID, parkingspot.TerminalType))
|
||||||
end -- check terminal type
|
end -- check terminal type
|
||||||
end -- loop over parking spots
|
end -- loop over parking spots
|
||||||
|
|
||||||
-- No parking spot for at least one asset :(
|
-- No parking spot for at least one asset :(
|
||||||
if not gotit then
|
if not gotit then
|
||||||
self:I(self.lid..string.format("WARNING: No free parking spot for asset id=%d",_asset.uid))
|
self:I(self.lid..string.format("WARNING: No free parking spot for asset %s [id=%d]", assetname, _asset.uid))
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end -- loop over asset units
|
end -- loop over asset units
|
||||||
|
|||||||
@@ -3227,6 +3227,26 @@ function AUFTRAG:onafterStatus(From, Event, To)
|
|||||||
-- Cancel mission if mission targets are gone (if there were any in the beginning).
|
-- Cancel mission if mission targets are gone (if there were any in the beginning).
|
||||||
-- TODO: I commented this out for some reason but I forgot why...
|
-- TODO: I commented this out for some reason but I forgot why...
|
||||||
self:Cancel()
|
self:Cancel()
|
||||||
|
|
||||||
|
elseif self:IsExecuting() then
|
||||||
|
|
||||||
|
-- Had the case that mission was in state Executing but all assigned groups were dead.
|
||||||
|
-- TODO: might need to loop over all assigned groups
|
||||||
|
if Ngroups==0 then
|
||||||
|
self:Done()
|
||||||
|
else
|
||||||
|
local done=true
|
||||||
|
for groupname,data in pairs(self.groupdata or {}) do
|
||||||
|
local groupdata=data --#AUFTRAG.GroupData
|
||||||
|
local opsgroup=groupdata.opsgroup
|
||||||
|
if opsgroup:IsAlive() then
|
||||||
|
done=false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if done then
|
||||||
|
self:Done()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user