feat: add API to report finished tag actions

This commit is contained in:
Kazhnuz 2021-07-17 21:23:08 +02:00
parent 0377077ca9
commit 09ac826f34
3 changed files with 34 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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)