Compare commits

..

No commits in common. "7d4c85683202d9a883a9178494260a139708dc1f" and "70e0c52d593258845fd410e9c06b41d73984b280" have entirely different histories.

2 changed files with 6 additions and 21 deletions

View File

@ -10,8 +10,6 @@ local utils = require "lib.utils.utils"
local level = {} local level = {}
level.__index = level level.__index = level
local path = nil
--- @param type "procedural"|"handmaded" --- @param type "procedural"|"handmaded"
--- @param template Procedural|Handmaded --- @param template Procedural|Handmaded
local function new(type, template) local function new(type, template)
@ -27,25 +25,11 @@ local function new(type, template)
}, level) }, level)
end end
local mposCache = nil
function level:update(dt) function level:update(dt)
self.characterGrid:reset() self.characterGrid:reset()
utils.each(self.characters, function(el) utils.each(self.characters, function(el)
el:update(dt) el:update(dt)
end) end)
if self.characters[self.selector.id] then
local charPos = self.characters[self.selector.id].logic.mapLogic.position:floor()
--- @type Vec3
local mpos = self.camera:toWorldPosition(Vec3 { love.mouse.getX(), love.mouse.getY() }):floor()
-- ДУШИ здесь больше нет, приводите рыжих обратно
if not path or tostring(mpos) ~= mposCache then
path = require "lib.pathfinder" (charPos, mpos) -- ?????
end
mposCache = tostring(mpos)
-- path = (require "lib.pathfinder")(charPos, mpos)
end
self.camera:update(dt) self.camera:update(dt)
self.selector:update(dt) self.selector:update(dt)
end end
@ -54,7 +38,12 @@ function level:draw()
self.map:draw() self.map:draw()
--- Это отрисовка пути персонажа к мышке --- Это отрисовка пути персонажа к мышке
if self.selector.id and path then if self.selector.id then
local charPos = self.characters[self.selector.id].logic.mapLogic.position:floor()
--- @type Vec3
local mpos = self.camera:toWorldPosition(Vec3 { love.mouse.getX(), love.mouse.getY() }):floor()
local path = (require "lib.pathfinder")(charPos, mpos)
love.graphics.setColor(0.6, 0.75, 0.5) love.graphics.setColor(0.6, 0.75, 0.5)
for p in path:values() do for p in path:values() do
love.graphics.circle("fill", p.x + 0.45, p.y + 0.45, 0.1) love.graphics.circle("fill", p.x + 0.45, p.y + 0.45, 0.1)

View File

@ -1,6 +1,5 @@
local Vec3 = require "lib.utils.vec3" local Vec3 = require "lib.utils.vec3"
local ui = require "lib.ui.core" local ui = require "lib.ui.core"
local controls = require "lib.controls"
--- @type Rectangle --- @type Rectangle
local ReactiveRectangle = ui.Rectangle { local ReactiveRectangle = ui.Rectangle {
@ -15,9 +14,6 @@ function ReactiveRectangle:update(dt)
if mx > self.origin.x and mx < self.origin.x + self.size.x if mx > self.origin.x and mx < self.origin.x + self.size.x
and my > self.origin.y and my < self.origin.y + self.size.y and my > self.origin.y and my < self.origin.y + self.size.y
then then
if controls:isJustPressed("select") then
controls:consume("select")
end
self.color = { 0, 1, 0 } self.color = { 0, 1, 0 }
else else
self.color = { 1, 0, 0 } self.color = { 1, 0, 0 }