From 09ac826f34fa06cf21cce03bd4c85f1cdf0c1804 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 17 Jul 2021 21:23:08 +0200 Subject: [PATCH] feat: add API to report finished tag actions --- .../scenes/battlesystem/actors/battler.lua | 21 +++++++++++++++++++ .../scenes/battlesystem/actors/gfx.lua | 6 +++++- .../systems/choregraphy/qte/parent.lua | 8 +++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua index 4b4daa2..56638c4 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua @@ -43,6 +43,9 @@ function Battler:new(world, x, y, z, owner) self.owner = owner self.isDefending = false + + self.tags = {} + self.choregraphy = nil end function Battler:destroy() @@ -250,6 +253,22 @@ function Battler:blockChoregraphy(isBlocking, currentlyBlocking, blockedBy) end end +function Battler:addTaggedAction(tag, choregraphy, taggedBy) + if (not utils.string.isEmpty(tag)) then + self.tags[tag] = taggedBy + self.choregraphy = choregraphy + end +end + +function Battler:unlockTag(taggedBy) + for tag, actionTag in pairs(self.tags) do + if (self.choregraphy ~= nil) and (actionTag == taggedBy) then + self.choregraphy:finishTagAction(tag) + self.tags[tag] = nil + end + end +end + function Battler:unblockChoregraphy() self.currentlyBlocking:finish() self.currentlyBlocking = nil @@ -259,6 +278,7 @@ function Battler:timerResponse(signal) if ((self.currentlyBlocking ~= nil) and (signal == self.blockedBy)) then self:unblockChoregraphy() end + self:unlockTag(signal) if (signal == "resetMovement") then self.movementType = MOVEMENT_NONE @@ -317,6 +337,7 @@ function Battler:animationEnded(animation) if (self.currentlyBlocking ~= nil and self.blockedBy=="animation") then self:unblockChoregraphy() end + self:unlockTag("animation") self:getNewAnimation(animation) end diff --git a/sonic-radiance.love/scenes/battlesystem/actors/gfx.lua b/sonic-radiance.love/scenes/battlesystem/actors/gfx.lua index d1cdeae..f883534 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/gfx.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/gfx.lua @@ -1,7 +1,7 @@ local Parent = require("scenes.battlesystem.actors.parent") local GFX = Parent:extend() -function GFX:new(world, x, y, z, spritename, creator, blockProcess) +function GFX:new(world, x, y, z, spritename, creator, blockProcess, tag) local width, height = world.assets.sprites[spritename]:getDimensions() GFX.super.new(self, world, x, y, z) @@ -9,6 +9,7 @@ function GFX:new(world, x, y, z, spritename, creator, blockProcess) self:cloneSprite() self.creator = creator self.blockProcess = blockProcess or false + self.tag = tag or "" self.direction = 1 end @@ -18,6 +19,9 @@ function GFX:animationEnded(animation) if (self.blockProcess) and (self.creator ~= nil) and (self.creator.getSignal ~= nil) then self.creator:getSignal("gfxEnded") end + if ((self.creator ~= nil) and (self.creator.choregraphy ~= nil) and (not utils.string.isEmpty(self.tag))) then + self.creator.choregraphy:finishTagAction(self.tag) + end self:destroy() end diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/qte/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/qte/parent.lua index 806470c..8429ae3 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/qte/parent.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/qte/parent.lua @@ -12,6 +12,11 @@ function QteParent:new(choregraphySystem, arguments) self.timer = 0 self.timerActive = false self.isSuccess = false + self.tag = "" +end + +function QteParent:setTag(tag) + self.tag = tag end function QteParent:blockAction(action, isBlocked) @@ -25,6 +30,9 @@ function QteParent:endQte() if (self.isBlocking ~= nil) then self.isBlocking:getSignal("qteEnded") end + if (not utils.string.isEmpty(self.tag)) then + self.choregraphy:finishTagAction(self.tag) + end end function QteParent:setOrigin(origin)