mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Finish Cargo/FC/Transport
This commit is contained in:
@@ -123,9 +123,7 @@ do -- ACT_ROUTE
|
|||||||
--- Set a Cancel Menu item.
|
--- Set a Cancel Menu item.
|
||||||
-- @param #ACT_ROUTE self
|
-- @param #ACT_ROUTE self
|
||||||
-- @return #ACT_ROUTE
|
-- @return #ACT_ROUTE
|
||||||
function ACT_ROUTE:SetMenuCancel( MenuGroup, MenuText, ParentMenu )
|
function ACT_ROUTE:SetMenuCancel( MenuGroup, MenuText, ParentMenu, MenuTime, MenuTag )
|
||||||
|
|
||||||
local MenuTime = timer.getTime() + 1
|
|
||||||
|
|
||||||
self.CancelMenuGroupCommand = MENU_GROUP_COMMAND:New(
|
self.CancelMenuGroupCommand = MENU_GROUP_COMMAND:New(
|
||||||
MenuGroup,
|
MenuGroup,
|
||||||
@@ -133,10 +131,11 @@ do -- ACT_ROUTE
|
|||||||
ParentMenu,
|
ParentMenu,
|
||||||
self.MenuCancel,
|
self.MenuCancel,
|
||||||
self
|
self
|
||||||
):SetTime( MenuTime )
|
):SetTime( MenuTime ):SetTag( MenuTag )
|
||||||
|
|
||||||
ParentMenu:SetTime( MenuTime )
|
ParentMenu:SetTime( MenuTime )
|
||||||
ParentMenu:Remove( MenuTime )
|
|
||||||
|
ParentMenu:Remove( MenuTime, MenuTag )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ do -- CARGO
|
|||||||
self:AddTransition( "*", "Damaged", "Damaged" )
|
self:AddTransition( "*", "Damaged", "Damaged" )
|
||||||
self:AddTransition( "*", "Destroyed", "Destroyed" )
|
self:AddTransition( "*", "Destroyed", "Destroyed" )
|
||||||
self:AddTransition( "*", "Respawn", "UnLoaded" )
|
self:AddTransition( "*", "Respawn", "UnLoaded" )
|
||||||
|
self:AddTransition( "*", "Reset", "UnLoaded" )
|
||||||
|
|
||||||
self.Type = Type
|
self.Type = Type
|
||||||
self.Name = Name
|
self.Name = Name
|
||||||
@@ -747,6 +748,22 @@ do -- CARGO
|
|||||||
self.Reported[CarrierGroup] = nil
|
self.Reported[CarrierGroup] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Respawn the cargo when destroyed
|
||||||
|
-- @param #CARGO self
|
||||||
|
-- @param #boolean RespawnDestroyed
|
||||||
|
function CARGO:RespawnOnDestroyed( RespawnDestroyed )
|
||||||
|
|
||||||
|
if RespawnDestroyed then
|
||||||
|
self.onenterDestroyed = function( self )
|
||||||
|
self:Respawn()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.onenterDestroyed = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end -- CARGO
|
end -- CARGO
|
||||||
|
|||||||
@@ -65,6 +65,33 @@ do -- CARGO_CRATE
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param #CARGO_CRATE self
|
||||||
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
|
function CARGO_CRATE:OnEventCargoDead( EventData )
|
||||||
|
|
||||||
|
local Destroyed = false
|
||||||
|
|
||||||
|
if self:IsDestroyed() or self:IsUnLoaded() or self:IsBoarding() then
|
||||||
|
if self.CargoObject:GetName() == EventData.IniUnitName then
|
||||||
|
Destroyed = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if self:IsLoaded() then
|
||||||
|
local CarrierName = self.CargoCarrier:GetName()
|
||||||
|
if CarrierName == EventData.IniDCSUnitName then
|
||||||
|
MESSAGE:New( "Cargo is lost from carrier " .. CarrierName, 15 ):ToAll()
|
||||||
|
Destroyed = true
|
||||||
|
self.CargoCarrier:ClearCargo()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if Destroyed then
|
||||||
|
self:I( { "Cargo crate destroyed: " .. self.CargoObject:GetName() } )
|
||||||
|
self:Destroyed()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Enter UnLoaded State.
|
--- Enter UnLoaded State.
|
||||||
@@ -90,7 +117,7 @@ do -- CARGO_CRATE
|
|||||||
|
|
||||||
-- Respawn the group...
|
-- Respawn the group...
|
||||||
if self.CargoObject then
|
if self.CargoObject then
|
||||||
self.CargoObject:ReSpawn( ToPointVec2, 0 )
|
self.CargoObject:ReSpawnAt( ToPointVec2, 0 )
|
||||||
self.CargoCarrier = nil
|
self.CargoCarrier = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -228,15 +255,39 @@ do -- CARGO_CRATE
|
|||||||
return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius )
|
return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the CargoGroup.
|
--- Respawn the CargoGroup.
|
||||||
-- @param #CARGO_CRATE self
|
-- @param #CARGO_CRATE self
|
||||||
function CARGO_CRATE:Respawn()
|
function CARGO_CRATE:Respawn()
|
||||||
|
|
||||||
self:F( { "Respawning" } )
|
self:F( { "Respawning crate " .. self:GetName() } )
|
||||||
|
|
||||||
|
|
||||||
|
-- Respawn the group...
|
||||||
|
if self.CargoObject then
|
||||||
|
self.CargoObject:ReSpawn() -- A cargo destroy crates a DEAD event.
|
||||||
|
self:__Reset( -0.1 )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Respawn the CargoGroup.
|
||||||
|
-- @param #CARGO_CRATE self
|
||||||
|
function CARGO_CRATE:onafterReset()
|
||||||
|
|
||||||
|
self:F( { "Reset crate " .. self:GetName() } )
|
||||||
|
|
||||||
|
|
||||||
|
-- Respawn the group...
|
||||||
|
if self.CargoObject then
|
||||||
|
self:SetDeployed( false )
|
||||||
|
self:SetStartState( "UnLoaded" )
|
||||||
|
self.CargoCarrier = nil
|
||||||
|
-- Cargo objects are added to the _DATABASE and SET_CARGO objects.
|
||||||
|
_EVENTDISPATCHER:CreateEventNewCargo( self )
|
||||||
|
end
|
||||||
|
|
||||||
self:SetDeployed( false )
|
|
||||||
self:SetStartState( "UnLoaded" )
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -38,82 +38,82 @@ do -- CARGO_GROUP
|
|||||||
ClassName = "CARGO_GROUP",
|
ClassName = "CARGO_GROUP",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- CARGO_GROUP constructor.
|
--- CARGO_GROUP constructor.
|
||||||
-- This make a new CARGO_GROUP from a @{Group} object.
|
-- This make a new CARGO_GROUP from a @{Group} object.
|
||||||
-- It will "ungroup" the group object within the sim, and will create a @{Set} of individual Unit objects.
|
-- It will "ungroup" the group object within the sim, and will create a @{Set} of individual Unit objects.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @param Wrapper.Group#GROUP CargoGroup
|
-- @param Wrapper.Group#GROUP CargoGroup
|
||||||
-- @param #string Type
|
-- @param #string Type
|
||||||
-- @param #string Name
|
-- @param #string Name
|
||||||
-- @param #number LoadRadius (optional)
|
-- @param #number LoadRadius (optional)
|
||||||
-- @param #number NearRadius (optional)
|
-- @param #number NearRadius (optional)
|
||||||
-- @return #CARGO_GROUP
|
-- @return #CARGO_GROUP
|
||||||
function CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius )
|
function CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius )
|
||||||
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( Type, Name, 0, LoadRadius ) ) -- #CARGO_GROUP
|
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( Type, Name, 0, LoadRadius ) ) -- #CARGO_GROUP
|
||||||
self:F( { Type, Name, LoadRadius } )
|
self:F( { Type, Name, LoadRadius } )
|
||||||
|
|
||||||
self.CargoSet = SET_CARGO:New()
|
self.CargoSet = SET_CARGO:New()
|
||||||
|
|
||||||
self:SetDeployed( false )
|
self:SetDeployed( false )
|
||||||
|
|
||||||
local WeightGroup = 0
|
local WeightGroup = 0
|
||||||
|
|
||||||
self.GroupName = CargoGroup:GetName()
|
self.GroupName = CargoGroup:GetName()
|
||||||
self.CargoTemplate = UTILS.DeepCopy( _DATABASE:GetGroupTemplate( self.GroupName ) )
|
self.CargoTemplate = UTILS.DeepCopy( _DATABASE:GetGroupTemplate( self.GroupName ) )
|
||||||
|
|
||||||
CargoGroup:Destroy()
|
CargoGroup:Destroy()
|
||||||
|
|
||||||
-- We iterate through the group template and for each unit in the template, we create a new group with one unit.
|
-- We iterate through the group template and for each unit in the template, we create a new group with one unit.
|
||||||
for UnitID, UnitTemplate in pairs( self.CargoTemplate.units ) do
|
for UnitID, UnitTemplate in pairs( self.CargoTemplate.units ) do
|
||||||
|
|
||||||
local GroupTemplate = UTILS.DeepCopy( self.CargoTemplate )
|
local GroupTemplate = UTILS.DeepCopy( self.CargoTemplate )
|
||||||
local GroupName = env.getValueDictByKey( GroupTemplate.name )
|
local GroupName = env.getValueDictByKey( GroupTemplate.name )
|
||||||
|
|
||||||
-- We create a new group object with one unit...
|
-- We create a new group object with one unit...
|
||||||
-- First we prepare the template...
|
-- First we prepare the template...
|
||||||
GroupTemplate.name = GroupName .. "#CARGO#" .. UnitID
|
GroupTemplate.name = GroupName .. "#CARGO#" .. UnitID
|
||||||
GroupTemplate.groupId = nil
|
GroupTemplate.groupId = nil
|
||||||
GroupTemplate.units = {}
|
GroupTemplate.units = {}
|
||||||
GroupTemplate.units[1] = UnitTemplate
|
GroupTemplate.units[1] = UnitTemplate
|
||||||
local UnitName = UnitTemplate.name .. "#CARGO"
|
local UnitName = UnitTemplate.name .. "#CARGO"
|
||||||
GroupTemplate.units[1].name = UnitTemplate.name .. "#CARGO"
|
GroupTemplate.units[1].name = UnitTemplate.name .. "#CARGO"
|
||||||
|
|
||||||
|
|
||||||
-- Then we register the new group in the database
|
-- Then we register the new group in the database
|
||||||
local CargoGroup = GROUP:NewTemplate( GroupTemplate, GroupTemplate.CoalitionID, GroupTemplate.CategoryID, GroupTemplate.CountryID)
|
local CargoGroup = GROUP:NewTemplate( GroupTemplate, GroupTemplate.CoalitionID, GroupTemplate.CategoryID, GroupTemplate.CountryID)
|
||||||
|
|
||||||
-- Now we spawn the new group based on the template created.
|
-- Now we spawn the new group based on the template created.
|
||||||
_DATABASE:Spawn( GroupTemplate )
|
_DATABASE:Spawn( GroupTemplate )
|
||||||
|
|
||||||
-- And we register the spawned unit as part of the CargoSet.
|
-- And we register the spawned unit as part of the CargoSet.
|
||||||
local Unit = UNIT:FindByName( UnitName )
|
local Unit = UNIT:FindByName( UnitName )
|
||||||
--local WeightUnit = Unit:GetDesc().massEmpty
|
--local WeightUnit = Unit:GetDesc().massEmpty
|
||||||
--WeightGroup = WeightGroup + WeightUnit
|
--WeightGroup = WeightGroup + WeightUnit
|
||||||
local CargoUnit = CARGO_UNIT:New( Unit, Type, UnitName, 10 )
|
local CargoUnit = CARGO_UNIT:New( Unit, Type, UnitName, 10 )
|
||||||
self.CargoSet:Add( UnitName, CargoUnit )
|
self.CargoSet:Add( UnitName, CargoUnit )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
self:SetWeight( WeightGroup )
|
||||||
|
self.CargoLimit = 10
|
||||||
|
|
||||||
|
self:T( { "Weight Cargo", WeightGroup } )
|
||||||
|
|
||||||
|
-- Cargo objects are added to the _DATABASE and SET_CARGO objects.
|
||||||
|
_EVENTDISPATCHER:CreateEventNewCargo( self )
|
||||||
|
|
||||||
|
self:HandleEvent( EVENTS.Dead, self.OnEventCargoDead )
|
||||||
|
self:HandleEvent( EVENTS.Crash, self.OnEventCargoDead )
|
||||||
|
self:HandleEvent( EVENTS.PlayerLeaveUnit, self.OnEventCargoDead )
|
||||||
|
|
||||||
|
self:SetEventPriority( 4 )
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param #CARGO_GROUP self
|
||||||
self:SetWeight( WeightGroup )
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
self.CargoLimit = 10
|
function CARGO_GROUP:OnEventCargoDead( EventData )
|
||||||
|
|
||||||
self:T( { "Weight Cargo", WeightGroup } )
|
|
||||||
|
|
||||||
-- Cargo objects are added to the _DATABASE and SET_CARGO objects.
|
|
||||||
_EVENTDISPATCHER:CreateEventNewCargo( self )
|
|
||||||
|
|
||||||
self:HandleEvent( EVENTS.Dead, self.OnEventCargoDead )
|
|
||||||
self:HandleEvent( EVENTS.Crash, self.OnEventCargoDead )
|
|
||||||
self:HandleEvent( EVENTS.PlayerLeaveUnit, self.OnEventCargoDead )
|
|
||||||
|
|
||||||
self:SetEventPriority( 4 )
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- @param #CARGO_GROUP self
|
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
|
||||||
function CARGO_GROUP:OnEventCargoDead( EventData )
|
|
||||||
|
|
||||||
local Destroyed = false
|
local Destroyed = false
|
||||||
|
|
||||||
@@ -364,22 +364,6 @@ function CARGO_GROUP:OnEventCargoDead( EventData )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the cargo when destroyed
|
|
||||||
-- @param #CARGO_GROUP self
|
|
||||||
-- @param #boolean RespawnDestroyed
|
|
||||||
function CARGO_GROUP:RespawnOnDestroyed( RespawnDestroyed )
|
|
||||||
self:F({"In function RespawnOnDestroyed"})
|
|
||||||
if RespawnDestroyed then
|
|
||||||
self.onenterDestroyed = function( self )
|
|
||||||
self:F("IN FUNCTION")
|
|
||||||
self:Respawn()
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.onenterDestroyed = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get the current Coordinate of the CargoGroup.
|
--- Get the current Coordinate of the CargoGroup.
|
||||||
-- @param #CARGO_GROUP self
|
-- @param #CARGO_GROUP self
|
||||||
-- @return Core.Point#COORDINATE The current Coordinate of the first Cargo of the CargoGroup.
|
-- @return Core.Point#COORDINATE The current Coordinate of the first Cargo of the CargoGroup.
|
||||||
|
|||||||
@@ -66,6 +66,26 @@ do -- CARGO_SLINGLOAD
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- @param #CARGO_SLINGLOAD self
|
||||||
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
|
function CARGO_SLINGLOAD:OnEventCargoDead( EventData )
|
||||||
|
|
||||||
|
local Destroyed = false
|
||||||
|
|
||||||
|
if self:IsDestroyed() or self:IsUnLoaded() then
|
||||||
|
if self.CargoObject:GetName() == EventData.IniUnitName then
|
||||||
|
Destroyed = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if Destroyed then
|
||||||
|
self:I( { "Cargo crate destroyed: " .. self.CargoObject:GetName() } )
|
||||||
|
self:Destroyed()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if the cargo can be Slingloaded.
|
--- Check if the cargo can be Slingloaded.
|
||||||
-- @param #CARGO self
|
-- @param #CARGO self
|
||||||
function CARGO:CanSlingload()
|
function CARGO:CanSlingload()
|
||||||
@@ -196,10 +216,35 @@ do -- CARGO_SLINGLOAD
|
|||||||
-- @param #CARGO_SLINGLOAD self
|
-- @param #CARGO_SLINGLOAD self
|
||||||
function CARGO_SLINGLOAD:Respawn()
|
function CARGO_SLINGLOAD:Respawn()
|
||||||
|
|
||||||
self:F( { "Respawning" } )
|
self:F( { "Respawning slingload " .. self:GetName() } )
|
||||||
|
|
||||||
|
|
||||||
|
-- Respawn the group...
|
||||||
|
if self.CargoObject then
|
||||||
|
self.CargoObject:ReSpawn() -- A cargo destroy crates a DEAD event.
|
||||||
|
self:__Reset( -0.1 )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Respawn the CargoGroup.
|
||||||
|
-- @param #CARGO_SLINGLOAD self
|
||||||
|
function CARGO_SLINGLOAD:onafterReset()
|
||||||
|
|
||||||
|
self:F( { "Reset slingload " .. self:GetName() } )
|
||||||
|
|
||||||
|
|
||||||
|
-- Respawn the group...
|
||||||
|
if self.CargoObject then
|
||||||
|
self:SetDeployed( false )
|
||||||
|
self:SetStartState( "UnLoaded" )
|
||||||
|
self.CargoCarrier = nil
|
||||||
|
-- Cargo objects are added to the _DATABASE and SET_CARGO objects.
|
||||||
|
_EVENTDISPATCHER:CreateEventNewCargo( self )
|
||||||
|
end
|
||||||
|
|
||||||
self:SetDeployed( false )
|
|
||||||
self:SetStartState( "UnLoaded" )
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ do -- CARGO_UNIT
|
|||||||
|
|
||||||
-- Respawn the group...
|
-- Respawn the group...
|
||||||
if self.CargoObject then
|
if self.CargoObject then
|
||||||
self.CargoObject:ReSpawn( FromPointVec2:GetVec3(), CargoDeployHeading )
|
self.CargoObject:ReSpawnAt( FromPointVec2, CargoDeployHeading )
|
||||||
self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
|
self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } )
|
||||||
self.CargoCarrier = nil
|
self.CargoCarrier = nil
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ do -- CARGO_UNIT
|
|||||||
|
|
||||||
-- Respawn the group...
|
-- Respawn the group...
|
||||||
if self.CargoObject then
|
if self.CargoObject then
|
||||||
self.CargoObject:ReSpawn( ToPointVec2:GetVec3(), 0 )
|
self.CargoObject:ReSpawnAt( ToPointVec2, 0 )
|
||||||
self.CargoCarrier = nil
|
self.CargoCarrier = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -794,6 +794,16 @@ function EVENT:onEvent( Event )
|
|||||||
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Event.IniObjectCategory == Object.Category.CARGO then
|
||||||
|
Event.IniDCSUnit = Event.initiator
|
||||||
|
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
||||||
|
Event.IniUnitName = Event.IniDCSUnitName
|
||||||
|
Event.IniUnit = CARGO:FindByName( Event.IniDCSUnitName )
|
||||||
|
Event.IniCoalition = Event.IniDCSUnit:getCoalition()
|
||||||
|
Event.IniCategory = Event.IniDCSUnit:getDesc().category
|
||||||
|
Event.IniTypeName = Event.IniDCSUnit:getTypeName()
|
||||||
|
end
|
||||||
|
|
||||||
if Event.IniObjectCategory == Object.Category.SCENERY then
|
if Event.IniObjectCategory == Object.Category.SCENERY then
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ do -- MENU_BASE
|
|||||||
self.Menus = {}
|
self.Menus = {}
|
||||||
self.MenuCount = 0
|
self.MenuCount = 0
|
||||||
self.MenuTime = timer.getTime()
|
self.MenuTime = timer.getTime()
|
||||||
|
self.MenuRemoveParent = false
|
||||||
|
|
||||||
if self.ParentMenu then
|
if self.ParentMenu then
|
||||||
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
||||||
@@ -226,15 +227,31 @@ do -- MENU_BASE
|
|||||||
if self.ParentMenu then
|
if self.ParentMenu then
|
||||||
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
self.ParentMenu.Menus = self.ParentMenu.Menus or {}
|
||||||
self.ParentMenu.Menus[MenuText] = Menu
|
self.ParentMenu.Menus[MenuText] = Menu
|
||||||
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MENU_BASE:ClearParentMenu( MenuText )
|
function MENU_BASE:ClearParentMenu( MenuText )
|
||||||
if self.ParentMenu and self.ParentMenu.Menus[MenuText] then
|
if self.ParentMenu and self.ParentMenu.Menus[MenuText] then
|
||||||
self.ParentMenu.Menus[MenuText] = nil
|
self.ParentMenu.Menus[MenuText] = nil
|
||||||
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
||||||
|
if self.ParentMenu.MenuCount == 0 then
|
||||||
|
--self.ParentMenu:Remove()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets a @{Menu} to remove automatically the parent menu when the menu removed is the last child menu of that parent @{Menu}.
|
||||||
|
-- @param #MENU_BASE self
|
||||||
|
-- @param #boolean RemoveParent If true, the parent menu is automatically removed when this menu is the last child menu of that parent @{Menu}.
|
||||||
|
-- @return #MENU_BASE
|
||||||
|
function MENU_BASE:SetRemoveParent( RemoveParent )
|
||||||
|
self:F( { RemoveParent } )
|
||||||
|
self.MenuRemoveParent = RemoveParent
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Gets a @{Menu} from a parent @{Menu}
|
--- Gets a @{Menu} from a parent @{Menu}
|
||||||
-- @param #MENU_BASE self
|
-- @param #MENU_BASE self
|
||||||
-- @param #string MenuText The text of the child menu.
|
-- @param #string MenuText The text of the child menu.
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ end
|
|||||||
-- @param Core.Base#BASE Object
|
-- @param Core.Base#BASE Object
|
||||||
-- @return Core.Base#BASE The added BASE Object.
|
-- @return Core.Base#BASE The added BASE Object.
|
||||||
function SET_BASE:Add( ObjectName, Object )
|
function SET_BASE:Add( ObjectName, Object )
|
||||||
self:F3( { ObjectName = ObjectName, Object = Object } )
|
self:F( { ObjectName = ObjectName, Object = Object } )
|
||||||
|
|
||||||
-- Ensure that the existing element is removed from the Set before a new one is inserted to the Set
|
-- Ensure that the existing element is removed from the Set before a new one is inserted to the Set
|
||||||
if self.Set[ObjectName] then
|
if self.Set[ObjectName] then
|
||||||
@@ -4349,7 +4349,7 @@ function SET_CARGO:IsIncludeObject( MCargo ) --R2.1
|
|||||||
MCargoCoalition = true
|
MCargoCoalition = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:T( { "Evaluated Coalition", MCargoCoalition } )
|
self:F( { "Evaluated Coalition", MCargoCoalition } )
|
||||||
MCargoInclude = MCargoInclude and MCargoCoalition
|
MCargoInclude = MCargoInclude and MCargoCoalition
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4361,7 +4361,7 @@ function SET_CARGO:IsIncludeObject( MCargo ) --R2.1
|
|||||||
MCargoType = true
|
MCargoType = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:T( { "Evaluated Type", MCargoType } )
|
self:F( { "Evaluated Type", MCargoType } )
|
||||||
MCargoInclude = MCargoInclude and MCargoType
|
MCargoInclude = MCargoInclude and MCargoType
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4373,7 +4373,7 @@ function SET_CARGO:IsIncludeObject( MCargo ) --R2.1
|
|||||||
MCargoPrefix = true
|
MCargoPrefix = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:T( { "Evaluated Prefix", MCargoPrefix } )
|
self:F( { "Evaluated Prefix", MCargoPrefix } )
|
||||||
MCargoInclude = MCargoInclude and MCargoPrefix
|
MCargoInclude = MCargoInclude and MCargoPrefix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -4387,6 +4387,8 @@ end
|
|||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function SET_CARGO:OnEventNewCargo( EventData ) --R2.1
|
function SET_CARGO:OnEventNewCargo( EventData ) --R2.1
|
||||||
|
|
||||||
|
self:F( { "New Cargo", EventData } )
|
||||||
|
|
||||||
if EventData.Cargo then
|
if EventData.Cargo then
|
||||||
if EventData.Cargo and self:IsIncludeObject( EventData.Cargo ) then
|
if EventData.Cargo and self:IsIncludeObject( EventData.Cargo ) then
|
||||||
self:Add( EventData.Cargo.Name , EventData.Cargo )
|
self:Add( EventData.Cargo.Name , EventData.Cargo )
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ function SPAWNSTATIC:NewFromType( SpawnTypeName, SpawnShapeName, SpawnCategory,
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Creates a new @{Static} at the original position.
|
--- Creates a new @{Static} at the original position.
|
||||||
-- @param #SPAWNSTATIC self
|
-- @param #SPAWNSTATIC self
|
||||||
-- @param #number Heading The heading of the static, which is a number in degrees from 0 to 360.
|
-- @param #number Heading The heading of the static, which is a number in degrees from 0 to 360.
|
||||||
@@ -192,6 +193,75 @@ function SPAWNSTATIC:SpawnFromPointVec2( PointVec2, Heading, NewName ) --R2.1
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Creates the original @{Static} at a POINT_VEC2.
|
||||||
|
-- @param #SPAWNSTATIC self
|
||||||
|
-- @param Core.Point#POINT_VEC2 PointVec2 The 2D coordinate where to spawn the static.
|
||||||
|
-- @param #number Heading The heading of the static, which is a number in degrees from 0 to 360.
|
||||||
|
-- @param #string (optional) The name of the new static.
|
||||||
|
-- @return #SPAWNSTATIC
|
||||||
|
function SPAWNSTATIC:ReSpawn()
|
||||||
|
|
||||||
|
local StaticTemplate = _DATABASE:GetStaticUnitTemplate( self.SpawnTemplatePrefix )
|
||||||
|
|
||||||
|
if StaticTemplate then
|
||||||
|
|
||||||
|
local CountryID = self.CountryID
|
||||||
|
local CountryName = _DATABASE.COUNTRY_NAME[CountryID]
|
||||||
|
|
||||||
|
StaticTemplate.units = nil
|
||||||
|
StaticTemplate.route = nil
|
||||||
|
StaticTemplate.groupId = nil
|
||||||
|
|
||||||
|
StaticTemplate.CountryID = nil
|
||||||
|
StaticTemplate.CoalitionID = nil
|
||||||
|
StaticTemplate.CategoryID = nil
|
||||||
|
|
||||||
|
local Static = coalition.addStaticObject( CountryID, StaticTemplate )
|
||||||
|
|
||||||
|
return Static
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Creates the original @{Static} at a POINT_VEC2.
|
||||||
|
-- @param #SPAWNSTATIC self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The 2D coordinate where to spawn the static.
|
||||||
|
-- @param #number Heading The heading of the static, which is a number in degrees from 0 to 360.
|
||||||
|
-- @return #SPAWNSTATIC
|
||||||
|
function SPAWNSTATIC:ReSpawnAt( Coordinate, Heading )
|
||||||
|
|
||||||
|
local StaticTemplate = _DATABASE:GetStaticUnitTemplate( self.SpawnTemplatePrefix )
|
||||||
|
|
||||||
|
if StaticTemplate then
|
||||||
|
|
||||||
|
local CountryID = self.CountryID
|
||||||
|
local CountryName = _DATABASE.COUNTRY_NAME[CountryID]
|
||||||
|
|
||||||
|
StaticTemplate.x = Coordinate.x
|
||||||
|
StaticTemplate.y = Coordinate.z
|
||||||
|
|
||||||
|
StaticTemplate.units = nil
|
||||||
|
StaticTemplate.route = nil
|
||||||
|
StaticTemplate.groupId = nil
|
||||||
|
|
||||||
|
StaticTemplate.heading = Heading and ( ( Heading / 180 ) * math.pi ) or StaticTemplate.heading
|
||||||
|
|
||||||
|
StaticTemplate.CountryID = nil
|
||||||
|
StaticTemplate.CoalitionID = nil
|
||||||
|
StaticTemplate.CategoryID = nil
|
||||||
|
|
||||||
|
local Static = coalition.addStaticObject( CountryID, StaticTemplate )
|
||||||
|
|
||||||
|
return Static
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Creates a new @{Static} from a @{Zone}.
|
--- Creates a new @{Static} from a @{Zone}.
|
||||||
-- @param #SPAWNSTATIC self
|
-- @param #SPAWNSTATIC self
|
||||||
-- @param Core.Zone#ZONE_BASE Zone The Zone where to spawn the static.
|
-- @param Core.Zone#ZONE_BASE Zone The Zone where to spawn the static.
|
||||||
|
|||||||
@@ -598,6 +598,8 @@ function TASK:UnAssignFromUnit( TaskUnit )
|
|||||||
|
|
||||||
self:RemoveStateMachine( TaskUnit )
|
self:RemoveStateMachine( TaskUnit )
|
||||||
|
|
||||||
|
-- If a Task Control Menu had been set, then this will be removed.
|
||||||
|
self:RemoveTaskControlMenu( TaskUnit )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -779,15 +781,16 @@ function TASK:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
|||||||
local TaskText = string.format( "%s%s", self:GetName(), TaskPlayerString ) --, TaskThreatLevelString )
|
local TaskText = string.format( "%s%s", self:GetName(), TaskPlayerString ) --, TaskThreatLevelString )
|
||||||
local TaskName = string.format( "%s", self:GetName() )
|
local TaskName = string.format( "%s", self:GetName() )
|
||||||
|
|
||||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
for UnitName, TaskUnit in pairs( TaskGroup:GetUnits() ) do
|
||||||
-- local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu ):SetTime( MenuTime )
|
local TaskUnit = TaskUnit -- Wrapper.Unit#UNIT
|
||||||
-- local MissionMenu = Mission:GetMenu( TaskGroup )
|
if TaskUnit then
|
||||||
|
local MenuControl = self:GetTaskControlMenu( TaskUnit )
|
||||||
self.MenuAssigned = self.MenuAssigned or {}
|
local TaskControl = MENU_GROUP:New( TaskGroup, "Control Task", MenuControl ):SetTime( MenuTime ):SetTag( "Tasking" )
|
||||||
self.MenuAssigned[TaskGroup] = MENU_GROUP_DELAYED:New( TaskGroup, string.format( "Assigned Task %s", TaskName ), MissionMenu ):SetTime( MenuTime ):SetTag( "Tasking" )
|
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Abort Task" ), TaskControl, self.MenuTaskAbort, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" )
|
||||||
local TaskMenu = MENU_GROUP_COMMAND_DELAYED:New( TaskGroup, string.format( "Abort Task" ), self.MenuAssigned[TaskGroup], self.MenuTaskAbort, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" )
|
local MarkMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Mark Task Location on Map" ), TaskControl, self.MenuMarkToGroup, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" )
|
||||||
local MarkMenu = MENU_GROUP_COMMAND_DELAYED:New( TaskGroup, string.format( "Mark Task Location on Map" ), self.MenuAssigned[TaskGroup], self.MenuMarkToGroup, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" )
|
local TaskTypeMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Report Task Details" ), TaskControl, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" )
|
||||||
local TaskTypeMenu = MENU_GROUP_COMMAND_DELAYED:New( TaskGroup, string.format( "Report Task Details" ), self.MenuAssigned[TaskGroup], self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetTag( "Tasking" )
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -1595,3 +1598,62 @@ do -- Additional Task Scoring and Task Progress
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do -- Task Control Menu
|
||||||
|
|
||||||
|
-- The Task Control Menu is a menu attached to the task at the main menu to quickly be able to do actions in the task.
|
||||||
|
-- The Task Control Menu can only be shown when the task is assigned to the player.
|
||||||
|
-- The Task Control Menu is linked to the process executing the task, so no task menu can be set to the main static task definition.
|
||||||
|
|
||||||
|
--- Init Task Control Menu
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Unit#UNIT TaskUnit The @{Unit} that contains a player.
|
||||||
|
-- @return Task Control Menu Refresh ID
|
||||||
|
function TASK:InitTaskControlMenu( TaskUnit )
|
||||||
|
|
||||||
|
self.TaskControlMenuTime = timer.getTime()
|
||||||
|
|
||||||
|
return self.TaskControlMenuTime
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get Task Control Menu
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Unit#UNIT TaskUnit The @{Unit} that contains a player.
|
||||||
|
-- @return Core.Menu#MENU_GROUP TaskControlMenu The Task Control Menu
|
||||||
|
function TASK:GetTaskControlMenu( TaskUnit, TaskName )
|
||||||
|
|
||||||
|
TaskName = TaskName or ""
|
||||||
|
|
||||||
|
if not self.TaskControlMenu then
|
||||||
|
self.TaskControlMenu = MENU_GROUP:New( TaskUnit:GetGroup(), "Assigned Task " .. TaskUnit:GetPlayerName() .. " - " .. self:GetName() .. " " .. TaskName ):SetTime( self.TaskControlMenuTime )
|
||||||
|
else
|
||||||
|
self.TaskControlMenu:SetTime( self.TaskControlMenuTime )
|
||||||
|
end
|
||||||
|
|
||||||
|
return self.TaskControlMenu
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove Task Control Menu
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Unit#UNIT TaskUnit The @{Unit} that contains a player.
|
||||||
|
function TASK:RemoveTaskControlMenu( TaskUnit )
|
||||||
|
|
||||||
|
if self.TaskControlMenu then
|
||||||
|
self.TaskControlMenu:Remove()
|
||||||
|
self.TaskControlMenu = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Refresh Task Control Menu
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Unit#UNIT TaskUnit The @{Unit} that contains a player.
|
||||||
|
-- @param MenuTime The refresh time that was used to refresh the Task Control Menu items.
|
||||||
|
-- @param MenuTag The tag.
|
||||||
|
function TASK:RefreshTaskControlMenu( TaskUnit, MenuTime, MenuTag )
|
||||||
|
|
||||||
|
if self.TaskControlMenu then
|
||||||
|
self.TaskControlMenu:Remove( MenuTime, MenuTag )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|||||||
@@ -257,16 +257,16 @@ do -- TASK_CARGO
|
|||||||
---
|
---
|
||||||
-- @param #FSM_PROCESS self
|
-- @param #FSM_PROCESS self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @param Tasking.Task_CARGO#TASK_CARGO Task
|
-- @param #TASK_CARGO Task
|
||||||
function Fsm:onafterSelectAction( TaskUnit, Task )
|
function Fsm:onafterSelectAction( TaskUnit, Task )
|
||||||
|
|
||||||
local TaskUnitName = TaskUnit:GetName()
|
local TaskUnitName = TaskUnit:GetName()
|
||||||
|
|
||||||
self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnitName, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
local MenuTime = timer.getTime()
|
local MenuTime = Task:InitTaskControlMenu( TaskUnit )
|
||||||
|
|
||||||
TaskUnit.Menu = MENU_GROUP:New( TaskUnit:GetGroup(), Task:GetName() .. " @ " .. TaskUnit:GetName() )
|
local MenuControl = Task:GetTaskControlMenu( TaskUnit )
|
||||||
|
|
||||||
local CargoItemCount = TaskUnit:CargoItemCount()
|
local CargoItemCount = TaskUnit:CargoItemCount()
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ do -- TASK_CARGO
|
|||||||
-- MENU_GROUP_COMMAND:New(
|
-- MENU_GROUP_COMMAND:New(
|
||||||
-- TaskUnit:GetGroup(),
|
-- TaskUnit:GetGroup(),
|
||||||
-- "Cancel Route " .. Cargo.Name,
|
-- "Cancel Route " .. Cargo.Name,
|
||||||
-- TaskUnit.Menu,
|
-- MenuControl,
|
||||||
-- self.MenuRouteToPickupCancel,
|
-- self.MenuRouteToPickupCancel,
|
||||||
-- self,
|
-- self,
|
||||||
-- Cargo
|
-- Cargo
|
||||||
@@ -294,6 +294,8 @@ do -- TASK_CARGO
|
|||||||
self:F( { CargoUnloaded = Cargo:IsUnLoaded(), CargoLoaded = Cargo:IsLoaded(), CargoItemCount = CargoItemCount } )
|
self:F( { CargoUnloaded = Cargo:IsUnLoaded(), CargoLoaded = Cargo:IsLoaded(), CargoItemCount = CargoItemCount } )
|
||||||
Task:E( { TaskDeployZones = Task.DeployZones, TaskName = Task:GetName() } )
|
Task:E( { TaskDeployZones = Task.DeployZones, TaskName = Task:GetName() } )
|
||||||
|
|
||||||
|
local TaskGroup = TaskUnit:GetGroup()
|
||||||
|
|
||||||
if Cargo:IsUnLoaded() then
|
if Cargo:IsUnLoaded() then
|
||||||
if CargoItemCount < 1 then
|
if CargoItemCount < 1 then
|
||||||
if Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then
|
if Cargo:IsInReportRadius( TaskUnit:GetPointVec2() ) then
|
||||||
@@ -308,7 +310,8 @@ do -- TASK_CARGO
|
|||||||
if Cargo:CanBoard() == true then
|
if Cargo:CanBoard() == true then
|
||||||
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
||||||
Cargo:Report( "ready for boarding at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "board", TaskUnit:GetGroup() )
|
Cargo:Report( "ready for boarding at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "board", TaskUnit:GetGroup() )
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Board cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime)
|
local BoardMenu = MENU_GROUP:New( TaskGroup, "Board cargo", MenuControl ):SetTime( MenuTime ):SetTag( "Cargo" )
|
||||||
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), Cargo.Name, BoardMenu, self.MenuBoardCargo, self, Cargo ):SetTime(MenuTime):SetTag("Cargo"):SetRemoveParent()
|
||||||
else
|
else
|
||||||
Cargo:Report( "Board at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
Cargo:Report( "Board at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
||||||
end
|
end
|
||||||
@@ -316,7 +319,8 @@ do -- TASK_CARGO
|
|||||||
if Cargo:CanLoad() == true then
|
if Cargo:CanLoad() == true then
|
||||||
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
if Cargo:IsInLoadRadius( TaskUnit:GetPointVec2() ) then
|
||||||
Cargo:Report( "ready for loading at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "load", TaskUnit:GetGroup() )
|
Cargo:Report( "ready for loading at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "load", TaskUnit:GetGroup() )
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Load cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuLoadCargo, self, Cargo ):SetTime(MenuTime)
|
local LoadMenu = MENU_GROUP:New( TaskGroup, "Load cargo", MenuControl ):SetTime( MenuTime ):SetTag( "Cargo" )
|
||||||
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), Cargo.Name, LoadMenu, self.MenuLoadCargo, self, Cargo ):SetTime(MenuTime):SetTag("Cargo"):SetRemoveParent()
|
||||||
else
|
else
|
||||||
Cargo:Report( "Load at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
Cargo:Report( "Load at " .. Cargo:GetCoordinate():ToString( TaskUnit:GetGroup() ), "reporting", TaskUnit:GetGroup() )
|
||||||
end
|
end
|
||||||
@@ -330,17 +334,14 @@ do -- TASK_CARGO
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
TaskUnit.Menu:SetTime( MenuTime )
|
|
||||||
else
|
else
|
||||||
Cargo:ReportResetAll( TaskUnit:GetGroup() )
|
Cargo:ReportResetAll( TaskUnit:GetGroup() )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if self:Is( "RoutingToPickup" ) then
|
if not Cargo:IsDeployed() == true then
|
||||||
else
|
local RouteToPickupMenu = MENU_GROUP:New( TaskGroup, "Route to pickup cargo", MenuControl ):SetTime( MenuTime ):SetTag( "Cargo" )
|
||||||
self:F("route menu set")
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), Cargo.Name, RouteToPickupMenu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime):SetTag("Cargo"):SetRemoveParent()
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Pickup cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuRouteToPickup, self, Cargo ):SetTime(MenuTime)
|
|
||||||
TaskUnit.Menu:SetTime( MenuTime )
|
|
||||||
Cargo:ReportResetAll( TaskUnit:GetGroup() )
|
Cargo:ReportResetAll( TaskUnit:GetGroup() )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -367,20 +368,22 @@ do -- TASK_CARGO
|
|||||||
if Cargo:IsLoaded() == true and Cargo:IsLoadedInCarrier( TaskUnit ) == true then
|
if Cargo:IsLoaded() == true and Cargo:IsLoadedInCarrier( TaskUnit ) == true then
|
||||||
if not TaskUnit:InAir() then
|
if not TaskUnit:InAir() then
|
||||||
if Cargo:CanUnboard() == true then
|
if Cargo:CanUnboard() == true then
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Unboard cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuUnboardCargo, self, Cargo ):SetTime(MenuTime)
|
local UnboardMenu = MENU_GROUP:New( TaskGroup, "Unboard cargo", MenuControl ):SetTime( MenuTime ):SetTag( "Cargo" )
|
||||||
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), Cargo.Name, UnboardMenu, self.MenuUnboardCargo, self, Cargo ):SetTime(MenuTime):SetTag("Cargo"):SetRemoveParent()
|
||||||
else
|
else
|
||||||
if Cargo:CanUnload() == true then
|
if Cargo:CanUnload() == true then
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Unload cargo " .. Cargo.Name, TaskUnit.Menu, self.MenuUnloadCargo, self, Cargo ):SetTime(MenuTime)
|
local UnloadMenu = MENU_GROUP:New( TaskGroup, "Unload cargo", MenuControl ):SetTime( MenuTime ):SetTag( "Cargo" )
|
||||||
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), Cargo.Name, UnloadMenu, self.MenuUnloadCargo, self, Cargo ):SetTime(MenuTime):SetTag("Cargo"):SetRemoveParent()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
TaskUnit.Menu:SetTime( MenuTime )
|
|
||||||
end
|
end
|
||||||
-- Deployzones are optional zones that can be selected to request routing information.
|
end
|
||||||
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
|
||||||
if not Cargo:IsInZone( DeployZone ) then
|
-- Deployzones are optional zones that can be selected to request routing information.
|
||||||
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Route to Deploy cargo at " .. DeployZoneName, TaskUnit.Menu, self.MenuRouteToDeploy, self, DeployZone ):SetTime(MenuTime)
|
for DeployZoneName, DeployZone in pairs( Task.DeployZones ) do
|
||||||
TaskUnit.Menu:SetTime( MenuTime )
|
if not Cargo:IsInZone( DeployZone ) then
|
||||||
end
|
local RouteToDeployMenu = MENU_GROUP:New( TaskGroup, "Route to deploy cargo", MenuControl ):SetTime( MenuTime ):SetTag( "Cargo" )
|
||||||
|
MENU_GROUP_COMMAND:New( TaskUnit:GetGroup(), "Zone " .. DeployZoneName, RouteToDeployMenu, self.MenuRouteToDeploy, self, DeployZone ):SetTime(MenuTime):SetTag("Cargo"):SetRemoveParent()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -388,8 +391,7 @@ do -- TASK_CARGO
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
TaskUnit.Menu:Remove( MenuTime )
|
Task:RefreshTaskControlMenu( TaskUnit, MenuTime, "Cargo" )
|
||||||
|
|
||||||
|
|
||||||
self:__SelectAction( -1 )
|
self:__SelectAction( -1 )
|
||||||
|
|
||||||
@@ -399,11 +401,13 @@ do -- TASK_CARGO
|
|||||||
---
|
---
|
||||||
-- @param #FSM_PROCESS self
|
-- @param #FSM_PROCESS self
|
||||||
-- @param Wrapper.Unit#UNIT TaskUnit
|
-- @param Wrapper.Unit#UNIT TaskUnit
|
||||||
-- @param Tasking.Task_Cargo#TASK_CARGO Task
|
-- @param #TASK_CARGO Task
|
||||||
function Fsm:OnLeaveWaitingForCommand( TaskUnit, Task )
|
function Fsm:OnLeaveWaitingForCommand( TaskUnit, Task )
|
||||||
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||||
|
|
||||||
TaskUnit.Menu:Remove()
|
--local MenuControl = Task:GetTaskControlMenu( TaskUnit )
|
||||||
|
|
||||||
|
--MenuControl:Remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Fsm:MenuBoardCargo( Cargo )
|
function Fsm:MenuBoardCargo( Cargo )
|
||||||
@@ -821,11 +825,14 @@ do -- TASK_CARGO
|
|||||||
self:F({Cargo, TaskUnit})
|
self:F({Cargo, TaskUnit})
|
||||||
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
||||||
|
|
||||||
|
local MenuTime = self:InitTaskControlMenu( TaskUnit )
|
||||||
|
local MenuControl = self:GetTaskControlMenu( TaskUnit )
|
||||||
|
|
||||||
local ActRouteCargo = ProcessUnit:GetProcess( "RoutingToPickup", "RouteToPickupPoint" ) -- Actions.Act_Route#ACT_ROUTE_POINT
|
local ActRouteCargo = ProcessUnit:GetProcess( "RoutingToPickup", "RouteToPickupPoint" ) -- Actions.Act_Route#ACT_ROUTE_POINT
|
||||||
ActRouteCargo:Reset()
|
ActRouteCargo:Reset()
|
||||||
ActRouteCargo:SetCoordinate( Cargo:GetCoordinate() )
|
ActRouteCargo:SetCoordinate( Cargo:GetCoordinate() )
|
||||||
ActRouteCargo:SetRange( Cargo:GetLoadRadius() )
|
ActRouteCargo:SetRange( Cargo:GetLoadRadius() )
|
||||||
ActRouteCargo:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Cargo " .. Cargo:GetName(), TaskUnit.Menu )
|
ActRouteCargo:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Cargo " .. Cargo:GetName(), MenuControl, MenuTime, "Cargo" )
|
||||||
ActRouteCargo:Start()
|
ActRouteCargo:Start()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -840,10 +847,13 @@ do -- TASK_CARGO
|
|||||||
|
|
||||||
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
local ProcessUnit = self:GetUnitProcess( TaskUnit )
|
||||||
|
|
||||||
|
local MenuTime = self:InitTaskControlMenu( TaskUnit )
|
||||||
|
local MenuControl = self:GetTaskControlMenu( TaskUnit )
|
||||||
|
|
||||||
local ActRouteDeployZone = ProcessUnit:GetProcess( "RoutingToDeploy", "RouteToDeployZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE
|
local ActRouteDeployZone = ProcessUnit:GetProcess( "RoutingToDeploy", "RouteToDeployZone" ) -- Actions.Act_Route#ACT_ROUTE_ZONE
|
||||||
ActRouteDeployZone:Reset()
|
ActRouteDeployZone:Reset()
|
||||||
ActRouteDeployZone:SetZone( DeployZone )
|
ActRouteDeployZone:SetZone( DeployZone )
|
||||||
ActRouteDeployZone:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Deploy Zone" .. DeployZone:GetName(), TaskUnit.Menu )
|
ActRouteDeployZone:SetMenuCancel( TaskUnit:GetGroup(), "Cancel Routing to Deploy Zone" .. DeployZone:GetName(), MenuControl, MenuTime, "Cargo" )
|
||||||
ActRouteDeployZone:Start()
|
ActRouteDeployZone:Start()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -970,6 +980,8 @@ do -- TASK_CARGO
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -130,12 +130,21 @@ end
|
|||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
||||||
-- @param #number Heading The heading of the unit respawn.
|
-- @param #number Heading The heading of the unit respawn.
|
||||||
function STATIC:ReSpawn( Coordinate, Heading )
|
function STATIC:SpawnAt( Coordinate, Heading )
|
||||||
|
|
||||||
|
|
||||||
-- todo: need to fix country
|
|
||||||
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName )
|
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName )
|
||||||
|
|
||||||
SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName )
|
SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Respawn the @{Unit} using a (tweaked) template of the parent Group.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
||||||
|
-- @param #number Heading The heading of the unit respawn.
|
||||||
|
function STATIC:ReSpawn()
|
||||||
|
|
||||||
|
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName )
|
||||||
|
|
||||||
|
SpawnStatic:ReSpawn()
|
||||||
|
end
|
||||||
|
|||||||
@@ -189,9 +189,9 @@ end
|
|||||||
-- * Then it will respawn the re-modelled group.
|
-- * Then it will respawn the re-modelled group.
|
||||||
--
|
--
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @param Dcs.DCSTypes#Vec3 SpawnVec3 The position where to Spawn the new Unit at.
|
-- @param Core.Point#COORDINATE Coordinate The position where to Spawn the new Unit at.
|
||||||
-- @param #number Heading The heading of the unit respawn.
|
-- @param #number Heading The heading of the unit respawn.
|
||||||
function UNIT:ReSpawn( SpawnVec3, Heading )
|
function UNIT:ReSpawnAt( Coordinate, Heading )
|
||||||
|
|
||||||
self:T( self:Name() )
|
self:T( self:Name() )
|
||||||
local SpawnGroupTemplate = UTILS.DeepCopy( _DATABASE:GetGroupTemplateFromUnitName( self:Name() ) )
|
local SpawnGroupTemplate = UTILS.DeepCopy( _DATABASE:GetGroupTemplateFromUnitName( self:Name() ) )
|
||||||
@@ -203,8 +203,8 @@ function UNIT:ReSpawn( SpawnVec3, Heading )
|
|||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
|
|
||||||
local Vec3 = SpawnGroup:GetVec3()
|
local Vec3 = SpawnGroup:GetVec3()
|
||||||
SpawnGroupTemplate.x = SpawnVec3.x
|
SpawnGroupTemplate.x = Coordinate.x
|
||||||
SpawnGroupTemplate.y = SpawnVec3.z
|
SpawnGroupTemplate.y = Coordinate.z
|
||||||
|
|
||||||
self:F( #SpawnGroupTemplate.units )
|
self:F( #SpawnGroupTemplate.units )
|
||||||
for UnitID, UnitData in pairs( SpawnGroup:GetUnits() ) do
|
for UnitID, UnitData in pairs( SpawnGroup:GetUnits() ) do
|
||||||
@@ -227,9 +227,9 @@ function UNIT:ReSpawn( SpawnVec3, Heading )
|
|||||||
SpawnGroupTemplate.units[UnitTemplateID].unitId = nil
|
SpawnGroupTemplate.units[UnitTemplateID].unitId = nil
|
||||||
if UnitTemplateData.name == self:Name() then
|
if UnitTemplateData.name == self:Name() then
|
||||||
self:T("Adjusting")
|
self:T("Adjusting")
|
||||||
SpawnGroupTemplate.units[UnitTemplateID].alt = SpawnVec3.y
|
SpawnGroupTemplate.units[UnitTemplateID].alt = Coordinate.y
|
||||||
SpawnGroupTemplate.units[UnitTemplateID].x = SpawnVec3.x
|
SpawnGroupTemplate.units[UnitTemplateID].x = Coordinate.x
|
||||||
SpawnGroupTemplate.units[UnitTemplateID].y = SpawnVec3.z
|
SpawnGroupTemplate.units[UnitTemplateID].y = Coordinate.z
|
||||||
SpawnGroupTemplate.units[UnitTemplateID].heading = Heading
|
SpawnGroupTemplate.units[UnitTemplateID].heading = Heading
|
||||||
self:F( { UnitTemplateID, SpawnGroupTemplate.units[UnitTemplateID], SpawnGroupTemplate.units[UnitTemplateID] } )
|
self:F( { UnitTemplateID, SpawnGroupTemplate.units[UnitTemplateID], SpawnGroupTemplate.units[UnitTemplateID] } )
|
||||||
else
|
else
|
||||||
@@ -344,18 +344,18 @@ end
|
|||||||
function UNIT:GetPlayerName()
|
function UNIT:GetPlayerName()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
local DCSUnit = self:GetDCSObject() -- Dcs.DCSUnit#Unit
|
||||||
|
|
||||||
if DCSUnit then
|
if DCSUnit then
|
||||||
|
|
||||||
local PlayerName = DCSUnit:getPlayerName()
|
local PlayerName = DCSUnit:getPlayerName()
|
||||||
if PlayerName == nil then
|
if PlayerName == nil or PlayerName == "" then
|
||||||
PlayerName = ""
|
PlayerName = "Player" .. DCSUnit:getID()
|
||||||
end
|
end
|
||||||
return PlayerName
|
return PlayerName
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user