mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixed slingload deploy problem.
Fixed messaging. Now a message is shown when cargo reports itself when in LoadRange and when near, it will allow for loading of cargo. Fixed the perception that cargo can be boarded when loaded in an other carrier, which is totally wrong.
This commit is contained in:
@@ -224,6 +224,7 @@ do -- CARGO
|
||||
Slingloadable = false,
|
||||
Moveable = false,
|
||||
Containable = false,
|
||||
Reported = {},
|
||||
}
|
||||
|
||||
--- @type CARGO.CargoObjects
|
||||
@@ -235,12 +236,13 @@ do -- CARGO
|
||||
-- @param #string Type
|
||||
-- @param #string Name
|
||||
-- @param #number Weight
|
||||
-- @param #number LoadRadius (optional)
|
||||
-- @param #number NearRadius (optional)
|
||||
-- @return #CARGO
|
||||
function CARGO:New( Type, Name, Weight ) --R2.1
|
||||
function CARGO:New( Type, Name, Weight, LoadRadius, NearRadius ) --R2.1
|
||||
|
||||
local self = BASE:Inherit( self, FSM:New() ) -- #CARGO
|
||||
self:F( { Type, Name, Weight } )
|
||||
self:F( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||
|
||||
self:SetStartState( "UnLoaded" )
|
||||
self:AddTransition( { "UnLoaded", "Boarding" }, "Board", "Boarding" )
|
||||
@@ -267,6 +269,9 @@ do -- CARGO
|
||||
self.Moveable = false
|
||||
self.Containable = false
|
||||
|
||||
self.LoadRadius = LoadRadius or 500
|
||||
self.NearRadius = NearRadius or 25
|
||||
|
||||
self:SetDeployed( false )
|
||||
|
||||
self.CargoScheduler = SCHEDULER:New()
|
||||
@@ -405,8 +410,9 @@ do -- CARGO
|
||||
end
|
||||
end
|
||||
|
||||
--- Set the cargo as deployed
|
||||
--- Set the cargo as deployed.
|
||||
-- @param #CARGO self
|
||||
-- @param #boolean Deployed true if the cargo is to be deployed. false or nil otherwise.
|
||||
function CARGO:SetDeployed( Deployed )
|
||||
self.Deployed = Deployed
|
||||
end
|
||||
@@ -507,7 +513,86 @@ do -- CARGO
|
||||
end
|
||||
|
||||
|
||||
--- Set the Load radius, which is the radius till when the Cargo can be loaded.
|
||||
-- @param #CARGO self
|
||||
-- @param #number LoadRadius The radius till Cargo can be loaded.
|
||||
-- @return #CARGO
|
||||
function CARGO:SetLoadRadius( LoadRadius )
|
||||
self.LoadRadius = LoadRadius or 150
|
||||
end
|
||||
|
||||
--- Get the Load radius, which is the radius till when the Cargo can be loaded.
|
||||
-- @param #CARGO self
|
||||
-- @return #number The radius till Cargo can be loaded.
|
||||
function CARGO:GetLoadRadius()
|
||||
return self.LoadRadius
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Check if Cargo is in the LoadRadius for the Cargo to be Boarded or Loaded.
|
||||
-- @param #CARGO self
|
||||
-- @param Core.Point#Coordinate Coordinate
|
||||
-- @return #boolean true if the CargoGroup is within the loading radius.
|
||||
function CARGO:IsInLoadRadius( Coordinate )
|
||||
self:F( { Coordinate } )
|
||||
|
||||
local Distance = 0
|
||||
if self:IsUnLoaded() then
|
||||
Distance = Coordinate:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
|
||||
self:T( Distance )
|
||||
if Distance <= self.LoadRadius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
--- Check if the Cargo can report itself to be Boarded or Loaded.
|
||||
-- @param #CARGO self
|
||||
-- @param Core.Point#Coordinate Coordinate
|
||||
-- @return #boolean true if the Cargo can report itself.
|
||||
function CARGO:IsInReportRadius( Coordinate )
|
||||
self:F( { Coordinate } )
|
||||
|
||||
local Distance = 0
|
||||
if self:IsUnLoaded() then
|
||||
Distance = Coordinate:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
|
||||
self:T( Distance )
|
||||
if Distance <= self.LoadRadius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
--- Check if CargoCarrier is near the Cargo to be Loaded.
|
||||
-- @param #CARGO self
|
||||
-- @param Core.Point#POINT_VEC2 PointVec2
|
||||
-- @param #number NearRadius The radius when the cargo will board the Carrier (to avoid collision).
|
||||
-- @return #boolean
|
||||
function CARGO:IsNear( PointVec2, NearRadius )
|
||||
self:F( { PointVec2 = PointVec2, NearRadius = NearRadius } )
|
||||
|
||||
if self.CargoObject:IsAlive() then
|
||||
--local Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
|
||||
self:F( { CargoObjectName = self.CargoObject:GetName() } )
|
||||
self:F( { CargoObjectVec2 = self.CargoObject:GetVec2() } )
|
||||
self:F( { PointVec2 = PointVec2:GetVec2() } )
|
||||
local Distance = PointVec2:Get2DDistance( self.CargoObject:GetPointVec2() )
|
||||
self:T( Distance )
|
||||
|
||||
if Distance <= NearRadius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -534,30 +619,6 @@ do -- CARGO
|
||||
end
|
||||
|
||||
|
||||
--- Check if CargoCarrier is near the Cargo to be Loaded.
|
||||
-- @param #CARGO self
|
||||
-- @param Core.Point#POINT_VEC2 PointVec2
|
||||
-- @param #number NearRadius The radius when the cargo will board the Carrier (to avoid collision).
|
||||
-- @return #boolean
|
||||
function CARGO:IsNear( PointVec2, NearRadius )
|
||||
self:F( { PointVec2 = PointVec2, NearRadius = NearRadius } )
|
||||
|
||||
if self.CargoObject:IsAlive() then
|
||||
--local Distance = PointVec2:DistanceFromPointVec2( self.CargoObject:GetPointVec2() )
|
||||
self:F( { CargoObjectName = self.CargoObject:GetName() } )
|
||||
self:F( { CargoObjectVec2 = self.CargoObject:GetVec2() } )
|
||||
self:F( { PointVec2 = PointVec2:GetVec2() } )
|
||||
local Distance = PointVec2:Get2DDistance( self.CargoObject:GetPointVec2() )
|
||||
self:T( Distance )
|
||||
|
||||
if Distance <= NearRadius then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--- Get the current PointVec2 of the cargo.
|
||||
-- @param #CARGO self
|
||||
-- @return Core.Point#POINT_VEC2
|
||||
@@ -580,6 +641,85 @@ do -- CARGO
|
||||
self.Weight = Weight
|
||||
return self
|
||||
end
|
||||
|
||||
--- Send a CC message to a @{Group}.
|
||||
-- @param #CARGO self
|
||||
-- @param #string Message
|
||||
-- @param Wrapper.Group#GROUP CarrierGroup The Carrier Group.
|
||||
-- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
|
||||
function CARGO:MessageToGroup( Message, CarrierGroup, Name )
|
||||
|
||||
MESSAGE:New( Message, 20, "Cargo " .. self:GetName() ):ToGroup( CarrierGroup )
|
||||
|
||||
end
|
||||
|
||||
--- Report to a Carrier Group.
|
||||
-- @param #CARGO self
|
||||
-- @param #string Action The string describing the action for the cargo.
|
||||
-- @param Wrapper.Group#GROUP CarrierGroup The Carrier Group to send the report to.
|
||||
-- @return #CARGO
|
||||
function CARGO:Report( ReportText, Action, CarrierGroup )
|
||||
|
||||
if not self.Reported[CarrierGroup] or not self.Reported[CarrierGroup][Action] then
|
||||
self.Reported[CarrierGroup] = {}
|
||||
self.Reported[CarrierGroup][Action] = true
|
||||
self:MessageToGroup( ReportText, CarrierGroup )
|
||||
if self.ReportFlareColor then
|
||||
if not self.Reported[CarrierGroup]["Flaring"] then
|
||||
self:Flare( self.ReportFlareColor )
|
||||
self.Reported[CarrierGroup]["Flaring"] = true
|
||||
end
|
||||
end
|
||||
if self.ReportSmokeColor then
|
||||
if not self.Reported[CarrierGroup]["Smoking"] then
|
||||
self:Smoke( self.ReportSmokeColor )
|
||||
self.Reported[CarrierGroup]["Smoking"] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Report to a Carrier Group with a Flaring signal.
|
||||
-- @param #CARGO self
|
||||
-- @param Utils#UTILS.FlareColor FlareColor the color of the flare.
|
||||
-- @return #CARGO
|
||||
function CARGO:ReportFlare( FlareColor )
|
||||
|
||||
self.ReportFlareColor = FlareColor
|
||||
end
|
||||
|
||||
|
||||
--- Report to a Carrier Group with a Smoking signal.
|
||||
-- @param #CARGO self
|
||||
-- @param Utils#UTILS.SmokeColor SmokeColor the color of the smoke.
|
||||
-- @return #CARGO
|
||||
function CARGO:ReportSmoke( SmokeColor )
|
||||
|
||||
self.ReportSmokeColor = SmokeColor
|
||||
end
|
||||
|
||||
|
||||
--- Reset the reporting for a Carrier Group.
|
||||
-- @param #CARGO self
|
||||
-- @param #string Action The string describing the action for the cargo.
|
||||
-- @param Wrapper.Group#GROUP CarrierGroup The Carrier Group to send the report to.
|
||||
-- @return #CARGO
|
||||
function CARGO:ReportReset( Action, CarrierGroup )
|
||||
|
||||
self.Reported[CarrierGroup][Action] = nil
|
||||
end
|
||||
|
||||
--- Reset all the reporting for a Carrier Group.
|
||||
-- @param #CARGO self
|
||||
-- @param Wrapper.Group#GROUP CarrierGroup The Carrier Group to send the report to.
|
||||
-- @return #CARGO
|
||||
function CARGO:ReportResetAll( CarrierGroup )
|
||||
|
||||
self.Reported[CarrierGroup] = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
end -- CARGO
|
||||
|
||||
@@ -600,16 +740,13 @@ do -- CARGO_REPRESENTABLE
|
||||
-- @param #string Type
|
||||
-- @param #string Name
|
||||
-- @param #number Weight
|
||||
-- @param #number ReportRadius (optional)
|
||||
-- @param #number LoadRadius (optional)
|
||||
-- @param #number NearRadius (optional)
|
||||
-- @return #CARGO_REPRESENTABLE
|
||||
function CARGO_REPRESENTABLE:New( CargoObject, Type, Name, Weight, ReportRadius, NearRadius )
|
||||
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPRESENTABLE
|
||||
self:F( { Type, Name, Weight, ReportRadius, NearRadius } )
|
||||
function CARGO_REPRESENTABLE:New( CargoObject, Type, Name, Weight, LoadRadius, NearRadius )
|
||||
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight, LoadRadius, NearRadius ) ) -- #CARGO_REPRESENTABLE
|
||||
self:F( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||
|
||||
self.ReportRadius = ReportRadius or 500
|
||||
self.NearRadius = NearRadius or 25
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -661,14 +798,12 @@ do -- CARGO_REPORTABLE
|
||||
-- @param #string Type
|
||||
-- @param #string Name
|
||||
-- @param #number Weight
|
||||
-- @param #number ReportRadius (optional)
|
||||
-- @param #number LoadRadius (optional)
|
||||
-- @param #number NearRadius (optional)
|
||||
-- @return #CARGO_REPORTABLE
|
||||
function CARGO_REPORTABLE:New( Type, Name, Weight, ReportRadius )
|
||||
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight ) ) -- #CARGO_REPORTABLE
|
||||
self:F( { Type, Name, Weight, ReportRadius } )
|
||||
|
||||
self.ReportRadius = ReportRadius or 1000
|
||||
function CARGO_REPORTABLE:New( Type, Name, Weight, LoadRadius, NearRadius )
|
||||
local self = BASE:Inherit( self, CARGO:New( Type, Name, Weight, LoadRadius, NearRadius ) ) -- #CARGO_REPORTABLE
|
||||
self:F( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -680,19 +815,10 @@ do -- CARGO_REPORTABLE
|
||||
-- @param #sring Name (optional) The name of the Group used as a prefix for the message to the Group. If not provided, there will be nothing shown.
|
||||
function CARGO_REPORTABLE:MessageToGroup( Message, TaskGroup, Name )
|
||||
|
||||
local Prefix = Name and "@ " .. Name .. ": " or "@ " .. TaskGroup:GetCallsign() .. ": "
|
||||
Message = Prefix .. Message
|
||||
MESSAGE:New( Message, 20, "Cargo: " .. self:GetName() ):ToGroup( TaskGroup )
|
||||
MESSAGE:New( Message, 20, "Cargo " .. self:GetName() ):ToGroup( TaskGroup )
|
||||
|
||||
end
|
||||
|
||||
--- Get the Report radius, which is the radius when the Cargo is reporting itself.
|
||||
-- @param #CARGO_REPORTABLE self
|
||||
-- @return #number The range till Cargo reports itself.
|
||||
function CARGO_REPORTABLE:GetBoardingRange()
|
||||
return self.ReportRadius
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -717,12 +843,12 @@ do -- CARGO_PACKAGE
|
||||
-- @param #string Type
|
||||
-- @param #string Name
|
||||
-- @param #number Weight
|
||||
-- @param #number ReportRadius (optional)
|
||||
-- @param #number LoadRadius (optional)
|
||||
-- @param #number NearRadius (optional)
|
||||
-- @return #CARGO_PACKAGE
|
||||
function CARGO_PACKAGE:New( CargoCarrier, Type, Name, Weight, ReportRadius, NearRadius )
|
||||
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoCarrier, Type, Name, Weight, ReportRadius, NearRadius ) ) -- #CARGO_PACKAGE
|
||||
self:F( { Type, Name, Weight, ReportRadius, NearRadius } )
|
||||
function CARGO_PACKAGE:New( CargoCarrier, Type, Name, Weight, LoadRadius, NearRadius )
|
||||
local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoCarrier, Type, Name, Weight, LoadRadius, NearRadius ) ) -- #CARGO_PACKAGE
|
||||
self:F( { Type, Name, Weight, LoadRadius, NearRadius } )
|
||||
|
||||
self:T( CargoCarrier )
|
||||
self.CargoCarrier = CargoCarrier
|
||||
|
||||
Reference in New Issue
Block a user