aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorGiuseppe Gadola <giusgadola@gmail.com>2023-03-08 10:40:09 +0100
committerGiuseppe Gadola <giusgadola@gmail.com>2023-03-08 10:40:09 +0100
commit08d9d53bd1c7b56e5c2276179be2cd966aed81df (patch)
treed8072700480241124a3c383999d62d34b6e656b1 /lua
parentfeat(pets): new slime animation (diff)
feat(pets): add split_die animation for slime
Diffstat (limited to 'lua')
-rw-r--r--lua/pets/animations.lua5
-rw-r--r--lua/pets/pets/slime.lua7
2 files changed, 10 insertions, 2 deletions
diff --git a/lua/pets/animations.lua b/lua/pets/animations.lua
index e4462a2..1b685d9 100644
--- a/lua/pets/animations.lua
+++ b/lua/pets/animations.lua
@@ -54,6 +54,7 @@ function M.Animation.new(sourcedir, type, style, popup, user_opts, state)
instance.idle_actions = pet.idle_actions
instance.movements = pet.movements
instance.first_action = pet.first_action
+ instance.get_death_animation = pet.get_death_animation
return instance
end
@@ -158,12 +159,12 @@ end
-- @function decide which action comes after the current_action
function M.Animation:set_next_action()
if self.dying then
- if self.current_action == "die" then
+ if vim.startswith(self.current_action, "die") or vim.endswith(self.current_action, "die") then
self.dead = true
M.Animation.stop(self)
self.popup:unmount()
end
- self.current_action = "die"
+ self.current_action = self.get_death_animation(self.current_action)
return
end
if self.state.idle then
diff --git a/lua/pets/pets/slime.lua b/lua/pets/pets/slime.lua
index da86c0d..ccdca88 100644
--- a/lua/pets/pets/slime.lua
+++ b/lua/pets/pets/slime.lua
@@ -26,4 +26,11 @@ return {
normal = { "walk_left" },
},
},
+ get_death_animation = function(current_action)
+ local split_animations = { "split_idle", "divide", "split_walk", "split_swap" }
+ if vim.tbl_contains(split_animations, current_action) then
+ return "split_die"
+ end
+ return "die"
+ end,
}