From 11503feac502df6dd2ea14a56f1f6a62eb7203bd Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 18 Jul 2021 19:17:45 +0200 Subject: [PATCH] feat: receive frame signal from the actor --- .../scenes/battlesystem/actors/battler.lua | 18 ++++++++++++++++++ .../systems/choregraphy/conditions.lua | 4 ++++ .../fighters/systems/choregraphy/init.lua | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua index 5311121..accd010 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua @@ -47,6 +47,7 @@ function Battler:new(world, x, y, z, owner) self.tags = {} self.choregraphy = nil + self.frameSignals = {} end function Battler:destroy() @@ -104,6 +105,18 @@ function Battler:update(dt) self:updateMovement(dt) end +function Battler:purgeFrameSignal() + self.frameSignals = {} +end + +function Battler:receiveFrameSignal(signal) + table.insert(self.frameSignals, signal) +end + +function Battler:haveFrameSignal(signal) + return utils.table.contain(self.frameSignals, signal) +end + -- MOVE FUNCTIONS -- All functions handling the moving @@ -363,6 +376,11 @@ function Battler:initSprite() self:changeAnimation("idle") end +function Battler:changeAnimation(animation, restart) + self:purgeFrameSignal() + Battler.super.changeAnimation(self, animation, restart) +end + function Battler:animationEnded(animation) if (self.currentlyBlocking ~= nil and self.blockedBy=="animation") then self:unblockChoregraphy() diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua index 1ecaa89..6ebe515 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/conditions.lua @@ -28,4 +28,8 @@ function Conditions.counter(cond, predicate, asker) return predicate.utils.testVariables(asker:getCounter(cond[2]), cond[3], cond[4]) end +function Conditions.haveFrameSignal(cond, predicate, asker) + return asker:haveFrameSignal(cond[2]) +end + return Conditions \ No newline at end of file diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua index 0e196ec..47e0691 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua @@ -13,6 +13,7 @@ function ChoregraphySystem:new(action, choregraphy) self.action = action self.fighter = action.fighter self.actor = self.fighter.actor + self.actor:purgeFrameSignal() self.assets = self.fighter.actor.assets self.world = self.actor.world self.target = action.target @@ -150,6 +151,10 @@ function ChoregraphySystem:setCounter(counterName, number, relative) self.counters[counterName] = number end +function ChoregraphySystem:haveFrameSignal(signal) + return self.actor:haveFrameSignal(signal) +end + function ChoregraphySystem:sendDamage(power, type, element, isSpecial) if (self.target ~= nil) then if (self.fighter.isAlive) then