remove pQueue by y-axis from CharacterGrid as sorting is done now during
the draw
This commit is contained in:
parent
790d63d37f
commit
d41f9fb542
@ -1,8 +1,6 @@
|
||||
local utils = require "lib.utils.utils"
|
||||
local pQueue = require "lib.utils.priority_queue"
|
||||
--- @class CharacterGrid : Grid
|
||||
--- @field __grid {string: Id|nil}
|
||||
--- @field yOrderQueue PriorityQueue<Character> очередь отрисовки сверху вниз
|
||||
local grid = setmetatable({}, require "lib.level.grid.base")
|
||||
grid.__index = grid
|
||||
|
||||
@ -29,22 +27,13 @@ function grid:add(id)
|
||||
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
|
||||
---
|
||||
--- should be called as early as possible during every tick
|
||||
function grid:reload()
|
||||
self:reset()
|
||||
self.yOrderQueue = pQueue.new(drawCmp)
|
||||
utils.each(Tree.level.characters, function(c)
|
||||
self:add(c.id)
|
||||
self.yOrderQueue:insert(c)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user