remove pQueue by y-axis from CharacterGrid as sorting is done now during

the draw
This commit is contained in:
PeaAshMeter 2026-05-03 20:29:31 +03:00
parent 790d63d37f
commit d41f9fb542

View File

@ -1,8 +1,6 @@
local utils = require "lib.utils.utils" local utils = require "lib.utils.utils"
local pQueue = require "lib.utils.priority_queue"
--- @class CharacterGrid : Grid --- @class CharacterGrid : Grid
--- @field __grid {string: Id|nil} --- @field __grid {string: Id|nil}
--- @field yOrderQueue PriorityQueue<Character> очередь отрисовки сверху вниз
local grid = setmetatable({}, require "lib.level.grid.base") local grid = setmetatable({}, require "lib.level.grid.base")
grid.__index = grid grid.__index = grid
@ -29,22 +27,13 @@ function grid:add(id)
end end
end end
--- @param a Character
--- @param b Character
local function drawCmp(a, b)
--- @TODO: это захардкожено, надо разделить поведения
return a:has(Tree.behaviors.positioned).position.y < b:has(Tree.behaviors.positioned).position.y
end
--- fills the grid with the actual data --- fills the grid with the actual data
--- ---
--- should be called as early as possible during every tick --- should be called as early as possible during every tick
function grid:reload() function grid:reload()
self:reset() self:reset()
self.yOrderQueue = pQueue.new(drawCmp)
utils.each(Tree.level.characters, function(c) utils.each(Tree.level.characters, function(c)
self:add(c.id) self:add(c.id)
self.yOrderQueue:insert(c)
end) end)
end end