Merge pull request #2371 from shaji-Dev/develop

[ADDED] `ValidateAndRepositionGroundUnits` to OPSGROUP
This commit is contained in:
Thomas 2025-08-26 06:21:58 +02:00 committed by GitHub
commit 2ff630d394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -1823,6 +1823,7 @@ function LEGION:_CreateFlightGroup(asset)
--- ---
opsgroup=ARMYGROUP:New(asset.spawngroupname) opsgroup=ARMYGROUP:New(asset.spawngroupname)
opsgroup:SetValidateAndRepositionGroundUnits(self.ValidateAndRepositionGroundUnits)
elseif self:IsFleet() then elseif self:IsFleet() then

View File

@ -7847,6 +7847,10 @@ function OPSGROUP:_Spawn(Delay, Template)
-- Debug output. -- Debug output.
self:T2({Template=Template}) self:T2({Template=Template})
if self:IsArmygroup() and self.ValidateAndRepositionGroundUnits then
UTILS.ValidateAndRepositionGroundUnits(Template.units)
end
-- Spawn new group. -- Spawn new group.
self.group=_DATABASE:Spawn(Template) self.group=_DATABASE:Spawn(Template)
--local countryID=self.group:GetCountry() --local countryID=self.group:GetCountry()
@ -13955,6 +13959,15 @@ function OPSGROUP:_GetDetectedTarget()
return targetgroup, targetdist return targetgroup, targetdist
end end
--- This function uses Disposition and other fallback logic to find better ground positions for ground units.
--- NOTE: This is not a spawn randomizer.
--- It will try to find clear ground locations avoiding trees, water, roads, runways, map scenery, statics and other units in the area and modifies the provided positions table.
--- Maintains the original layout and unit positions as close as possible by searching for the next closest valid position to each unit.
--- Uses UTILS.ValidateAndRepositionGroundUnits.
-- @param #boolean Enabled Enable/disable the feature.
function OPSGROUP:SetValidateAndRepositionGroundUnits(Enabled)
self.ValidateAndRepositionGroundUnits = Enabled
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------