2025-06-04 05:02:57 +08:00

43 lines
804 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CullingIDUtility = class("CullingIDUtility")
local maxID = 1500
local startID = 1
local usedFlags = {}
for i=1,maxID do
usedFlags[i] = false
end
function CullingIDUtility.GetID()
local i = startID
for j=1,maxID do
if(i >= maxID) then
i = 1
end
if(usedFlags[i] == false) then
usedFlags[i] = true
startID = i + 1;
break;
end
if(j>=maxID) then
errorLog("CullingIDUtility - 有效的cullingID已被用完請擴大id池子")
i = 0
else
i = i + 1
end
end
-- LogUtility.InfoFormat("CullingIDUtility.GetID {0}",i)
return i
end
function CullingIDUtility.ClearID(i)
if(i~=nil) then
if(usedFlags[i]) then
usedFlags[i] = false
startID = i
if(i>=maxID) then
startID = 1;
end
-- LogUtility.InfoFormat("CullingIDUtility.ClearID {0}",i)
end
end
end