Skip to content

Commit

Permalink
Fixed debugBlip on ComboZones
Browse files Browse the repository at this point in the history
Given ComboZones are used a lot by starting them empty and using AddZone overtime, doing a one-and-done style addDebugBlip won't work in most cases, and the print wouldn't make much sense either. To fix, on first call addDebugBlip will add blips to all the zones currently in the ComboZone, then during each AddZone() call, if debugBlip is true on the ComboZone, addDebugBlip() will be called on the added zone.
  • Loading branch information
mkafrin committed Oct 19, 2020
1 parent 7739f41 commit 8dcf830
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions ComboZone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ function ComboZone:AddZone(zone)
if self.useGrid == nil and newIndex >= 25 then
self.useGrid = true
end
if self.debugBlip then zone:addDebugBlip() end
end

function ComboZone:isPointInside(point)
Expand Down Expand Up @@ -298,25 +299,12 @@ function ComboZone:onPlayerInOutExhaustive(onPointInOutCb, waitInMS)
end

function ComboZone:addDebugBlip()
self.debugBlip = true
local zones = self.zones
local polyCount, boxCount, circleCount, entityCount = 0, 0, 0, 0
for i=1, #zones do
local zone = zones[i]
if zone then
zone:addDebugBlip()
if zone.isPolyZone then polyCount = polyCount + 1 end
if zone.isBoxZone then boxCount = boxCount + 1 end
if zone.isCircleZone then circleCount = circleCount + 1 end
if zone.isEntityZone then entityCount = entityCount + 1 end
end
if zone then zone:addDebugBlip() end
end
local name = self.name ~= nil and ("\"" .. self.name .. "\"") or nil
print("[PolyZone] Debug for ComboZone { name = " .. tostring(name) .. " }:")
print("[PolyZone] Total zones: " .. #zones)
print("[PolyZone] BoxZones: " .. boxCount)
print("[PolyZone] CircleZones: " .. circleCount)
print("[PolyZone] PolyZones: " .. polyCount)
print("[PolyZone] EntityZones: " .. entityCount)
end

function ComboZone:setPaused(paused)
Expand Down

0 comments on commit 8dcf830

Please sign in to comment.