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