2020-07-24 19:16:33 +02:00
|
|
|
local ChoregraphySystem = Object:extend()
|
|
|
|
|
|
|
|
local choregraphyUtils = require "game.utils.choregraphy"
|
2020-07-24 21:54:12 +02:00
|
|
|
local stepObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step"
|
2020-07-31 20:06:35 +02:00
|
|
|
local qteObjectList = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.qte"
|
2020-07-24 19:16:33 +02:00
|
|
|
|
|
|
|
function ChoregraphySystem:new(action, choregraphy)
|
|
|
|
self.action = action
|
|
|
|
self.fighter = action.fighter
|
|
|
|
self.actor = self.fighter.actor
|
2020-07-24 21:54:12 +02:00
|
|
|
self.assets = self.fighter.actor.assets
|
|
|
|
self.world = self.actor.world
|
2020-07-25 08:44:59 +02:00
|
|
|
self.target = action.target
|
2020-07-24 19:16:33 +02:00
|
|
|
|
|
|
|
self.currentStepId = 0
|
|
|
|
self.currentStep = nil
|
|
|
|
self.stepList = choregraphy
|
2020-07-31 20:06:35 +02:00
|
|
|
|
|
|
|
self.qte = {}
|
|
|
|
self.qte.current = nil
|
|
|
|
self.qte.wasSuccess = false
|
2020-07-24 19:16:33 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function ChoregraphySystem:update(dt)
|
2020-07-31 20:06:35 +02:00
|
|
|
if (self.qte.current ~= nil) then
|
|
|
|
self.qte.current:update(dt)
|
|
|
|
end
|
|
|
|
|
2020-07-24 19:16:33 +02:00
|
|
|
if (self.currentStep ~= nil) then
|
2020-07-24 21:54:12 +02:00
|
|
|
self.currentStep:updateStep(dt)
|
2020-07-24 19:16:33 +02:00
|
|
|
else
|
|
|
|
self:switchStep()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ChoregraphySystem:switchStep()
|
|
|
|
if self:haveNextStep() then
|
|
|
|
self.currentStepId = self.currentStepId + 1
|
|
|
|
local stepData = choregraphyUtils.getStepDatas(self.stepList[self.currentStepId])
|
|
|
|
core.debug:print("cbs/choregraphy", "Starting step " .. stepData.name)
|
2020-07-24 21:54:12 +02:00
|
|
|
if (stepObjectList[stepData.name] ~= nil) then
|
|
|
|
self.currentStep = stepObjectList[stepData.name](self, stepData.arguments)
|
|
|
|
end
|
2020-07-24 19:16:33 +02:00
|
|
|
else
|
|
|
|
self:endChoregraphy()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-31 20:06:35 +02:00
|
|
|
function ChoregraphySystem:addQTE(action, origin, qteBaseData, blockProcess)
|
|
|
|
local qteData = choregraphyUtils.getQteDatas(qteBaseData)
|
|
|
|
if (qteObjectList[qteData.name] ~= nil) then
|
2020-07-31 21:00:31 +02:00
|
|
|
self.qte.current = qteObjectList[qteData.name](self, qteData.arguments)
|
2020-07-31 20:06:35 +02:00
|
|
|
self.qte.current:blockAction(action, blockProcess)
|
|
|
|
self.qte.current:setOrigin(origin)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-25 08:44:59 +02:00
|
|
|
function ChoregraphySystem:sendDamage(power, accuracy, isSpecial, isAerial)
|
|
|
|
if (self.target ~= nil) then
|
|
|
|
if (self.fighter.isAlive) then
|
|
|
|
self.fighter:sendDamage(self.target, power, accuracy, isSpecial, isAerial)
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-12 21:14:17 +01:00
|
|
|
function ChoregraphySystem:useItemEffect()
|
|
|
|
self.action:useItemEffect()
|
|
|
|
end
|
|
|
|
|
2020-07-24 19:16:33 +02:00
|
|
|
function ChoregraphySystem:endStep()
|
|
|
|
self.currentStep = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
function ChoregraphySystem:endChoregraphy()
|
2020-07-25 10:25:00 +02:00
|
|
|
self.actor:choregraphyEnded()
|
2020-07-24 19:16:33 +02:00
|
|
|
self.action:choregraphyEnded()
|
2020-07-25 08:44:59 +02:00
|
|
|
self.fighter.turnSystem:applyDeath()
|
2020-07-24 19:16:33 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function ChoregraphySystem:haveNextStep()
|
|
|
|
return ((self.currentStepId + 1) <= #self.stepList)
|
|
|
|
end
|
|
|
|
|
|
|
|
return ChoregraphySystem
|