Buildable (#36)
- Buildable missions now working. - FARPS and BLUESAM zones are now buildable. - Secondary Logistics missions are created as buildables become available. - Logistic missions can be "marked" with a MAP marker. - Supplies can only be picked up in a SUPPLYHUB zone. - SUPPLYHUB zones are active once their parents are active. A supplyhub parent can be oneof: FARP, AIRBASE, STAGE. - Required supplies for a zone can be configured in kilos. - Crates can be picked up with 1000 or 2000 kilo per crate. - Max load for a helicopter is set based on public data. - TO COME: Sling load options
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
|
||||
---@class BlueSam
|
||||
---@class BlueSam : OnCrateDroppedListener, MissionCompleteListener
|
||||
---@field Activate fun(self: BlueSam)
|
||||
---@field private _database Database
|
||||
---@field private _logger Logger
|
||||
---@field private _zoneName string
|
||||
---@field private _blueGroups Array<SpearheadGroup>
|
||||
---@field private _cleanupUnits table<string, boolean>
|
||||
---@field private _buildableCrateKilos number?
|
||||
---@field private _receivedKilos number?
|
||||
---@field private _unitsPerCrate number?
|
||||
---@field private _buildableMission BuildableMission?
|
||||
local BlueSam = {}
|
||||
|
||||
---@param database Database
|
||||
---@param logger Logger
|
||||
---@param zoneName string
|
||||
---@return BlueSam?
|
||||
function BlueSam.New(database, logger, zoneName)
|
||||
BlueSam.__index = BlueSam
|
||||
local self = setmetatable({}, BlueSam)
|
||||
@@ -19,56 +27,114 @@ function BlueSam.New(database, logger, zoneName)
|
||||
self._blueGroups = {}
|
||||
self._cleanupUnits = {}
|
||||
|
||||
do
|
||||
local groups = database:getBlueSamGroupsInZone(zoneName)
|
||||
local blueSamData = database:getBlueSamDataForZone(zoneName)
|
||||
|
||||
---@type table<string, Vec3>
|
||||
local blueUnitsPos = {}
|
||||
if blueSamData == nil then
|
||||
logger:error("Blue SAM data not found for zone: " .. zoneName)
|
||||
return nil
|
||||
end
|
||||
|
||||
---@type table<string, Vec3>
|
||||
local redUnitsPos = {}
|
||||
self._buildableCrateKilos = blueSamData.buildingKilos
|
||||
self._receivedKilos = 0
|
||||
|
||||
for _, groupName in pairs(groups) do
|
||||
local SpearheadGroup = Spearhead.classes.stageClasses.Groups.SpearheadGroup.New(groupName)
|
||||
if SpearheadGroup then
|
||||
|
||||
if SpearheadGroup:GetCoalition() == 2 then
|
||||
table.insert(self._blueGroups, SpearheadGroup)
|
||||
end
|
||||
---@type table<string, Vec3>
|
||||
local blueUnitsPos = {}
|
||||
|
||||
---@type table<string, Vec3>
|
||||
local redUnitsPos = {}
|
||||
|
||||
for _, unit in pairs(SpearheadGroup:GetUnits()) do
|
||||
if SpearheadGroup:GetCoalition() == 1 then
|
||||
table.insert(blueUnitsPos, unit:getPoint())
|
||||
elseif SpearheadGroup:GetCoalition() == 2 then
|
||||
table.insert(redUnitsPos, unit:getPoint())
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for _, groupName in pairs(blueSamData.groups) do
|
||||
local SpearheadGroup = Spearhead.classes.stageClasses.Groups.SpearheadGroup.New(groupName)
|
||||
if SpearheadGroup then
|
||||
|
||||
if SpearheadGroup:GetCoalition() == 2 then
|
||||
table.insert(self._blueGroups, SpearheadGroup)
|
||||
end
|
||||
SpearheadGroup:Destroy()
|
||||
end
|
||||
|
||||
do -- check cleanup requirements
|
||||
-- Checks is any of the units are withing range (5m) of another unit.
|
||||
-- If so, make sure to add them to the cleanup list.
|
||||
|
||||
local cleanup_distance = 5
|
||||
for blueUnitName, blueUnitPos in pairs(blueUnitsPos) do
|
||||
for redUnitName, redUnitPos in pairs(redUnitsPos) do
|
||||
local distance = Spearhead.Util.VectorDistance3d(blueUnitPos, redUnitPos)
|
||||
if distance <= cleanup_distance then
|
||||
self._cleanupUnits[redUnitName] = true
|
||||
end
|
||||
|
||||
for _, unit in pairs(SpearheadGroup:GetUnits()) do
|
||||
if SpearheadGroup:GetCoalition() == 1 then
|
||||
table.insert(blueUnitsPos, unit:getPoint())
|
||||
elseif SpearheadGroup:GetCoalition() == 2 then
|
||||
table.insert(redUnitsPos, unit:getPoint())
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
SpearheadGroup:Destroy()
|
||||
end
|
||||
|
||||
--Cleanup units
|
||||
local cleanup_distance = 5
|
||||
for blueUnitName, blueUnitPos in pairs(blueUnitsPos) do
|
||||
for redUnitName, redUnitPos in pairs(redUnitsPos) do
|
||||
local distance = Spearhead.Util.VectorDistance3d(blueUnitPos, redUnitPos)
|
||||
if distance <= cleanup_distance then
|
||||
self._cleanupUnits[redUnitName] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self._buildableCrateKilos ~= nil and self._buildableCrateKilos ~= 0 then
|
||||
self._logger:debug("Buildable mission creating for zone: " .. zoneName .. " with crates: " .. self._buildableCrateKilos)
|
||||
|
||||
local noLandingZone = self:GetNoLandingZone()
|
||||
|
||||
self._buildableMission = Spearhead.classes.stageClasses.missions.BuildableMission.new(database, logger, zoneName, noLandingZone, self._buildableCrateKilos, "SAM_CRATE")
|
||||
self._buildableMission:AddOnCrateDroppedOfListener(self)
|
||||
self._buildableMission:AddMissionCompleteListener(self)
|
||||
end
|
||||
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
---@private
|
||||
---@return SpearheadTriggerZone?
|
||||
function BlueSam:GetNoLandingZone()
|
||||
|
||||
---@type Array<Vec2>
|
||||
local points = {}
|
||||
|
||||
for _, group in pairs(self._blueGroups) do
|
||||
for _, unitPos in pairs(group:GetAllUnitPositions()) do
|
||||
table.insert(points, { x = unitPos.x, y = unitPos.z })
|
||||
end
|
||||
end
|
||||
|
||||
local vecs = Spearhead.Util.getConvexHull(points)
|
||||
|
||||
local zone = Spearhead.DcsUtil.getZoneByName(self._zoneName)
|
||||
if zone == nil then
|
||||
self._logger:error("Zone not found: " .. self._zoneName)
|
||||
return nil
|
||||
end
|
||||
|
||||
---@type SpearheadTriggerZone
|
||||
local spearheadZone = {
|
||||
name = self._zoneName .. "_noland",
|
||||
location = zone.location,
|
||||
verts = vecs,
|
||||
radius = 0,
|
||||
zone_type = "Polygon"
|
||||
}
|
||||
|
||||
return spearheadZone
|
||||
end
|
||||
|
||||
function BlueSam:Activate()
|
||||
|
||||
if self._buildableMission == nil then
|
||||
self:SpawnGroups()
|
||||
else
|
||||
self._buildableMission:SpawnActive()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function BlueSam:SpawnGroups()
|
||||
for unitName, needsCleanup in pairs(self._cleanupUnits) do
|
||||
if needsCleanup == true then
|
||||
Spearhead.DcsUtil.DestroyUnit(unitName)
|
||||
@@ -86,6 +152,24 @@ function BlueSam:Activate()
|
||||
end
|
||||
|
||||
|
||||
---@param buildableMission BuildableMission
|
||||
---@param kilos number
|
||||
function BlueSam:OnCrateDroppedOff(buildableMission, kilos)
|
||||
|
||||
self._logger:debug("Crate dropped off in zone: " .. self._zoneName)
|
||||
self._receivedKilos = self._receivedKilos + kilos
|
||||
|
||||
end
|
||||
|
||||
---@param buildableMission Mission
|
||||
function BlueSam:OnMissionComplete(buildableMission)
|
||||
self._logger:debug("Buildable mission complete for zone: " .. self._zoneName)
|
||||
|
||||
self:SpawnGroups()
|
||||
|
||||
end
|
||||
|
||||
|
||||
if Spearhead == nil then Spearhead = {} end
|
||||
if Spearhead.classes == nil then Spearhead.classes = {} end
|
||||
if Spearhead.classes.stageClasses == nil then Spearhead.classes.stageClasses = {} end
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
|
||||
|
||||
---@class FarpZone
|
||||
---@class FarpZone : OnCrateDroppedListener, MissionCompleteListener
|
||||
---@field private _startingFarp boolean
|
||||
---@field private _groups Array<SpearheadGroup>
|
||||
---@field private _padNames Array<string>
|
||||
---@field private _database Database
|
||||
---@field private _logger Logger
|
||||
---@field private _zoneName string
|
||||
---@field private _requiredBuildingKilos number
|
||||
---@field private _receivedBuildingKilos number
|
||||
---@field private _groupsPerKilo number
|
||||
---@field private _buildableMission BuildableMission?
|
||||
---@field private _supplyHubs Array<SupplyHub>
|
||||
local FarpZone = {}
|
||||
FarpZone.__index = FarpZone
|
||||
|
||||
@@ -36,22 +41,50 @@ function FarpZone.New(database, logger, zoneName)
|
||||
local farpData = database:getFarpDataForZone(zoneName)
|
||||
self._groups = {}
|
||||
self._padNames = {}
|
||||
self._supplyHubs = {}
|
||||
|
||||
|
||||
if farpData then
|
||||
self._padNames = farpData.padNames
|
||||
|
||||
for _, supplyHubName in pairs(farpData.supplyHubNames) do
|
||||
local supplyHub = Spearhead.classes.stageClasses.SpecialZones.SupplyHub.new(database, logger, supplyHubName)
|
||||
if supplyHub then
|
||||
table.insert(self._supplyHubs, supplyHub)
|
||||
end
|
||||
end
|
||||
|
||||
for _, groupName in pairs(farpData.groups) do
|
||||
local group = Spearhead.classes.stageClasses.Groups.SpearheadGroup.New(groupName)
|
||||
table.insert(self._groups, group)
|
||||
group:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
self._requiredBuildingKilos = farpData.buildingKilos
|
||||
self._receivedBuildingKilos = 0
|
||||
|
||||
if self._requiredBuildingKilos ~= nil and self._requiredBuildingKilos > 0 then
|
||||
self._logger:debug("FARP zone " .. zoneName .. " requires " .. self._requiredBuildingKilos .. " crates to be dropped off")
|
||||
local noLandingZone = self:GetNoLandingZone()
|
||||
self._buildableMission = Spearhead.classes.stageClasses.missions.BuildableMission.new(database, logger, zoneName, noLandingZone, self._requiredBuildingKilos, "FARP_CRATE")
|
||||
if self._buildableMission then
|
||||
self._buildableMission:AddOnCrateDroppedOfListener(self)
|
||||
self._buildableMission:AddMissionCompleteListener(self)
|
||||
end
|
||||
|
||||
local totalGroups = Spearhead.Util.tableLength(self._groups)
|
||||
self._groupsPerKilo = totalGroups / self._requiredBuildingKilos
|
||||
end
|
||||
end
|
||||
if self._buildableMission == nil then
|
||||
self._logger:debug("No buildable mission for zone: " .. zoneName)
|
||||
end
|
||||
self:Deactivate()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---@return boolean
|
||||
function FarpZone:IsStartingFarp()
|
||||
return self._startingFarp
|
||||
@@ -59,14 +92,112 @@ end
|
||||
|
||||
function FarpZone:Activate()
|
||||
self._logger:info("Activating FARP zone: " .. self._zoneName)
|
||||
self:BuildUp()
|
||||
self:SetPadsBlue()
|
||||
|
||||
if self._buildableMission == nil then
|
||||
self:BuildUp()
|
||||
self:SetPadsBlue()
|
||||
self:ActivateSupplyHubs()
|
||||
else
|
||||
self._buildableMission:SpawnActive()
|
||||
end
|
||||
end
|
||||
|
||||
function FarpZone:Deactivate()
|
||||
|
||||
self:NeutralisePads()
|
||||
end
|
||||
|
||||
---@class UnpackCrateParam
|
||||
---@field self FarpZone
|
||||
---@field kilos number
|
||||
---@field groupsPerKilo number
|
||||
---@field kilosPerSecond number
|
||||
---@field unpackedItems number
|
||||
---@field unpackedKilos number
|
||||
|
||||
---@param params UnpackCrateParam
|
||||
---@param time number
|
||||
local startUnpackingCrate = function(params, time)
|
||||
local unpacked = params.unpackedKilos + (params.kilosPerSecond * 2)
|
||||
local alreadySpawned = params.unpackedItems / params.groupsPerKilo
|
||||
local diff = unpacked - alreadySpawned
|
||||
|
||||
local amount = math.floor(diff * params.groupsPerKilo)
|
||||
local spawned = params.self:SpawnAmount(amount)
|
||||
|
||||
params.unpackedItems = params.unpackedItems + amount
|
||||
params.unpackedKilos = unpacked
|
||||
if params.unpackedKilos >= params.kilos or spawned == false then
|
||||
params.self:FinaliseCrate(params.kilos)
|
||||
return
|
||||
end
|
||||
|
||||
return time + 2
|
||||
end
|
||||
|
||||
---comment
|
||||
---@param amount number
|
||||
---@return boolean
|
||||
function FarpZone:SpawnAmount(amount)
|
||||
|
||||
local function spawnOne()
|
||||
for _, group in pairs(self._groups) do
|
||||
if group:IsSpawned() == false then
|
||||
group:Spawn()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
for i = 1, amount do
|
||||
local spawned = spawnOne()
|
||||
if spawned ~= true then
|
||||
self._logger:debug("No more groups to spawn in zone: " .. self._zoneName)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
---@param buildableMission BuildableMission
|
||||
function FarpZone:OnCrateDroppedOff(buildableMission, kilos)
|
||||
|
||||
self._logger:debug("Crate dropped off in zone: " .. self._zoneName)
|
||||
|
||||
local timeToUnpack = (kilos / 500) * 15
|
||||
|
||||
---@type UnpackCrateParam
|
||||
local params = {
|
||||
self = self,
|
||||
groupsPerKilo = self._groupsPerKilo,
|
||||
unpackedItems = 0,
|
||||
kilosPerSecond = kilos/timeToUnpack,
|
||||
unpackedKilos = 0,
|
||||
kilos = kilos
|
||||
}
|
||||
|
||||
timer.scheduleFunction(startUnpackingCrate, params, timer.getTime() + 2)
|
||||
|
||||
end
|
||||
|
||||
---@param kilos number
|
||||
function FarpZone:FinaliseCrate(kilos)
|
||||
self._receivedBuildingKilos = self._receivedBuildingKilos + kilos
|
||||
if self._receivedBuildingKilos >= self._requiredBuildingKilos then
|
||||
self:BuildUp()
|
||||
self:SetPadsBlue()
|
||||
self:ActivateSupplyHubs()
|
||||
end
|
||||
end
|
||||
|
||||
---@param buildableMission Mission
|
||||
function FarpZone:OnMissionComplete(buildableMission)
|
||||
self._logger:debug("Buildable mission complete for zone: " .. self._zoneName)
|
||||
|
||||
-- self:BuildUp()
|
||||
-- self:SetPadsBlue()
|
||||
-- self:ActivateSupplyHubs()
|
||||
|
||||
end
|
||||
|
||||
@@ -76,6 +207,13 @@ function FarpZone:BuildUp()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function FarpZone:ActivateSupplyHubs()
|
||||
for _, supplyHub in pairs(self._supplyHubs) do
|
||||
supplyHub:Activate()
|
||||
end
|
||||
end
|
||||
|
||||
---@private
|
||||
function FarpZone:NeutralisePads()
|
||||
for _, name in pairs(self._padNames) do
|
||||
@@ -99,6 +237,39 @@ function FarpZone:SetPadsBlue()
|
||||
end
|
||||
|
||||
|
||||
---@private
|
||||
---@return SpearheadTriggerZone?
|
||||
function FarpZone:GetNoLandingZone()
|
||||
|
||||
---@type Array<Vec2>
|
||||
local points = {}
|
||||
|
||||
for _, group in pairs(self._groups) do
|
||||
for _, unitPos in pairs(group:GetAllUnitPositions()) do
|
||||
table.insert(points, { x = unitPos.x, y = unitPos.z })
|
||||
end
|
||||
end
|
||||
|
||||
local vecs = Spearhead.Util.getConvexHull(points)
|
||||
|
||||
local zone = Spearhead.DcsUtil.getZoneByName(self._zoneName)
|
||||
if zone == nil then
|
||||
self._logger:error("Zone not found: " .. self._zoneName)
|
||||
return nil
|
||||
end
|
||||
|
||||
---@type SpearheadTriggerZone
|
||||
local spearheadZone = {
|
||||
name = self._zoneName .. "_noland",
|
||||
location = zone.location,
|
||||
verts = vecs,
|
||||
radius = 0,
|
||||
zone_type = "Polygon"
|
||||
}
|
||||
|
||||
return spearheadZone
|
||||
end
|
||||
|
||||
if Spearhead == nil then Spearhead = {} end
|
||||
if Spearhead.classes == nil then Spearhead.classes = {} end
|
||||
if Spearhead.classes.stageClasses == nil then Spearhead.classes.stageClasses = {} end
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
---@field private _cleanup_units table<string, boolean>
|
||||
---@field private _airbase Airbase?
|
||||
---@field private _initialSide number?
|
||||
---@field private _supplyHubs Array<SupplyHub>
|
||||
local StageBase = {}
|
||||
|
||||
---comment
|
||||
---@param databaseManager Database
|
||||
---@param logger table
|
||||
---@param airbaseName string
|
||||
---@return StageBase
|
||||
---@return StageBase?
|
||||
function StageBase.New(databaseManager, logger, airbaseName)
|
||||
|
||||
StageBase.__index = StageBase
|
||||
@@ -26,45 +27,51 @@ function StageBase.New(databaseManager, logger, airbaseName)
|
||||
self._red_groups = {}
|
||||
self._blue_groups = {}
|
||||
self._cleanup_units = {}
|
||||
self._supplyHubs = {}
|
||||
|
||||
self._airbase = Airbase.getByName(airbaseName)
|
||||
self._initialSide = Spearhead.DcsUtil.getStartingCoalition(self._airbase)
|
||||
|
||||
do --init
|
||||
|
||||
local airbaseData = databaseManager:getAirbaseDataForZone(airbaseName)
|
||||
if airbaseData == nil then
|
||||
logger:error("Airbase data not found for airbase: " .. airbaseName)
|
||||
return nil
|
||||
end
|
||||
|
||||
---@type table<string, Vec3>
|
||||
local redUnitsPos = {}
|
||||
|
||||
---@type table<string, Vec3>
|
||||
local blueUnitsPos = {}
|
||||
|
||||
do -- fill tables
|
||||
local redGroups = databaseManager:getRedGroupsAtAirbase(airbaseName)
|
||||
if redGroups then
|
||||
for _, groupName in pairs(redGroups) do
|
||||
local shGroup = Spearhead.classes.stageClasses.Groups.SpearheadGroup.New(groupName)
|
||||
table.insert(self._red_groups, shGroup)
|
||||
for _, groupName in pairs(airbaseData.RedGroups) do
|
||||
local shGroup = Spearhead.classes.stageClasses.Groups.SpearheadGroup.New(groupName)
|
||||
table.insert(self._red_groups, shGroup)
|
||||
|
||||
for _, unit in pairs(shGroup:GetUnits()) do
|
||||
redUnitsPos[unit:getName()] = unit:getPoint()
|
||||
end
|
||||
|
||||
shGroup:Destroy()
|
||||
end
|
||||
for _, unit in pairs(shGroup:GetUnits()) do
|
||||
redUnitsPos[unit:getName()] = unit:getPoint()
|
||||
end
|
||||
|
||||
local blueGroups = databaseManager:getBlueGroupsAtAirbase(airbaseName)
|
||||
if blueGroups then
|
||||
for _, groupName in pairs(blueGroups) do
|
||||
local shGroup = Spearhead.classes.stageClasses.Groups.SpearheadGroup.New(groupName)
|
||||
table.insert(self._blue_groups, shGroup)
|
||||
shGroup:Destroy()
|
||||
end
|
||||
|
||||
for _, unit in pairs(shGroup:GetUnits()) do
|
||||
blueUnitsPos[unit:getName()] = unit:getPoint()
|
||||
end
|
||||
for _, groupName in pairs(airbaseData.BlueGroups) do
|
||||
local shGroup = Spearhead.classes.stageClasses.Groups.SpearheadGroup.New(groupName)
|
||||
table.insert(self._blue_groups, shGroup)
|
||||
|
||||
shGroup:Destroy()
|
||||
for _, unit in pairs(shGroup:GetUnits()) do
|
||||
blueUnitsPos[unit:getName()] = unit:getPoint()
|
||||
end
|
||||
|
||||
shGroup:Destroy()
|
||||
end
|
||||
|
||||
for _, supplyHubName in pairs(airbaseData.supplyHubNames) do
|
||||
local supplyHub = Spearhead.classes.stageClasses.SpecialZones.SupplyHub.new(databaseManager, logger, supplyHubName)
|
||||
if supplyHub then
|
||||
table.insert(self._supplyHubs, supplyHub)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -151,6 +158,10 @@ function StageBase:ActivateBlueStage()
|
||||
|
||||
self:CleanRedUnits()
|
||||
self:SpawnBlueUnits()
|
||||
|
||||
for _, hub in pairs(self._supplyHubs) do
|
||||
hub:Activate()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
---@class SupplyHub
|
||||
---@field private _database Database
|
||||
---@field private _logger Logger
|
||||
---@field private _zoneName string
|
||||
---@field private _zone SpearheadTriggerZone?
|
||||
---@field private _supplyUnitsTracker SupplyUnitsTracker
|
||||
---@field private _isCommmandAdded table<string, boolean>
|
||||
---@field private _missionCommandsHelper MissionCommandsHelper
|
||||
---@field private _inZone table<string, boolean>
|
||||
---@field private _drawID number
|
||||
---@field private _cargoInUnits table<table<string, number>>
|
||||
---@field private _activeAtStart boolean
|
||||
---@field private _active boolean
|
||||
local SupplyHub = {}
|
||||
|
||||
---@param database Database
|
||||
---@param logger Logger
|
||||
---@param zoneName string
|
||||
---@return SupplyHub?
|
||||
function SupplyHub.new(database, logger, zoneName)
|
||||
|
||||
SupplyHub.__index = SupplyHub
|
||||
local self = setmetatable({}, SupplyHub)
|
||||
|
||||
self._database = database
|
||||
self._logger = logger
|
||||
self._zoneName = zoneName
|
||||
|
||||
local split = Spearhead.Util.split_string(zoneName, "_")
|
||||
if string.lower(split[2]) == "a" then
|
||||
self._activeAtStart = true
|
||||
else
|
||||
self._activeAtStart = false
|
||||
end
|
||||
|
||||
self._zone = Spearhead.DcsUtil.getZoneByName(zoneName)
|
||||
|
||||
self._supplyUnitsTracker = Spearhead.classes.stageClasses.helpers.SupplyUnitsTracker.getOrCreate(logger.LogLevel)
|
||||
self._inZone = {}
|
||||
self._missionCommandsHelper = Spearhead.classes.stageClasses.helpers.MissionCommandsHelper.getOrCreate(logger.LogLevel)
|
||||
|
||||
self._logger:debug("Creating Supply Hub zone: " .. self._zoneName)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function SupplyHub:IsActiveFromStart()
|
||||
return self._activeAtStart
|
||||
end
|
||||
|
||||
function SupplyHub:GetZoneName()
|
||||
return self._zoneName
|
||||
end
|
||||
|
||||
---@return SpearheadTriggerZone?
|
||||
function SupplyHub:GetZone()
|
||||
return self._zone
|
||||
end
|
||||
|
||||
function SupplyHub:Activate()
|
||||
if self._active == true then
|
||||
return
|
||||
end
|
||||
|
||||
self._active = true
|
||||
|
||||
self._logger:debug("Activating Supply Hub zone: " .. self._zoneName)
|
||||
|
||||
local zone = Spearhead.DcsUtil.getZoneByName(self._zoneName)
|
||||
if zone and self._drawID == nil then
|
||||
---@type DrawColor
|
||||
local fillColor = { r=0, g=1, b=0, a=0.2 }
|
||||
---@type DrawColor
|
||||
local lineColor = { r=0, g=1, b=0, a=1}
|
||||
local lineStyle = 1
|
||||
self._drawID = Spearhead.DcsUtil.DrawZone(zone, lineColor, fillColor, lineStyle)
|
||||
end
|
||||
|
||||
self._supplyUnitsTracker:RegisterHub(self)
|
||||
|
||||
end
|
||||
|
||||
|
||||
if not Spearhead then Spearhead = {} end
|
||||
if Spearhead.classes == nil then Spearhead.classes = {} end
|
||||
if Spearhead.classes.stageClasses == nil then Spearhead.classes.stageClasses = {} end
|
||||
if Spearhead.classes.stageClasses.SpecialZones == nil then Spearhead.classes.stageClasses.SpecialZones = {} end
|
||||
Spearhead.classes.stageClasses.SpecialZones.SupplyHub = SupplyHub
|
||||
Reference in New Issue
Block a user