fix selection during a cast
This commit is contained in:
parent
177e1ef347
commit
83115e82f8
@ -10,9 +10,9 @@ end
|
|||||||
--- @param characterId integer | nil
|
--- @param characterId integer | nil
|
||||||
function selector:select(characterId)
|
function selector:select(characterId)
|
||||||
self.id = characterId
|
self.id = characterId
|
||||||
|
print("[Selector]:", characterId and "selected " .. characterId or "deselected")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- TODO: сделать обработчик селектора
|
|
||||||
function selector:update(dt)
|
function selector:update(dt)
|
||||||
if not Tree.controls:isJustPressed("select") then return end
|
if not Tree.controls:isJustPressed("select") then return end
|
||||||
|
|
||||||
@ -21,19 +21,21 @@ function selector:update(dt)
|
|||||||
if mousePosition.x >= Tree.level.size.x or mousePosition.y >= Tree.level.size.y or mousePosition.y < 0 or mousePosition.x < 0 then
|
if mousePosition.x >= Tree.level.size.x or mousePosition.y >= Tree.level.size.y or mousePosition.y < 0 or mousePosition.x < 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local characterId = Tree.level.characterGrid:get(Vec3 { mousePosition.x, mousePosition.y })
|
local selectedId = Tree.level.characterGrid:get(Vec3 { mousePosition.x, mousePosition.y })
|
||||||
|
|
||||||
if not characterId and self.id then -- Когда кликаем по тайлу за персонажа в режиме каста, кастуем спелл
|
if not self.id then
|
||||||
|
return self:select(selectedId)
|
||||||
|
else
|
||||||
local char = Tree.level.characters[self.id]
|
local char = Tree.level.characters[self.id]
|
||||||
char:try(Tree.behaviors.spellcaster, function(b)
|
char:try(Tree.behaviors.spellcaster, function(b)
|
||||||
if not b.cast then return end
|
if not b.cast then
|
||||||
|
self:select(selectedId)
|
||||||
|
return
|
||||||
|
end
|
||||||
b.cast:cast(char, mousePosition)
|
b.cast:cast(char, mousePosition)
|
||||||
b.cast = nil
|
b.cast = nil
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
self:select(characterId)
|
|
||||||
|
|
||||||
print("[Selector]:", mousePosition, characterId and "selected " .. characterId or "deselected")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -18,10 +18,13 @@ local walk = setmetatable({
|
|||||||
|
|
||||||
function walk:cast(caster, target)
|
function walk:cast(caster, target)
|
||||||
local path = self.path
|
local path = self.path
|
||||||
|
if path:is_empty() then return end
|
||||||
path:pop_front()
|
path:pop_front()
|
||||||
print("Following path: ")
|
print("Following path: ")
|
||||||
for p in path:values() do print(p) end
|
for p in path:values() do print(p) end
|
||||||
caster:has(Tree.behaviors.map):followPath(path)
|
caster:has(Tree.behaviors.map):followPath(path)
|
||||||
|
-- TODO: списать деньги за каст (антиутопия какая-то)
|
||||||
|
-- TODO: привязка тинькоффа
|
||||||
end
|
end
|
||||||
|
|
||||||
function walk:update(caster, dt)
|
function walk:update(caster, dt)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user