mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
parent
b9a94271b2
commit
bd62df4d28
@ -317,20 +317,19 @@ function CARGO_REPRESENTABLE:OnUnBoard( FsmP, Event, From, To, Speed, Angle, Dis
|
||||
|
||||
local Points = {}
|
||||
|
||||
local PointStartVec2 = self.CargoCarrier:GetPointVec2()
|
||||
local StartPointVec2 = self.CargoCarrier:GetPointVec2()
|
||||
local CargoCarrierHeading = self.CargoCarrier:GetHeading() -- Get Heading of object in degrees.
|
||||
local CargoDeployHeading = ( ( CargoCarrierHeading + Angle ) >= 360 ) and ( CargoCarrierHeading + Angle - 360 ) or ( CargoCarrierHeading + Angle )
|
||||
local PointEndVec2 = CargoCarrier:GetPointVec2()
|
||||
local CargoDeployPointVec2 = StartPointVec2:Translate( Distance, CargoDeployHeading )
|
||||
|
||||
|
||||
Points[#Points+1] = PointStartVec2:RoutePointGround( Speed )
|
||||
Points[#Points+1] = PointEndVec2:RoutePointGround( Speed )
|
||||
Points[#Points+1] = StartPointVec2:RoutePointGround( Speed )
|
||||
Points[#Points+1] = CargoDeployPointVec2:RoutePointGround( Speed )
|
||||
|
||||
local TaskRoute = self.CargoObject:TaskRoute( Points )
|
||||
self.CargoObject:SetTask( TaskRoute, 4 )
|
||||
end
|
||||
|
||||
self:_NextEvent( FsmP.Boarded, CargoCarrier )
|
||||
self:_NextEvent( FsmP.UnBoarded )
|
||||
|
||||
end
|
||||
|
||||
@ -345,9 +344,8 @@ function CARGO_REPRESENTABLE:OnUnBoarded( FsmP, Event, From, To )
|
||||
self:F()
|
||||
|
||||
if self.CargoObject:GetVelocityKMH() <= 0.1 then
|
||||
self:_NextEvent( FsmP.UnLoad )
|
||||
else
|
||||
self:_NextEvent( FsmP.Boarded, CargoCarrier )
|
||||
self:_NextEvent( FsmP.UnBoarded )
|
||||
end
|
||||
end
|
||||
|
||||
@ -365,6 +363,25 @@ function CARGO_REPRESENTABLE:OnLoad( FsmP, Event, From, To, CargoCarrier )
|
||||
self.CargoObject:Destroy()
|
||||
end
|
||||
|
||||
--- UnLoad Event.
|
||||
-- @param #CARGO self
|
||||
-- @param StateMachine#STATEMACHINE_PROCESS FsmP
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
-- @param Unit#UNIT CargoCarrier
|
||||
function CARGO_REPRESENTABLE:OnUnLoad( FsmP, Event, From, To, Distance, Angle )
|
||||
self:F()
|
||||
|
||||
local StartPointVec2 = self.CargoCarrier:GetPointVec2()
|
||||
local CargoCarrierHeading = self.CargoCarrier:GetHeading() -- Get Heading of object in degrees.
|
||||
local CargoDeployHeading = ( ( CargoCarrierHeading + Angle ) >= 360 ) and ( CargoCarrierHeading + Angle - 360 ) or ( CargoCarrierHeading + Angle )
|
||||
local CargoDeployPointVec2 = StartPointVec2:Translate( Distance, CargoDeployHeading )
|
||||
|
||||
-- Respawn the group...
|
||||
self.CargoObject:ReSpawn( CargoDeployPointVec2:GetVec3(), CargoDeployHeading )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- CARGO_UNIT
|
||||
|
||||
@ -387,6 +387,14 @@ function DATABASE:GetGroupTemplate( GroupName )
|
||||
return GroupTemplate
|
||||
end
|
||||
|
||||
function DATABASE:GetGroupNameFromUnitName( UnitName )
|
||||
return self.Templates.Units[UnitName].GroupName
|
||||
end
|
||||
|
||||
function DATABASE:GetGroupTemplateFromUnitName( UnitName )
|
||||
return self.Templates.Units[UnitName].GroupTemplate
|
||||
end
|
||||
|
||||
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
|
||||
return self.Templates.ClientsByName[ClientName].CoalitionID
|
||||
end
|
||||
|
||||
@ -166,6 +166,56 @@ function UNIT:GetDCSObject()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Respawn the @{Unit} using a (tweaked) template of the parent Group.
|
||||
--
|
||||
-- This function will:
|
||||
--
|
||||
-- * Get the current position and heading of the group.
|
||||
-- * When the unit is alive, it will tweak the template x, y and heading coordinates of the group and the embedded units to the current units positions.
|
||||
-- * Then it will respawn the re-modelled group.
|
||||
--
|
||||
-- @param Unit#UNIT self
|
||||
-- @param DCSTypes#Vec3 SpawnVec3 The position where to Spawn the new Unit at.
|
||||
-- @param #number Heading The heading of the unit respawn.
|
||||
function UNIT:ReSpawn( SpawnVec3, Heading )
|
||||
|
||||
local SpawnGroupTemplate = _DATABASE:GetGroupTemplateFromUnitName( self:GetName() )
|
||||
local SpawnGroup = self:GetGroup()
|
||||
|
||||
if SpawnGroup then
|
||||
|
||||
local Vec3 = SpawnGroup:GetVec3()
|
||||
SpawnGroupTemplate.x = Vec3.x
|
||||
SpawnGroupTemplate.y = Vec3.z
|
||||
|
||||
self:E( #SpawnGroupTemplate.units )
|
||||
for UnitID, UnitData in pairs( SpawnGroup:GetUnits() ) do
|
||||
local GroupUnit = UnitData -- Unit#UNIT
|
||||
self:E( GroupUnit:GetName() )
|
||||
if GroupUnit:IsAlive() then
|
||||
local GroupUnitVec3 = GroupUnit:GetVec3()
|
||||
local GroupUnitHeading = GroupUnit:GetHeading()
|
||||
SpawnGroupTemplate.units[UnitID].alt = GroupUnitVec3.y
|
||||
SpawnGroupTemplate.units[UnitID].x = GroupUnitVec3.x
|
||||
SpawnGroupTemplate.units[UnitID].y = GroupUnitVec3.z
|
||||
SpawnGroupTemplate.units[UnitID].heading = GroupUnitHeading
|
||||
self:E( { UnitID, SpawnGroupTemplate.units[UnitID], SpawnGroupTemplate.units[UnitID] } )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for UnitTemplateID, UnitTemplateData in pairs( SpawnGroupTemplate.units ) do
|
||||
if UnitTemplateData.name == self:GetName() then
|
||||
SpawnGroupTemplate.units[UnitTemplateID].alt = SpawnVec3.y
|
||||
SpawnGroupTemplate.units[UnitTemplateID].x = SpawnVec3.x
|
||||
SpawnGroupTemplate.units[UnitTemplateID].y = SpawnVec3.z
|
||||
SpawnGroupTemplate.units[UnitTemplateID].heading = Heading
|
||||
self:E( { UnitTemplateID, SpawnGroupTemplate.units[UnitTemplateID], SpawnGroupTemplate.units[UnitTemplateID] } )
|
||||
end
|
||||
end
|
||||
|
||||
_DATABASE:Spawn( SpawnGroupTemplate )
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user