mega cool table of tasks for ai!!

This commit is contained in:
neckrat 2026-03-17 23:59:49 +03:00
parent af05a9fde3
commit d6644fb799
2 changed files with 40 additions and 21 deletions

View File

@ -21,19 +21,9 @@ local function closestCharacter(char)
return charTarget return charTarget
end end
--- @class AIBehavior : Behavior ---@type {[Class]: fun(self): Task<nil>} возможно где-то здесь на объявлении типа сломается типизация
--- @field animationNode AnimationNode? local aiNature = {
--- @field target Vec3? ["dev_warrior"] = function(self)
local behavior = {}
behavior.__index = behavior
behavior.id = "ai"
function behavior.new()
return setmetatable({}, behavior)
end
--- @return Task<nil>
function behavior:makeTurn()
return function(callback) -- почему так, описано в Task return function(callback) -- почему так, описано в Task
self.owner:try(Tree.behaviors.spellcaster, function(spellB) self.owner:try(Tree.behaviors.spellcaster, function(spellB)
local charTarget = closestCharacter(self.owner) local charTarget = closestCharacter(self.owner)
@ -54,6 +44,35 @@ function behavior:makeTurn()
end) end)
end) end)
end end
end,
["dev_mage"] = function(self)
return function(callback)
print("etoh... bleh")
callback()
end
end
}
--- @class AIBehavior : Behavior
--- @field animationNode AnimationNode?
--- @field target Vec3?
local behavior = {}
behavior.__index = behavior
behavior.id = "ai"
--- @param class Class
function behavior.new(class)
return setmetatable({
makeTurn = aiNature[class]
}, behavior)
end
--- @return Task<nil>
function behavior:makeTurn()
return function(callback)
end
end end
return behavior return behavior

View File

@ -52,7 +52,7 @@ function love.load()
Tree.behaviors.sprite.new(Tree.assets.files.sprites.character), Tree.behaviors.sprite.new(Tree.assets.files.sprites.character),
Tree.behaviors.shadowcaster.new(), Tree.behaviors.shadowcaster.new(),
Tree.behaviors.spellcaster.new(), Tree.behaviors.spellcaster.new(),
Tree.behaviors.ai.new() Tree.behaviors.ai.new("dev_warrior")
}, },
} }