36 lines
811 B
Lua
36 lines
811 B
Lua
--- @class Selector
|
|
--- @field id integer
|
|
local selector = {}
|
|
|
|
local function new()
|
|
return setmetatable({}, selector)
|
|
end
|
|
|
|
--- @param characterId integer
|
|
function selector:select(characterId)
|
|
self.id = characterId
|
|
end
|
|
|
|
function selector:deselect()
|
|
self.id = nil
|
|
end
|
|
|
|
--- TODO: сделать обработчик селектора
|
|
--- @param camera Camera
|
|
function selector:update(camera, dt)
|
|
if self.id then
|
|
return
|
|
end
|
|
local mousePosition = camera:toWorldPosition(Vec3 { love.mouse.getX(), love.mouse.getY() }):floor()
|
|
local characterPosition = Tree.level.positionGrid[mousePosition.x][mousePosition.y]
|
|
if Tree.controls:isDown("select") then
|
|
if characterPosition then
|
|
self:select(characterPosition)
|
|
end
|
|
end
|
|
end
|
|
|
|
return {
|
|
new = new
|
|
}
|