Cap rework (#48)

- Refactored all CAP classes.
- Improved timing
- Zones are now not tied to MissionStages
  - CAPROUTE_<routeID>_<free>
  - routeID is now what is used in the naming convention.
- Units taxi back to their spawn parking space and rearm there.
  (Units destroyed while in the Rearming or Repairing state are not taken into account)
This commit is contained in:
2025-06-01 18:58:35 +02:00
committed by GitHub
parent 059081890d
commit 0233b9e2d7
21 changed files with 1519 additions and 832 deletions
@@ -159,14 +159,17 @@ function StageBase:SpawnBlueUnits()
end
function StageBase:ActivateRedStage()
if self._initialSide == 2 and self._airbase then
self._airbase:setCoalition(1)
self._logger:debug("Activate red stage for airbase: " .. self._airbase:getName())
if self._airbase and (self._initialSide == 2 or self._initialSide == 1) then
self._airbase:setCoalition(coalition.side.RED)
self._airbase:autoCapture(false)
end
self:SpawnRedUnits()
end
function StageBase:ActivateBlueStage()
self._logger:debug("Activate blue stage for airbase: " .. self._airbase:getName())
self:CleanRedUnits()
if self._buildableMission and self._buildableMission:getState() ~= "COMPLETED" then
@@ -178,7 +181,8 @@ end
function StageBase:FinaliseBlueStage()
if self._initialSide == 2 and self._airbase then
self._airbase:setCoalition(2)
self._airbase:setCoalition(coalition.side.BLUE)
self._airbase:autoCapture(false)
end
self:SpawnBlueUnits()
@@ -9,6 +9,8 @@
local BattleManager = {}
BattleManager.__index = BattleManager
local debugDrawing = false
---@param redGroups Array<SpearheadGroup>
---@param blueGroups Array<SpearheadGroup>
---@param name string
@@ -131,12 +133,10 @@ function BattleManager:LetUnitsShoot(groups, targetGroups)
}
}
if SpearheadConfig and SpearheadConfig.debugEnabled == true then
if debugDrawing == true then
self:DrawDebugLine(point, unit)
end
self._logger:debug("Red unit " .. unit:getName() .. " will shoot " .. qty .. " rounds at point: " .. tostring(point))
local controller = unit:getController()
if controller then
controller:setTask(shootTask)
@@ -241,7 +241,7 @@ function BattleManager:GetRandomPoint(origin, groupHulls)
if not hull then return nil end
local shootPoints = Spearhead.Util.GetTangentHullPointsFromOrigin(hull, origin)
if SpearheadConfig and SpearheadConfig.debugEnabled == true then
if debugDrawing == true then
self:DrawDebugZone({ hull })
end
@@ -271,8 +271,8 @@ function MissionCommandsHelper:AddAllMissionCommandsToGroup(groupID)
local mission = self.missionsByCode[code]
if mission and mission.priority == "primary" then
count = count + 1
if count <= perFolder then
local copied = Spearhead.Util.copyTable(path)
if count <= perFolder then
local copied = Spearhead.Util.deepCopyTable(path)
self:addMissionCommands(groupID, copied, mission)
else
local name = "Next Menu ..."
@@ -294,7 +294,7 @@ function MissionCommandsHelper:AddAllMissionCommandsToGroup(groupID)
if mission and mission.priority == "secondary" then
count = count + 1
if count <= perFolder then
local copied = Spearhead.Util.copyTable(path)
local copied = Spearhead.Util.deepCopyTable(path)
self:addMissionCommands(groupID, copied, mission)
else
local name = "Next Menu ..."
@@ -29,6 +29,7 @@ function SupplyUnitsTracker.getOrCreate(logLevel)
singleton._supplyUnitsByName = {}
singleton._droppedCrates = {}
singleton._registeredHubs = {}
singleton._supplyUnitSpawnedListener = {}
singleton._commandsHelper = Spearhead.classes.stageClasses.helpers.MissionCommandsHelper.getOrCreate(singleton._logger.LogLevel)