Compare commits
26 Commits
feature/ef
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 781a09a947 | |||
| 9e7a787d83 | |||
| d41f9fb542 | |||
| 80ae1e0a68 | |||
| 790d63d37f | |||
| fd47ada751 | |||
| 149432e699 | |||
| 8eb453ff7f | |||
| a39be70969 | |||
| 41a906fe6a | |||
| 3e23599c88 | |||
| cb53fa8d88 | |||
| 254e94fc29 | |||
| 606c1158e3 | |||
| 1ad38c3103 | |||
| c2c33cbf1b | |||
| d33d6eedd6 | |||
| d7228cc322 | |||
| d1597d8ffa | |||
| 85883dfa7d | |||
| a16b279e44 | |||
| cdf68004da | |||
| bad4b494cd | |||
| b6737e8f0b | |||
| db8db450d0 | |||
| 46c7b46bd1 |
@ -6,5 +6,6 @@
|
|||||||
"love.filesystem.load": "loadfile"
|
"love.filesystem.load": "loadfile"
|
||||||
},
|
},
|
||||||
"workspace.ignoreDir": ["dev_utils"],
|
"workspace.ignoreDir": ["dev_utils"],
|
||||||
"diagnostics.ignoredFiles": "Disable"
|
"diagnostics.ignoredFiles": "Disable",
|
||||||
|
"hint.enable": true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
local easing = require "lib.utils.easing"
|
local easing = require "lib.utils.easing"
|
||||||
local pf = require "lib.pathfinder"
|
local pf = require "lib.pathfinder"
|
||||||
local utils = require "lib.utils.utils"
|
local utils = require "lib.utils.utils"
|
||||||
|
local task = require "lib.utils.task"
|
||||||
|
|
||||||
--- @alias AIAction fun(self: AIBehavior): Task<nil>
|
--- @alias AIAction fun(self: AIBehavior): Task<nil>
|
||||||
|
|
||||||
@ -156,6 +157,16 @@ local behavior = {}
|
|||||||
behavior.__index = behavior
|
behavior.__index = behavior
|
||||||
behavior.id = "ai"
|
behavior.id = "ai"
|
||||||
|
|
||||||
|
--- Заставляет ИИ сделать ход
|
||||||
|
---
|
||||||
|
--- По умолчанию ничего не делает
|
||||||
|
--- @return Task<nil>
|
||||||
|
function behavior:makeTurn()
|
||||||
|
return function(callback)
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- @param class Class
|
--- @param class Class
|
||||||
function behavior.new(class)
|
function behavior.new(class)
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
|
|||||||
@ -37,8 +37,8 @@ function behavior.new(hp, mana, initiative, class, isInTurnOrder)
|
|||||||
hp = hp or 20,
|
hp = hp or 20,
|
||||||
mana = mana or 10,
|
mana = mana or 10,
|
||||||
initiative = initiative or 10,
|
initiative = initiative or 10,
|
||||||
|
class = class or "dev_warrior",
|
||||||
isInTurnOrder = isInTurnOrder or true,
|
isInTurnOrder = isInTurnOrder or true,
|
||||||
class = "dev_warrior",
|
|
||||||
amIAlive = true
|
amIAlive = true
|
||||||
}, behavior)
|
}, behavior)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
local utils = require "lib.utils.utils"
|
local utils = require "lib.utils.utils"
|
||||||
local pQueue = require "lib.utils.priority_queue"
|
|
||||||
--- @class CharacterGrid : Grid
|
--- @class CharacterGrid : Grid
|
||||||
--- @field __grid {string: Id|nil}
|
--- @field __grid {string: Id|nil}
|
||||||
--- @field yOrderQueue PriorityQueue<Character> очередь отрисовки сверху вниз
|
|
||||||
local grid = setmetatable({}, require "lib.level.grid.base")
|
local grid = setmetatable({}, require "lib.level.grid.base")
|
||||||
grid.__index = grid
|
grid.__index = grid
|
||||||
|
|
||||||
@ -29,22 +27,13 @@ function grid:add(id)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param a Character
|
|
||||||
--- @param b Character
|
|
||||||
local function drawCmp(a, b)
|
|
||||||
--- @TODO: это захардкожено, надо разделить поведения
|
|
||||||
return a:has(Tree.behaviors.positioned).position.y < b:has(Tree.behaviors.positioned).position.y
|
|
||||||
end
|
|
||||||
|
|
||||||
--- fills the grid with the actual data
|
--- fills the grid with the actual data
|
||||||
---
|
---
|
||||||
--- should be called as early as possible during every tick
|
--- should be called as early as possible during every tick
|
||||||
function grid:reload()
|
function grid:reload()
|
||||||
self:reset()
|
self:reset()
|
||||||
self.yOrderQueue = pQueue.new(drawCmp)
|
|
||||||
utils.each(Tree.level.characters, function(c)
|
utils.each(Tree.level.characters, function(c)
|
||||||
self:add(c.id)
|
self:add(c.id)
|
||||||
self.yOrderQueue:insert(c)
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user