diff --git a/Moose Development/Moose/Cargo.lua b/Moose Development/Moose/Cargo.lua index 913ef372c..314706d99 100644 --- a/Moose Development/Moose/Cargo.lua +++ b/Moose Development/Moose/Cargo.lua @@ -30,7 +30,7 @@ do -- CARGO -- @field #number Weight A number defining the weight of the cargo. The weight is expressed in kg. -- @field #number ReportRadius (optional) A number defining the radius in meters when the cargo is signalling or reporting to a Carrier. -- @field #number NearRadius (optional) A number defining the radius in meters when the cargo is near to a Carrier, so that it can be loaded. - -- @field Positionable#POSITIONABLE CargoObject The alive DCS object representing the cargo. This value can be nil, meaning, that the cargo is not represented anywhere... + -- @field Controllable#CONTROLLABLE CargoObject The alive DCS object representing the cargo. This value can be nil, meaning, that the cargo is not represented anywhere... -- @field Positionable#POSITIONABLE CargoCarrier The alive DCS object carrying the cargo. This value can be nil, meaning, that the cargo is not contained anywhere... -- @field #boolean Slingloadable This flag defines if the cargo can be slingloaded. -- @field #boolean Moveable This flag defines if the cargo is moveable. @@ -254,7 +254,7 @@ do -- CARGO_REPRESENTABLE --- CARGO_REPRESENTABLE Constructor. -- @param #CARGO_REPRESENTABLE self -- @param Mission#MISSION Mission - -- @param Positionable#POSITIONABLE CargoObject + -- @param Controllable#Controllable CargoObject -- @param #string Type -- @param #string Name -- @param #number Weight @@ -272,8 +272,9 @@ do -- CARGO_REPRESENTABLE --- Onboard representable Cargo to a Carrier. -- @param #CARGO_REPRESENTABLE self - function CARGO_REPRESENTABLE:Onboard( Carrier, OnBoardSide ) - self:F() + -- @param Unit#UNIT Carrier + function CARGO_REPRESENTABLE:Onboard( Carrier ) + self:F() local OnBoardScheduler = SCHEDULER:New( self, self.ExecuteOnboarding, 1, 1, 0, 30 ) @@ -287,67 +288,18 @@ do -- CARGO_REPRESENTABLE local Points = {} - local PointStartVec2 = self.CargoObject:GetVec2() + local PointStartVec2 = self.CargoObject:GetPointVec2() + local PointEndVec2 = Carrier:GetPointVec2() + - self:T( 'CargoPos x = ' .. CargoPos.x .. " z = " .. CargoPos.z ) - self:T( 'CarrierPosMove x = ' .. CarrierPosMove.x .. " z = " .. CarrierPosMove.z ) + Points[#Points+1] = PointStartVec2:RoutePointGround( "Cone", 10 ) + Points[#Points+1] = PointEndVec2:RoutePointGround( "Cone", 10 ) - Points[#Points+1] = routines.ground.buildWP( CargoPos, "Cone", 10 ) - - self:T( 'Points[1] x = ' .. Points[1].x .. " y = " .. Points[1].y ) - - if OnBoardSide == nil then - OnBoardSide = CLIENT.ONBOARDSIDE.NONE - end - - if OnBoardSide == CLIENT.ONBOARDSIDE.LEFT then - - self:T( "TransportCargoOnBoard: Onboarding LEFT" ) - CarrierPosMove.z = CarrierPosMove.z - 25 - CarrierPosOnBoard.z = CarrierPosOnBoard.z - 5 - Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 ) - Points[#Points+1] = routines.ground.buildWP( CarrierPosOnBoard, "Cone", 10 ) - - elseif OnBoardSide == CLIENT.ONBOARDSIDE.RIGHT then - - self:T( "TransportCargoOnBoard: Onboarding RIGHT" ) - CarrierPosMove.z = CarrierPosMove.z + 25 - CarrierPosOnBoard.z = CarrierPosOnBoard.z + 5 - Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 ) - Points[#Points+1] = routines.ground.buildWP( CarrierPosOnBoard, "Cone", 10 ) - - elseif OnBoardSide == CLIENT.ONBOARDSIDE.BACK then - - self:T( "TransportCargoOnBoard: Onboarding BACK" ) - CarrierPosMove.x = CarrierPosMove.x - 25 - CarrierPosOnBoard.x = CarrierPosOnBoard.x - 5 - Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 ) - Points[#Points+1] = routines.ground.buildWP( CarrierPosOnBoard, "Cone", 10 ) - - elseif OnBoardSide == CLIENT.ONBOARDSIDE.FRONT then - - self:T( "TransportCargoOnBoard: Onboarding FRONT" ) - CarrierPosMove.x = CarrierPosMove.x + 25 - CarrierPosOnBoard.x = CarrierPosOnBoard.x + 5 - Points[#Points+1] = routines.ground.buildWP( CarrierPosMove, "Cone", 10 ) - Points[#Points+1] = routines.ground.buildWP( CarrierPosOnBoard, "Cone", 10 ) - - elseif OnBoardSide == CLIENT.ONBOARDSIDE.NONE then - - self:T( "TransportCargoOnBoard: Onboarding CENTRAL" ) - Points[#Points+1] = routines.ground.buildWP( CarrierPos, "Cone", 10 ) - - end - self:T( "TransportCargoOnBoard: Routing " .. self.CargoGroupName ) - - --routines.scheduleFunction( routines.goRoute, { self.CargoGroupName, Points}, timer.getTime() + 4 ) - SCHEDULER:New( self, routines.goRoute, { self.CargoGroupName, Points}, 4 ) + local TaskRoute = self.CargoObject:TaskRoute( Points ) + self.CargoObject:SetTask( TaskRoute, 4 ) end - self:StatusLoading( Client ) - - return Valid - + self:StatusLoading( Carrier ) end --- Can the Cargo Onboard to the Carrier? diff --git a/Moose Development/Moose/Point.lua b/Moose Development/Moose/Point.lua index 9b7f73546..2372135c1 100644 --- a/Moose Development/Moose/Point.lua +++ b/Moose Development/Moose/Point.lua @@ -381,6 +381,44 @@ function POINT_VEC3:RoutePointAir( AltType, Type, Action, Speed, SpeedLocked ) return RoutePoint end +--- Build an ground type route point. +-- @param #POINT_VEC3 self +-- @param #POINT_VEC3.RoutePointAction Formation The route point Formation. +-- @param DCSTypes#Speed Speed Speed in km/h. +-- @return #table The route point. +function POINT_VEC3:RoutePointGround( Formation, Speed ) + self:F2( { Formation, Speed } ) + + local RoutePoint = {} + RoutePoint.x = self.PointVec3.x + RoutePoint.y = self.PointVec3.z + + RoutePoint.action = Formation + + RoutePoint.speed = Speed / 3.6 + RoutePoint.speed_locked = true + +-- ["task"] = +-- { +-- ["id"] = "ComboTask", +-- ["params"] = +-- { +-- ["tasks"] = +-- { +-- }, -- end of ["tasks"] +-- }, -- end of ["params"] +-- }, -- end of ["task"] + + + RoutePoint.task = {} + RoutePoint.task.id = "ComboTask" + RoutePoint.task.params = {} + RoutePoint.task.params.tasks = {} + + + return RoutePoint +end + --- Smokes the point in a color. -- @param #POINT_VEC3 self diff --git a/Moose Development/Moose/Positionable.lua b/Moose Development/Moose/Positionable.lua index 82642f088..d53ea0c9d 100644 --- a/Moose Development/Moose/Positionable.lua +++ b/Moose Development/Moose/Positionable.lua @@ -77,11 +77,11 @@ function POSITIONABLE:GetVec2() local DCSPositionable = self:GetDCSObject() if DCSPositionable then - local PositionablePointVec3 = DCSPositionable:getPosition().p + local PositionableVec3 = DCSPositionable:getPosition().p local PositionableVec2 = {} - PositionableVec2.x = PositionablePointVec3.x - PositionableVec2.y = PositionablePointVec3.z + PositionableVec2.x = PositionableVec3.x + PositionableVec2.y = PositionableVec3.z self:T2( PositionableVec2 ) return PositionableVec2 @@ -94,15 +94,15 @@ end -- @param Positionable#POSITIONABLE self -- @return Point#POINT_VEC2 The 2D point vector of the POSITIONABLE. -- @return #nil The DCS Positionable is not existing or alive. -function POSITIONABLE:GetVec2() +function POSITIONABLE:GetPointVec2() self:F2( self.PositionableName ) local DCSPositionable = self:GetDCSObject() if DCSPositionable then - local PositionablePointVec3 = DCSPositionable:getPosition().p + local PositionableVec3 = DCSPositionable:getPosition().p - local PositionablePointVec2 = POINT_VEC2:NewFromVec3( PositionablePointVec3 ) + local PositionablePointVec2 = POINT_VEC2:NewFromVec3( PositionableVec3 ) self:T2( PositionablePointVec2 ) return PositionablePointVec2