mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
CARGO_GROUP working!!!
This commit is contained in:
parent
0b59fb87f2
commit
ff64255ea7
@ -228,7 +228,8 @@ BASE = {
|
||||
-- @type FORMATION
|
||||
-- @field Cone A cone formation.
|
||||
FORMATION = {
|
||||
Cone = "Cone"
|
||||
Cone = "Cone",
|
||||
Vee = "Vee"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -508,9 +508,11 @@ end
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||
function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2 )
|
||||
function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||
self:F()
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
local Angle = 180
|
||||
local Speed = 10
|
||||
local DeployDistance = 5
|
||||
@ -541,7 +543,7 @@ function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2 )
|
||||
local TaskRoute = self.CargoObject:TaskRoute( Points )
|
||||
self.CargoObject:SetTask( TaskRoute, 1 )
|
||||
|
||||
self:__UnBoarding( 1, ToPointVec2 )
|
||||
self:__UnBoarding( -1, ToPointVec2, NearRadius )
|
||||
end
|
||||
end
|
||||
|
||||
@ -553,18 +555,20 @@ end
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||
function CARGO_UNIT:onleaveUnBoarding( From, Event, To, ToPointVec2 )
|
||||
function CARGO_UNIT:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||
self:F( { ToPointVec2, From, Event, To } )
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
local Angle = 180
|
||||
local Speed = 10
|
||||
local Distance = 5
|
||||
|
||||
if From == "UnBoarding" then
|
||||
if self:IsNear( ToPointVec2 ) then
|
||||
if self:IsNear( ToPointVec2, NearRadius ) then
|
||||
return true
|
||||
else
|
||||
self:__UnBoarding( 1, ToPointVec2 )
|
||||
self:__UnBoarding( 1, ToPointVec2, NearRadius )
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -577,9 +581,11 @@ end
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
-- @param Core.Point#POINT_VEC2 ToPointVec2
|
||||
function CARGO_UNIT:onafterUnBoarding( From, Event, To, ToPointVec2 )
|
||||
function CARGO_UNIT:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||
self:F( { ToPointVec2, From, Event, To } )
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
self.CargoInAir = self.CargoObject:InAir()
|
||||
|
||||
self:T( self.CargoInAir )
|
||||
@ -602,7 +608,7 @@ end
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
-- @param Core.Point#POINT_VEC2
|
||||
function CARGO_UNIT:onenterUnLoaded( From, Event, To, ToPointVec2 )
|
||||
function CARGO_UNIT:onenterUnLoaded( From, Event, To, ToPointVec2 )
|
||||
self:F( { ToPointVec2, From, Event, To } )
|
||||
|
||||
local Angle = 180
|
||||
@ -661,6 +667,25 @@ function CARGO_UNIT:onenterBoarding( From, Event, To, CargoCarrier, NearRadius,
|
||||
|
||||
Points[#Points+1] = PointStartVec2:RoutePointGround( Speed )
|
||||
Points[#Points+1] = CargoDeployPointVec2:RoutePointGround( Speed )
|
||||
|
||||
-- I need to do this mess, otherwise the units will stop boarding at a point in time...
|
||||
-- This is a DCS bug that i am handling in this way.
|
||||
do
|
||||
local CargoBooardPointVec2 = CargoDeployPointVec2:GetRandomPointVec2InRadius(NearRadius,0)
|
||||
Points[#Points+1] = CargoBooardPointVec2:RoutePointGround( Speed )
|
||||
end
|
||||
do
|
||||
local CargoBooardPointVec2 = CargoDeployPointVec2:GetRandomPointVec2InRadius(NearRadius,0)
|
||||
Points[#Points+1] = CargoBooardPointVec2:RoutePointGround( Speed )
|
||||
end
|
||||
do
|
||||
local CargoBooardPointVec2 = CargoDeployPointVec2:GetRandomPointVec2InRadius(NearRadius,0)
|
||||
Points[#Points+1] = CargoBooardPointVec2:RoutePointGround( Speed )
|
||||
end
|
||||
do
|
||||
local CargoBooardPointVec2 = CargoDeployPointVec2:GetRandomPointVec2InRadius(NearRadius,0)
|
||||
Points[#Points+1] = CargoBooardPointVec2:RoutePointGround( Speed )
|
||||
end
|
||||
|
||||
local TaskRoute = self.CargoObject:TaskRoute( Points )
|
||||
self.CargoObject:SetTask( TaskRoute, 2 )
|
||||
@ -970,9 +995,9 @@ do -- CARGO_GROUP
|
||||
-- @param #number ReportRadius (optional)
|
||||
-- @param #number NearRadius (optional)
|
||||
-- @return #CARGO_GROUP
|
||||
function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius, NearRadius )
|
||||
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( CargoGroup, Type, Name, 0, ReportRadius, NearRadius ) ) -- #CARGO_GROUP
|
||||
self:F( { Type, Name, ReportRadius, NearRadius } )
|
||||
function CARGO_GROUP:New( CargoGroup, Type, Name, ReportRadius )
|
||||
local self = BASE:Inherit( self, CARGO_REPORTABLE:New( CargoGroup, Type, Name, 0, ReportRadius ) ) -- #CARGO_GROUP
|
||||
self:F( { Type, Name, ReportRadius } )
|
||||
|
||||
self.CargoSet = SET_CARGO:New()
|
||||
|
||||
@ -1002,19 +1027,21 @@ end
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function CARGO_GROUP:onenterBoarding( From, Event, To, CargoCarrier )
|
||||
function CARGO_GROUP:onenterBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||
self:F( { CargoCarrier.UnitName, From, Event, To } )
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
if From == "UnLoaded" then
|
||||
|
||||
-- For each Cargo object within the CARGO_GROUPED, route each object to the CargoLoadPointVec2
|
||||
self.CargoSet:ForEach(
|
||||
function( Cargo )
|
||||
Cargo:__Board( 1, CargoCarrier )
|
||||
Cargo:__Board( 1, CargoCarrier, NearRadius )
|
||||
end
|
||||
)
|
||||
|
||||
self:__Boarding( 1, CargoCarrier )
|
||||
self:__Boarding( 1, CargoCarrier, NearRadius, ... )
|
||||
end
|
||||
|
||||
end
|
||||
@ -1025,7 +1052,7 @@ end
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function CARGO_GROUP:onenterLoaded( From, Event, To, CargoCarrier )
|
||||
function CARGO_GROUP:onenterLoaded( From, Event, To, CargoCarrier, ... )
|
||||
self:F( { CargoCarrier.UnitName, From, Event, To } )
|
||||
|
||||
if From == "UnLoaded" then
|
||||
@ -1034,6 +1061,9 @@ function CARGO_GROUP:onenterLoaded( From, Event, To, CargoCarrier )
|
||||
Cargo:Load( CargoCarrier )
|
||||
end
|
||||
end
|
||||
|
||||
self.CargoCarrier = CargoCarrier
|
||||
|
||||
end
|
||||
|
||||
--- Leave Boarding State.
|
||||
@ -1042,23 +1072,27 @@ end
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function CARGO_GROUP:onleaveBoarding( From, Event, To, CargoCarrier )
|
||||
function CARGO_GROUP:onleaveBoarding( From, Event, To, CargoCarrier, NearRadius, ... )
|
||||
self:F( { CargoCarrier.UnitName, From, Event, To } )
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
local Boarded = true
|
||||
|
||||
self.CargoSet:Flush()
|
||||
|
||||
-- For each Cargo object within the CARGO_GROUP, route each object to the CargoLoadPointVec2
|
||||
for CargoID, Cargo in pairs( self.CargoSet:GetSet() ) do
|
||||
self:T( Cargo.current )
|
||||
self:T( { Cargo:GetName(), Cargo.current } )
|
||||
if not Cargo:is( "Loaded" ) then
|
||||
Boarded = false
|
||||
end
|
||||
end
|
||||
|
||||
if not Boarded then
|
||||
self:__Boarding( 1, CargoCarrier )
|
||||
self:__Boarding( 1, CargoCarrier, NearRadius, ... )
|
||||
else
|
||||
self:__Load( 1, CargoCarrier )
|
||||
self:__Load( 1, CargoCarrier, ... )
|
||||
end
|
||||
return Boarded
|
||||
end
|
||||
@ -1069,9 +1103,11 @@ end
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2 )
|
||||
function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||
self:F()
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
local Timer = 1
|
||||
|
||||
if From == "Loaded" then
|
||||
@ -1079,12 +1115,12 @@ function CARGO_GROUP:onenterUnBoarding( From, Event, To, ToPointVec2 )
|
||||
-- For each Cargo object within the CARGO_GROUP, route each object to the CargoLoadPointVec2
|
||||
self.CargoSet:ForEach(
|
||||
function( Cargo )
|
||||
Cargo:__UnBoard( Timer, ToPointVec2 )
|
||||
Cargo:__UnBoard( Timer, ToPointVec2, NearRadius )
|
||||
Timer = Timer + 10
|
||||
end
|
||||
)
|
||||
|
||||
self:__UnBoarding( 1, ToPointVec2 )
|
||||
self:__UnBoarding( 1, ToPointVec2, NearRadius )
|
||||
end
|
||||
|
||||
end
|
||||
@ -1095,9 +1131,11 @@ end
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function CARGO_GROUP:onleaveUnBoarding( From, Event, To, ToPointVec2 )
|
||||
function CARGO_GROUP:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||
self:F( { ToPointVec2, From, Event, To } )
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
local Angle = 180
|
||||
local Speed = 10
|
||||
local Distance = 5
|
||||
@ -1116,7 +1154,7 @@ function CARGO_GROUP:onleaveUnBoarding( From, Event, To, ToPointVec2 )
|
||||
if UnBoarded then
|
||||
return true
|
||||
else
|
||||
self:__UnBoarding( 1, ToPointVec2 )
|
||||
self:__UnBoarding( 1, ToPointVec2, NearRadius )
|
||||
end
|
||||
|
||||
return false
|
||||
@ -1130,9 +1168,11 @@ end
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function CARGO_GROUP:onafterUnBoarding( From, Event, To, ToPointVec2 )
|
||||
function CARGO_GROUP:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius )
|
||||
self:F( { ToPointVec2, From, Event, To } )
|
||||
|
||||
NearRadius = NearRadius or 25
|
||||
|
||||
self:__UnLoad( 1, ToPointVec2 )
|
||||
end
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ end
|
||||
-- @param Core.Base#BASE Object
|
||||
-- @return Core.Base#BASE The added BASE Object.
|
||||
function SET_BASE:Add( ObjectName, Object )
|
||||
self:F2( ObjectName )
|
||||
self:F( ObjectName )
|
||||
|
||||
local t = { _ = Object }
|
||||
|
||||
@ -2467,9 +2467,6 @@ function SET_CARGO:New()
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.CARGOS ) )
|
||||
|
||||
self:HandleEvent( EVENTS.NewCargo )
|
||||
self:HandleEvent( EVENTS.DeleteCargo )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -2600,6 +2597,9 @@ function SET_CARGO:FilterStart()
|
||||
if _DATABASE then
|
||||
self:_FilterStart()
|
||||
end
|
||||
|
||||
self:HandleEvent( EVENTS.NewCargo )
|
||||
self:HandleEvent( EVENTS.DeleteCargo )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -117,6 +117,21 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
|
||||
end
|
||||
)
|
||||
|
||||
-- Handle when a player leaves a slot and goes back to spectators ...
|
||||
-- The PlayerUnit will be UnAssigned from the Task.
|
||||
-- When there is no Unit left running the Task, the Task goes into Abort...
|
||||
self:HandleEvent( EVENTS.MissionEnd,
|
||||
--- @param #TASK self
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
function( self, EventData )
|
||||
local PlayerUnit = EventData.IniUnit
|
||||
for MissionID, Mission in pairs( self:GetMissions() ) do
|
||||
local Mission = Mission -- Tasking.Mission#MISSION
|
||||
Mission:Stop()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
-- Handle when a player leaves a slot and goes back to spectators ...
|
||||
-- The PlayerUnit will be UnAssigned from the Task.
|
||||
-- When there is no Unit left running the Task, the Task goes into Abort...
|
||||
@ -127,7 +142,9 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
|
||||
local PlayerUnit = EventData.IniUnit
|
||||
for MissionID, Mission in pairs( self:GetMissions() ) do
|
||||
local Mission = Mission -- Tasking.Mission#MISSION
|
||||
Mission:AbortUnit( PlayerUnit )
|
||||
if Mission:IsOngoing() then
|
||||
Mission:AbortUnit( PlayerUnit )
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
@ -275,8 +275,9 @@ function TASK:AbortUnit( PlayerUnit )
|
||||
local IsAssignedToGroup = self:IsAssignedToGroup( PlayerGroup )
|
||||
self:E( { IsAssignedToGroup = IsAssignedToGroup } )
|
||||
if IsAssignedToGroup then
|
||||
local PlayerName = PlayerUnit:GetPlayerName()
|
||||
self:UnAssignFromUnit( PlayerUnit )
|
||||
self:MessageToGroups( PlayerUnit:GetPlayerName() .. " aborted Task " .. self:GetName() )
|
||||
self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() )
|
||||
self:E( { TaskGroup = PlayerGroup:GetName(), GetUnits = PlayerGroup:GetUnits() } )
|
||||
if #PlayerGroup:GetUnits() == 1 then
|
||||
self:UnAssignFromGroup( PlayerGroup )
|
||||
|
||||
@ -347,7 +347,7 @@ do -- TASK_CARGO
|
||||
self:__Land( -0.1 )
|
||||
else
|
||||
Task:GetMission():GetCommandCenter():MessageToGroup( "Boarding ...", TaskUnit:GetGroup(), "Boarding" )
|
||||
self.Cargo:Board( TaskUnit, self )
|
||||
self.Cargo:Board( TaskUnit, 20, self )
|
||||
end
|
||||
else
|
||||
self:__ArriveAtCargo( -0.1 )
|
||||
@ -375,7 +375,7 @@ do -- TASK_CARGO
|
||||
self:E( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } )
|
||||
|
||||
self.DeployZone = DeployZone
|
||||
self.Cargo:__UnBoard( -0.1, DeployZone )
|
||||
self.Cargo:__UnBoard( -0.1, DeployZone, 20 )
|
||||
end
|
||||
|
||||
---
|
||||
@ -394,7 +394,7 @@ do -- TASK_CARGO
|
||||
end
|
||||
|
||||
Task:GetMission():GetCommandCenter():MessageToGroup( "UnBoarding ...", TaskUnit:GetGroup(), "UnBoarding" )
|
||||
self.Cargo:__UnBoard( -0.1, self.DeployZone )
|
||||
self.Cargo:__UnBoard( -0.1, self.DeployZone, 20 )
|
||||
end
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user