feature/simple_ui #18

Merged
PeaAshMeter merged 25 commits from feature/simple_ui into main 2025-11-08 01:32:47 +03:00
Showing only changes of commit 21dbf99435 - Show all commits

View File

@ -10,11 +10,13 @@
local AnimationNode = require "lib.animation_node" local AnimationNode = require "lib.animation_node"
--- @class Spell Здесь будет много бойлерплейта, поэтому тоже понадобится спеллмейкерский фреймворк, который просто вернет готовый Spell --- @class Spell Здесь будет много бойлерплейта, поэтому тоже понадобится спеллмейкерский фреймворк, который просто вернет готовый Spell
--- @field tag string
--- @field update fun(self: Spell, caster: Character, dt: number): nil Изменяет состояние спелла --- @field update fun(self: Spell, caster: Character, dt: number): nil Изменяет состояние спелла
--- @field draw fun(self: Spell): nil Рисует превью каста, ничего не должна изменять в идеальном мире --- @field draw fun(self: Spell): nil Рисует превью каста, ничего не должна изменять в идеальном мире
--- @field cast fun(self: Spell, caster: Character, target: Vec3): boolean Вызывается в момент каста, изменяет мир. Возвращает bool в зависимости от того, получилось ли скастовать --- @field cast fun(self: Spell, caster: Character, target: Vec3): boolean Вызывается в момент каста, изменяет мир. Возвращает bool в зависимости от того, получилось ли скастовать
local spell = {} local spell = {}
spell.__index = spell spell.__index = spell
spell.tag = "base"
function spell:update(caster, dt) end function spell:update(caster, dt) end
@ -26,6 +28,7 @@ local walk = setmetatable({
--- @type Deque --- @type Deque
path = nil path = nil
}, spell) }, spell)
walk.tag = "dev_move"
function walk:cast(caster, target) function walk:cast(caster, target)
if not caster:try(Tree.behaviors.stats, function(stats) if not caster:try(Tree.behaviors.stats, function(stats)
@ -73,6 +76,7 @@ function walk:draw()
end end
local regenerateMana = setmetatable({}, spell) local regenerateMana = setmetatable({}, spell)
regenerateMana.tag = "dev_mana"
function regenerateMana:cast(caster, target) function regenerateMana:cast(caster, target)
caster:try(Tree.behaviors.stats, function(stats) caster:try(Tree.behaviors.stats, function(stats)
@ -92,6 +96,7 @@ function regenerateMana:cast(caster, target)
end end
local attack = setmetatable({}, spell) local attack = setmetatable({}, spell)
attack.tag = "dev_attack"
function attack:cast(caster, target) function attack:cast(caster, target)
if caster:try(Tree.behaviors.map, function(map) if caster:try(Tree.behaviors.map, function(map)
@ -102,7 +107,7 @@ function attack:cast(caster, target)
return false return false
end end
caster:try(Tree.behaviors.stats, function (stats) caster:try(Tree.behaviors.stats, function(stats)
stats.mana = stats.mana - 2 stats.mana = stats.mana - 2
end) end)