reduce use of Map.Topleft and Map.Bottomright as requested in #8549

This commit is contained in:
clemty
2015-09-24 21:03:36 +02:00
parent bbdd597917
commit d4e1b1ba48
6 changed files with 49 additions and 60 deletions

View File

@@ -53,23 +53,16 @@ OnAnyDamaged = function(actors, func)
end)
end
CheckForBase = function(player, buildings)
local checked = { }
local baseBuildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(actor)
if actor.Owner ~= Nod or Utils.Any(checked, function(bldng) return bldng.Type == actor.Type end) then
return false
end
CheckForBase = function(player)
local buildings = 0
local found = false
for i = 1, #buildings, 1 do
if actor.Type == buildings[i] then
found = true
checked[#checked + 1] = actor
end
Utils.Do(NodBaseBuildings, function(name)
if #player.GetActorsByType(name) > 0 then
buildings = buildings + 1
end
return found
end)
return #baseBuildings >= 3
return buildings == #NodBaseBuildings
end
DfndTriggerFunction = function()
@@ -231,7 +224,7 @@ Tick = function()
end
end
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not Nod.IsObjectiveCompleted(NodObjective1) and CheckForBase(Nod, NodBaseBuildings) then
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not Nod.IsObjectiveCompleted(NodObjective1) and CheckForBase(Nod) then
Nod.MarkCompletedObjective(NodObjective1)
end