feat: receive frame signal from the actor

This commit is contained in:
Kazhnuz 2021-07-18 19:17:45 +02:00
parent eabd1a3a8c
commit 11503feac5
3 changed files with 27 additions and 0 deletions

View file

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

View file

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

View file

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