mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
- Transport - Respawn
This commit is contained in:
parent
fa3e387dd1
commit
3c6e8d6d01
@ -525,7 +525,7 @@ function OPSGROUP:New(group)
|
|||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("InUtero", "Spawned", "Spawned") -- The whole group was spawned.
|
self:AddTransition("InUtero", "Spawned", "Spawned") -- The whole group was spawned.
|
||||||
self:AddTransition("*", "Respawn", "*") -- Respawn group.
|
self:AddTransition("*", "Respawn", "InUtero") -- Respawn group.
|
||||||
self:AddTransition("*", "Dead", "Dead") -- The whole group is dead.
|
self:AddTransition("*", "Dead", "Dead") -- The whole group is dead.
|
||||||
self:AddTransition("*", "InUtero", "InUtero") -- Deactivated group goes back to mummy.
|
self:AddTransition("*", "InUtero", "InUtero") -- Deactivated group goes back to mummy.
|
||||||
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
self:AddTransition("*", "Stop", "Stopped") -- Stop FSM.
|
||||||
@ -4473,7 +4473,7 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
-- @param #OPSGROUP.Element Element The flight group element.
|
-- @param #OPSGROUP.Element Element The flight group element.
|
||||||
function OPSGROUP:onafterElementInUtero(From, Event, To, Element)
|
function OPSGROUP:onafterElementInUtero(From, Event, To, Element)
|
||||||
self:I(self.lid..string.format("Element in utero %s", Element.name))
|
self:T(self.lid..string.format("Element in utero %s", Element.name))
|
||||||
|
|
||||||
-- Set element status.
|
-- Set element status.
|
||||||
self:_UpdateStatus(Element, OPSGROUP.ElementStatus.INUTERO)
|
self:_UpdateStatus(Element, OPSGROUP.ElementStatus.INUTERO)
|
||||||
@ -4503,9 +4503,6 @@ function OPSGROUP:onafterElementDestroyed(From, Event, To, Element)
|
|||||||
-- Element is dead.
|
-- Element is dead.
|
||||||
self:ElementDead(Element)
|
self:ElementDead(Element)
|
||||||
|
|
||||||
-- Set element status.
|
|
||||||
--self:_UpdateStatus(Element, OPSGROUP.ElementStatus.DEAD)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "ElementDead" event.
|
--- On after "ElementDead" event.
|
||||||
@ -4555,19 +4552,24 @@ function OPSGROUP:onafterElementDead(From, Event, To, Element)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Check cargo bay and declare cargo groups dead.
|
-- Clear cargo bay of element.
|
||||||
for _,_element in pairs(self.elements) do
|
--for _,_cargo in pairs(Element.cargoBay) do
|
||||||
local element=_element --#OPSGROUP.Element
|
for i=#Element.cargoBay,1,-1 do
|
||||||
for _,_cargo in pairs(element.cargoBay) do
|
local cargo=Element.cargoBay[i] --#OPSGROUP.MyCargo --_cargo --#OPSGROUP.MyCargo
|
||||||
local cargo=_cargo --#OPSGROUP.MyCargo
|
|
||||||
|
-- Remove from cargo bay.
|
||||||
|
self:_DelCargobay(cargo.group)
|
||||||
|
|
||||||
if cargo.group and not (cargo.group:IsDead() or cargo.group:IsStopped()) then
|
if cargo.group and not (cargo.group:IsDead() or cargo.group:IsStopped()) then
|
||||||
|
|
||||||
-- Remove my carrier
|
-- Remove my carrier
|
||||||
cargo.group:_RemoveMyCarrier()
|
cargo.group:_RemoveMyCarrier()
|
||||||
|
|
||||||
if cargo.reserved then
|
if cargo.reserved then
|
||||||
|
|
||||||
-- This group was not loaded yet ==> Not cargo any more.
|
-- This group was not loaded yet ==> Not cargo any more.
|
||||||
cargo.group.cargoStatus=OPSGROUP.CargoStatus.NOTCARGO
|
cargo.group.cargoStatus=OPSGROUP.CargoStatus.NOTCARGO
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Carrier dead ==> cargo dead.
|
-- Carrier dead ==> cargo dead.
|
||||||
@ -4584,7 +4586,6 @@ function OPSGROUP:onafterElementDead(From, Event, To, Element)
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -4596,14 +4597,15 @@ end
|
|||||||
-- @param #table Template The template used to respawn the group. Default is the inital template of the group.
|
-- @param #table Template The template used to respawn the group. Default is the inital template of the group.
|
||||||
function OPSGROUP:onafterRespawn(From, Event, To, Template)
|
function OPSGROUP:onafterRespawn(From, Event, To, Template)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
self:I(self.lid.."Respawning group!")
|
self:I(self.lid.."Respawning group!")
|
||||||
|
|
||||||
|
-- Copy template.
|
||||||
local template=UTILS.DeepCopy(Template or self.template)
|
local template=UTILS.DeepCopy(Template or self.template)
|
||||||
|
|
||||||
|
-- Late activation off.
|
||||||
template.lateActivation=false
|
template.lateActivation=false
|
||||||
|
|
||||||
--self.respawning=true
|
|
||||||
|
|
||||||
self:_Respawn(0, template)
|
self:_Respawn(0, template)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -4686,11 +4688,7 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Debug output.
|
-- Debug output.
|
||||||
self:I({Template=Template})
|
self:T({Template=Template})
|
||||||
|
|
||||||
--if self:IsStopped() then
|
|
||||||
--self:InitWaypoints()
|
|
||||||
--end
|
|
||||||
|
|
||||||
-- Spawn new group.
|
-- Spawn new group.
|
||||||
_DATABASE:Spawn(Template)
|
_DATABASE:Spawn(Template)
|
||||||
@ -4699,6 +4697,10 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
|||||||
self.isLateActivated=Template.lateActivation
|
self.isLateActivated=Template.lateActivation
|
||||||
self.isUncontrolled=Template.uncontrolled
|
self.isUncontrolled=Template.uncontrolled
|
||||||
|
|
||||||
|
-- Not dead or destroyed any more.
|
||||||
|
self.isDead=false
|
||||||
|
self.isDestroyed=false
|
||||||
|
self.Ndestroyed=0
|
||||||
|
|
||||||
-- Reset events.
|
-- Reset events.
|
||||||
--self:ResetEvents()
|
--self:ResetEvents()
|
||||||
@ -4783,7 +4785,9 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function OPSGROUP:onbeforeStop(From, Event, To)
|
function OPSGROUP:onbeforeStop(From, Event, To)
|
||||||
|
|
||||||
|
-- We check if
|
||||||
if self:IsAlive() then
|
if self:IsAlive() then
|
||||||
|
self:E(self.lid..string.format("WARNING: Group is still alive! Will not stop the FSM. Use :Despawn() instead"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -4849,7 +4853,7 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
|
|
||||||
-- Cargo bay debug info.
|
-- Cargo bay debug info.
|
||||||
-- Check cargo bay and declare cargo groups dead.
|
-- Check cargo bay and declare cargo groups dead.
|
||||||
if self.verbose>=0 then
|
if self.verbose>=1 then
|
||||||
local text=""
|
local text=""
|
||||||
for _,_element in pairs(self.elements) do
|
for _,_element in pairs(self.elements) do
|
||||||
local element=_element --#OPSGROUP.Element
|
local element=_element --#OPSGROUP.Element
|
||||||
@ -4858,9 +4862,10 @@ function OPSGROUP:_CheckCargoTransport()
|
|||||||
text=text..string.format("\n- %s in carrier %s, reserved=%s", tostring(cargo.group:GetName()), tostring(element.name), tostring(cargo.reserved))
|
text=text..string.format("\n- %s in carrier %s, reserved=%s", tostring(cargo.group:GetName()), tostring(element.name), tostring(cargo.reserved))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if text~="" then
|
if text=="" then
|
||||||
self:I(self.lid.."Cargo bay:"..text)
|
text=" empty"
|
||||||
end
|
end
|
||||||
|
self:I(self.lid.."Cargo bay:"..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Cargo queue debug info.
|
-- Cargo queue debug info.
|
||||||
@ -5111,46 +5116,14 @@ function OPSGROUP:_DelCargobay(CargoGroup)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get cargo bay info.
|
||||||
--[[
|
|
||||||
local MyCarrierGroup, MyCarrierElement, MyIsReserved=CargoGroup:_GetMyCarrier()
|
|
||||||
|
|
||||||
if MyCarrierGroup and MyCarrierGroup.groupname==self.groupname then
|
|
||||||
if not IsReserved then
|
|
||||||
|
|
||||||
-- Reduce carrier weight.
|
|
||||||
local weight=CargoGroup:GetWeightTotal()
|
|
||||||
|
|
||||||
self:RedWeightCargo(CarrierElement.name, weight)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
-- Loop over elements and their cargo bay items.
|
|
||||||
--[[
|
|
||||||
local CarrierElement=nil --#OPSGROUP.Element
|
|
||||||
local cargobayIndex=nil
|
|
||||||
local reserved=nil
|
|
||||||
for i,_element in pairs(self.elements) do
|
|
||||||
local element=_element --#OPSGROUP.Element
|
|
||||||
for j,_cargo in pairs(element.cargoBay) do
|
|
||||||
local cargo=_cargo --#OPSGROUP.MyCargo
|
|
||||||
if cargo.group and cargo.group.groupname==CargoGroup.groupname then
|
|
||||||
CarrierElement=element
|
|
||||||
cargobayIndex=j
|
|
||||||
reserved=cargo.reserved
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
|
|
||||||
local cargoBayItem, cargoBayIndex, CarrierElement=self:_GetCargobay(CargoGroup)
|
local cargoBayItem, cargoBayIndex, CarrierElement=self:_GetCargobay(CargoGroup)
|
||||||
|
|
||||||
if cargoBayItem and cargoBayIndex then
|
if cargoBayItem and cargoBayIndex then
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Removing cargo group %s from cargo bay (index=%d) of carrier %s", CargoGroup:GetName(), cargoBayIndex, CarrierElement.name))
|
||||||
|
|
||||||
-- Remove
|
-- Remove
|
||||||
table.remove(CarrierElement.cargoBay, cargoBayIndex)
|
table.remove(CarrierElement.cargoBay, cargoBayIndex)
|
||||||
|
|
||||||
@ -5163,7 +5136,7 @@ function OPSGROUP:_DelCargobay(CargoGroup)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
env.error(self.lid.."ERROR: Group is not in cargo bay. Cannot remove it!")
|
self:E(self.lid.."ERROR: Group is not in cargo bay. Cannot remove it!")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -5320,13 +5293,18 @@ end
|
|||||||
-- @return #number Free cargo bay in kg.
|
-- @return #number Free cargo bay in kg.
|
||||||
function OPSGROUP:GetFreeCargobay(UnitName, IncludeReserved)
|
function OPSGROUP:GetFreeCargobay(UnitName, IncludeReserved)
|
||||||
|
|
||||||
|
-- Max cargo weight.
|
||||||
local weightCargoMax=self:GetWeightCargoMax(UnitName)
|
local weightCargoMax=self:GetWeightCargoMax(UnitName)
|
||||||
|
|
||||||
|
-- Current cargo weight.
|
||||||
local weightCargo=self:GetWeightCargo(UnitName, IncludeReserved)
|
local weightCargo=self:GetWeightCargo(UnitName, IncludeReserved)
|
||||||
|
|
||||||
|
-- Free cargo.
|
||||||
local Free=weightCargoMax-weightCargo
|
local Free=weightCargoMax-weightCargo
|
||||||
|
|
||||||
self:I(self.lid..string.format("Free cargo bay=%d kg (unit=%s)", Free, (UnitName or "whole group")))
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Free cargo bay=%d kg (unit=%s)", Free, (UnitName or "whole group")))
|
||||||
|
|
||||||
return Free
|
return Free
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -5368,6 +5346,7 @@ end
|
|||||||
-- @return #number Cargo weight in kg.
|
-- @return #number Cargo weight in kg.
|
||||||
function OPSGROUP:GetWeightCargo(UnitName, IncludeReserved)
|
function OPSGROUP:GetWeightCargo(UnitName, IncludeReserved)
|
||||||
|
|
||||||
|
-- Calculate weight based on actual cargo weight.
|
||||||
local weight=0
|
local weight=0
|
||||||
for _,_element in pairs(self.elements) do
|
for _,_element in pairs(self.elements) do
|
||||||
local element=_element --#OPSGROUP.Element
|
local element=_element --#OPSGROUP.Element
|
||||||
@ -5380,6 +5359,7 @@ function OPSGROUP:GetWeightCargo(UnitName, IncludeReserved)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Calculate weight from stuff in cargo bay. By default this includes the reserved weight if a cargo group was assigned and is currently boarding.
|
||||||
local gewicht=0
|
local gewicht=0
|
||||||
for _,_element in pairs(self.elements) do
|
for _,_element in pairs(self.elements) do
|
||||||
local element=_element --#OPSGROUP.Element
|
local element=_element --#OPSGROUP.Element
|
||||||
@ -5387,13 +5367,20 @@ function OPSGROUP:GetWeightCargo(UnitName, IncludeReserved)
|
|||||||
for _,_cargo in pairs(element.cargoBay) do
|
for _,_cargo in pairs(element.cargoBay) do
|
||||||
local cargo=_cargo --#OPSGROUP.MyCargo
|
local cargo=_cargo --#OPSGROUP.MyCargo
|
||||||
if (not cargo.reserved) or (cargo.reserved==true and (IncludeReserved==true or IncludeReserved==nil)) then
|
if (not cargo.reserved) or (cargo.reserved==true and (IncludeReserved==true or IncludeReserved==nil)) then
|
||||||
gewicht=gewicht+cargo.group:GetWeightTotal()
|
local cargoweight=cargo.group:GetWeightTotal()
|
||||||
|
gewicht=gewicht+cargoweight
|
||||||
|
--self:I(self.lid..string.format("unit=%s (reserved=%s): cargo=%s weight=%d, total weight=%d", tostring(UnitName), tostring(IncludeReserved), cargo.group:GetName(), cargoweight, weight))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T2(self.lid..string.format("Unit=%s (reserved=%s): weight=%d, gewicht=%d", tostring(UnitName), tostring(IncludeReserved), weight, gewicht))
|
||||||
|
|
||||||
|
-- Quick check.
|
||||||
if IncludeReserved==false and gewicht~=weight then
|
if IncludeReserved==false and gewicht~=weight then
|
||||||
self:I(self.lid..string.format("ERROR: FF weight!=gewicht: weight=%.1f, gewicht=%.1f", weight, gewicht))
|
self:E(self.lid..string.format("ERROR: FF weight!=gewicht: weight=%.1f, gewicht=%.1f", weight, gewicht))
|
||||||
end
|
end
|
||||||
|
|
||||||
return gewicht
|
return gewicht
|
||||||
@ -5434,7 +5421,7 @@ function OPSGROUP:AddWeightCargo(UnitName, Weight)
|
|||||||
element.weightCargo=element.weightCargo+Weight
|
element.weightCargo=element.weightCargo+Weight
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("FF %s: Adding %.1f kg cargo weight. New cargo weight=%.1f kg", UnitName, Weight, element.weightCargo))
|
self:T(self.lid..string.format("%s: Adding %.1f kg cargo weight. New cargo weight=%.1f kg", UnitName, Weight, element.weightCargo))
|
||||||
|
|
||||||
-- For airborne units, we set the weight in game.
|
-- For airborne units, we set the weight in game.
|
||||||
if self.isFlightgroup then
|
if self.isFlightgroup then
|
||||||
@ -5516,7 +5503,7 @@ end
|
|||||||
function OPSGROUP:_SetMyCarrier(CarrierGroup, CarrierElement, Reserved)
|
function OPSGROUP:_SetMyCarrier(CarrierGroup, CarrierElement, Reserved)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Setting My Carrier: %s (%s), reserved=%s", CarrierGroup:GetName(), tostring(CarrierElement.name), tostring(Reserved)))
|
self:T(self.lid..string.format("Setting My Carrier: %s (%s), reserved=%s", CarrierGroup:GetName(), tostring(CarrierElement.name), tostring(Reserved)))
|
||||||
|
|
||||||
self.mycarrier.group=CarrierGroup
|
self.mycarrier.group=CarrierGroup
|
||||||
self.mycarrier.element=CarrierElement
|
self.mycarrier.element=CarrierElement
|
||||||
@ -5572,6 +5559,7 @@ end
|
|||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
function OPSGROUP:_RemoveMyCarrier()
|
function OPSGROUP:_RemoveMyCarrier()
|
||||||
|
self:I(self.lid..string.format("Removing my carrier!"))
|
||||||
self.mycarrier.group=nil
|
self.mycarrier.group=nil
|
||||||
self.mycarrier.element=nil
|
self.mycarrier.element=nil
|
||||||
self.mycarrier.reserved=nil
|
self.mycarrier.reserved=nil
|
||||||
@ -5636,8 +5624,6 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
|||||||
-- Add waypoint.
|
-- Add waypoint.
|
||||||
if self.isFlightgroup then
|
if self.isFlightgroup then
|
||||||
|
|
||||||
env.info("FF pickup is flightgroup")
|
|
||||||
|
|
||||||
if airbasePickup then
|
if airbasePickup then
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -5651,14 +5637,11 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
|||||||
|
|
||||||
-- Activate uncontrolled group.
|
-- Activate uncontrolled group.
|
||||||
if self:IsParking() then
|
if self:IsParking() then
|
||||||
env.info("FF pickup start uncontrolled while parking at current airbase")
|
|
||||||
self:StartUncontrolled()
|
self:StartUncontrolled()
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
env.info("FF pickup land at airbase")
|
|
||||||
|
|
||||||
-- Order group to land at an airbase.
|
-- Order group to land at an airbase.
|
||||||
self:LandAtAirbase(airbasePickup)
|
self:LandAtAirbase(airbasePickup)
|
||||||
|
|
||||||
@ -5670,11 +5653,8 @@ function OPSGROUP:onafterPickup(From, Event, To)
|
|||||||
-- Helo can also land in a zone (NOTE: currently VTOL cannot!)
|
-- Helo can also land in a zone (NOTE: currently VTOL cannot!)
|
||||||
---
|
---
|
||||||
|
|
||||||
env.info("FF pickup helo addwaypoint")
|
|
||||||
|
|
||||||
-- Activate uncontrolled group.
|
-- Activate uncontrolled group.
|
||||||
if self:IsParking() then
|
if self:IsParking() then
|
||||||
env.info("FF pickup start uncontrolled while parking airbase")
|
|
||||||
self:StartUncontrolled()
|
self:StartUncontrolled()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -5809,6 +5789,7 @@ end
|
|||||||
-- @param #OPSGROUP CargoGroup The OPSGROUP loaded as cargo.
|
-- @param #OPSGROUP CargoGroup The OPSGROUP loaded as cargo.
|
||||||
-- @param #OPSGROUP.Element Carrier The carrier element/unit.
|
-- @param #OPSGROUP.Element Carrier The carrier element/unit.
|
||||||
function OPSGROUP:onafterLoad(From, Event, To, CargoGroup, Carrier)
|
function OPSGROUP:onafterLoad(From, Event, To, CargoGroup, Carrier)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Loading group %s", tostring(CargoGroup.groupname)))
|
self:I(self.lid..string.format("Loading group %s", tostring(CargoGroup.groupname)))
|
||||||
|
|
||||||
@ -5904,6 +5885,7 @@ end
|
|||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function OPSGROUP:onafterTransport(From, Event, To)
|
function OPSGROUP:onafterTransport(From, Event, To)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("New carrier status: %s --> %s", self.carrierStatus, OPSGROUP.CarrierStatus.TRANSPORTING))
|
self:I(self.lid..string.format("New carrier status: %s --> %s", self.carrierStatus, OPSGROUP.CarrierStatus.TRANSPORTING))
|
||||||
|
|
||||||
@ -6107,7 +6089,7 @@ function OPSGROUP:onafterUnloading(From, Event, To)
|
|||||||
---
|
---
|
||||||
|
|
||||||
-- Issue warning.
|
-- Issue warning.
|
||||||
env.info("ERROR: Deploy/disembark zone is a ZONE_AIRBASE of a ship! Where to put the cargo? Dumping into the sea, sorry!")
|
self:E(self.lid.."ERROR: Deploy/disembark zone is a ZONE_AIRBASE of a ship! Where to put the cargo? Dumping into the sea, sorry!")
|
||||||
--TODO: Dumb into sea.
|
--TODO: Dumb into sea.
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -6479,7 +6461,6 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
|||||||
|
|
||||||
-- Set carrier. As long as the group is not loaded, we only reserve the cargo space.´
|
-- Set carrier. As long as the group is not loaded, we only reserve the cargo space.´
|
||||||
CarrierGroup:_AddCargobay(self, Carrier, true)
|
CarrierGroup:_AddCargobay(self, Carrier, true)
|
||||||
--self:_SetMyCarrier(CarrierGroup, Carrier, true)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -32,9 +32,11 @@
|
|||||||
-- @field #table cargos Cargos. Each element is a @{Ops.OpsGroup#OPSGROUP.CargoGroup}.
|
-- @field #table cargos Cargos. Each element is a @{Ops.OpsGroup#OPSGROUP.CargoGroup}.
|
||||||
-- @field #table carriers Carriers assigned for this transport.
|
-- @field #table carriers Carriers assigned for this transport.
|
||||||
-- @field #number prio Priority of this transport. Should be a number between 0 (high prio) and 100 (low prio).
|
-- @field #number prio Priority of this transport. Should be a number between 0 (high prio) and 100 (low prio).
|
||||||
|
-- @field #boolean urgent If true, transport is urgent.
|
||||||
-- @field #number importance Importance of this transport. Smaller=higher.
|
-- @field #number importance Importance of this transport. Smaller=higher.
|
||||||
-- @field #number Tstart Start time in *abs.* seconds.
|
-- @field #number Tstart Start time in *abs.* seconds.
|
||||||
-- @field #number Tstop Stop time in *abs.* seconds. Default `#nil` (never stops).
|
-- @field #number Tstop Stop time in *abs.* seconds. Default `#nil` (never stops).
|
||||||
|
-- @field #number duration Duration (`Tstop-Tstart`) of the transport in seconds.
|
||||||
-- @field #table conditionStart Start conditions.
|
-- @field #table conditionStart Start conditions.
|
||||||
-- @field Core.Zone#ZONE pickupzone Zone where the cargo is picked up.
|
-- @field Core.Zone#ZONE pickupzone Zone where the cargo is picked up.
|
||||||
-- @field Core.Zone#ZONE deployzone Zone where the cargo is dropped off.
|
-- @field Core.Zone#ZONE deployzone Zone where the cargo is dropped off.
|
||||||
@ -70,7 +72,7 @@
|
|||||||
-- @field #OPSTRANSPORT
|
-- @field #OPSTRANSPORT
|
||||||
OPSTRANSPORT = {
|
OPSTRANSPORT = {
|
||||||
ClassName = "OPSTRANSPORT",
|
ClassName = "OPSTRANSPORT",
|
||||||
verbose = 1,
|
verbose = 0,
|
||||||
cargos = {},
|
cargos = {},
|
||||||
carriers = {},
|
carriers = {},
|
||||||
carrierTransportStatus = {},
|
carrierTransportStatus = {},
|
||||||
@ -108,12 +110,13 @@ _OPSTRANSPORTID=0
|
|||||||
|
|
||||||
--- Army Group version.
|
--- Army Group version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
OPSTRANSPORT.version="0.0.7"
|
OPSTRANSPORT.version="0.0.8"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- TODO: Stop/abort transport.
|
||||||
-- DONE: Add start conditions.
|
-- DONE: Add start conditions.
|
||||||
-- DONE: Check carrier(s) dead.
|
-- DONE: Check carrier(s) dead.
|
||||||
|
|
||||||
@ -140,7 +143,6 @@ function OPSTRANSPORT:New(GroupSet, Pickupzone, Deployzone)
|
|||||||
|
|
||||||
-- Defaults.
|
-- Defaults.
|
||||||
self.uid=_OPSTRANSPORTID
|
self.uid=_OPSTRANSPORTID
|
||||||
--self.status=OPSTRANSPORT.Status.PLANNING
|
|
||||||
|
|
||||||
self.pickupzone=Pickupzone
|
self.pickupzone=Pickupzone
|
||||||
self.deployzone=Deployzone
|
self.deployzone=Deployzone
|
||||||
@ -277,7 +279,8 @@ end
|
|||||||
-- @return #OPSTRANSPORT self
|
-- @return #OPSTRANSPORT self
|
||||||
function OPSTRANSPORT:SetDisembarkCarriers(Carriers)
|
function OPSTRANSPORT:SetDisembarkCarriers(Carriers)
|
||||||
|
|
||||||
self:I(self.lid.."Setting transfer carriers!")
|
-- Debug info.
|
||||||
|
self:T(self.lid.."Setting transfer carriers!")
|
||||||
|
|
||||||
-- Create table.
|
-- Create table.
|
||||||
self.disembarkCarriers=self.disembarkCarriers or {}
|
self.disembarkCarriers=self.disembarkCarriers or {}
|
||||||
@ -326,7 +329,8 @@ end
|
|||||||
-- @return #OPSTRANSPORT self
|
-- @return #OPSTRANSPORT self
|
||||||
function OPSTRANSPORT:SetRequiredCargos(Cargos)
|
function OPSTRANSPORT:SetRequiredCargos(Cargos)
|
||||||
|
|
||||||
self:I(self.lid.."Setting required cargos!")
|
-- Debug info.
|
||||||
|
self:T(self.lid.."Setting required cargos!")
|
||||||
|
|
||||||
-- Create table.
|
-- Create table.
|
||||||
self.requiredCargos=self.requiredCargos or {}
|
self.requiredCargos=self.requiredCargos or {}
|
||||||
@ -390,10 +394,10 @@ function OPSTRANSPORT:_DelCarrier(CarrierGroup)
|
|||||||
|
|
||||||
if self:IsCarrier(CarrierGroup) then
|
if self:IsCarrier(CarrierGroup) then
|
||||||
|
|
||||||
for i,_carrier in pairs(self.carriers) do
|
for i=#self.carriers,1,-1 do
|
||||||
local carrier=_carrier --Ops.OpsGroup#OPSGROUP
|
local carrier=self.carriers[i] --Ops.OpsGroup#OPSGROUP
|
||||||
if carrier.groupname==CarrierGroup.groupname then
|
if carrier.groupname==CarrierGroup.groupname then
|
||||||
self:I(self.lid..string.format("Removing carrier %s", CarrierGroup.groupname))
|
self:T(self.lid..string.format("Removing carrier %s", CarrierGroup.groupname))
|
||||||
table.remove(self.carriers, i)
|
table.remove(self.carriers, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -704,16 +708,22 @@ function OPSTRANSPORT:onafterStatus(From, Event, To)
|
|||||||
-- Current FSM state.
|
-- Current FSM state.
|
||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
|
|
||||||
|
if self.verbose>=1 then
|
||||||
|
|
||||||
-- Info text.
|
-- Info text.
|
||||||
local text=string.format("%s [%s --> %s]: Ncargo=%d/%d, Ncarrier=%d/%d", fsmstate:upper(), self.pickupzone:GetName(), self.deployzone:GetName(), self.Ncargo, self.Ndelivered, #self.carriers,self.Ncarrier)
|
local text=string.format("%s [%s --> %s]: Ncargo=%d/%d, Ncarrier=%d/%d", fsmstate:upper(), self.pickupzone:GetName(), self.deployzone:GetName(), self.Ncargo, self.Ndelivered, #self.carriers,self.Ncarrier)
|
||||||
|
|
||||||
|
-- Info about cargo and carrier.
|
||||||
|
if self.verbose>=2 then
|
||||||
|
|
||||||
text=text..string.format("\nCargos:")
|
text=text..string.format("\nCargos:")
|
||||||
for _,_cargo in pairs(self.cargos) do
|
for _,_cargo in pairs(self.cargos) do
|
||||||
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
local cargo=_cargo --Ops.OpsGroup#OPSGROUP.CargoGroup
|
||||||
local carrier=cargo.opsgroup:_GetMyCarrierElement()
|
local carrier=cargo.opsgroup:_GetMyCarrierElement()
|
||||||
local name=carrier and carrier.name or "none"
|
local name=carrier and carrier.name or "none"
|
||||||
local cstate=carrier and carrier.status or "N/A"
|
local cstate=carrier and carrier.status or "N/A"
|
||||||
text=text..string.format("\n- %s: %s [%s], weight=%d kg, carrier=%s [%s]", cargo.opsgroup:GetName(), cargo.opsgroup.cargoStatus:upper(), cargo.opsgroup:GetState(), cargo.opsgroup:GetWeightTotal(), name, cstate)
|
text=text..string.format("\n- %s: %s [%s], weight=%d kg, carrier=%s [%s], delivered=%s",
|
||||||
|
cargo.opsgroup:GetName(), cargo.opsgroup.cargoStatus:upper(), cargo.opsgroup:GetState(), cargo.opsgroup:GetWeightTotal(), name, cstate, tostring(cargo.delivered))
|
||||||
end
|
end
|
||||||
|
|
||||||
text=text..string.format("\nCarriers:")
|
text=text..string.format("\nCarriers:")
|
||||||
@ -724,8 +734,10 @@ function OPSTRANSPORT:onafterStatus(From, Event, To)
|
|||||||
carrier:GetWeightCargo(nil, false), carrier:GetWeightCargo(), carrier:GetWeightCargoMax(),
|
carrier:GetWeightCargo(nil, false), carrier:GetWeightCargo(), carrier:GetWeightCargoMax(),
|
||||||
carrier:GetFreeCargobay(nil, false), carrier:GetFreeCargobay(), carrier:GetFreeCargobayMax())
|
carrier:GetFreeCargobay(nil, false), carrier:GetFreeCargobay(), carrier:GetFreeCargobayMax())
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
end
|
||||||
|
|
||||||
-- Check if all cargo was delivered (or is dead).
|
-- Check if all cargo was delivered (or is dead).
|
||||||
self:_CheckDelivered()
|
self:_CheckDelivered()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user