feat: add subchoregraphies

This commit is contained in:
Kazhnuz 2021-08-08 13:11:36 +02:00
parent 47a9353471
commit 3e2eafb63d
9 changed files with 169 additions and 5 deletions

View file

@ -19,6 +19,7 @@ return {
["setCounter"] = {"counterName", "number", "relative"},
["useItemEffect"] = {},
["stopMov"] = {"who"},
["startSubChoregraphies"] = {"waitTime", "blockProcess"},
--[name] = {args},
},
argumentWrapper = "arguments",

View file

@ -18,11 +18,11 @@ end
function ActionParent:loadChoregraphy(skillname)
local skill = core.datas:get("skills", skillname)
self.choregraphy = ChoregraphySystem(self, skill.choregraphy)
self:loadChoregraphy(self, skill)
end
function ActionParent:loadChoregraphyFromSkill(skill)
self.choregraphy = ChoregraphySystem(self, skill.choregraphy)
self.choregraphy = ChoregraphySystem(self, skill.choregraphy, skill.subChoregraphy)
end
function ActionParent:needTarget()

View file

@ -32,4 +32,12 @@ function Conditions.haveFrameSignal(cond, predicate, asker)
return asker:haveFrameSignal(cond[2])
end
function Conditions.hasNextTarget(cond, predicate, asker)
return asker:hasNextTarget()
end
function Conditions.hasSubChoregraphiesActive(cond, predicate, asker)
return asker:hasSubChoregraphiesActive()
end
return Conditions

View file

@ -5,20 +5,27 @@ local StepsMixin = require "scenes.battlesystem.controllers.fighters.systems.cho
local TagsMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.tags"
local CountersMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.counters"
local WrappersMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.wrappers"
local SubChoregraphiesMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.subchoregraphies"
local TweenManager = require "birb.classes.time"
ChoregraphySystem:implement(QteMixin)
ChoregraphySystem:implement(StepsMixin)
ChoregraphySystem:implement(TagsMixin)
ChoregraphySystem:implement(CountersMixin)
ChoregraphySystem:implement(WrappersMixin)
ChoregraphySystem:implement(SubChoregraphiesMixin)
function ChoregraphySystem:new(action, choregraphy)
function ChoregraphySystem:new(action, choregraphy, subChoregraphy)
self:initWrappers(action)
self:initSteps(choregraphy)
self:initQte()
self:initTagActions()
self:initCounters()
self:initSubchoregraphies(subChoregraphy)
self.tweens = TweenManager(self)
self.actor:resetFrameSignal()
end
@ -26,6 +33,14 @@ end
function ChoregraphySystem:update(dt)
self:updateQte(dt)
self:updateSteps(dt)
self.tweens:update(dt)
self:updateSubChoregraphies(dt)
end
function ChoregraphySystem:timerResponse(signal)
if (signal == "startNextTarget") then
self:startNextTarget()
end
end
function ChoregraphySystem:endChoregraphy()
@ -36,6 +51,7 @@ end
function ChoregraphySystem:draw()
self:drawQte()
self:drawSubChoregraphies()
end
return ChoregraphySystem

View file

@ -0,0 +1,73 @@
local SubChoregraphiesMixin = Object:extend()
local SubChoregraphy = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.subchoregraphy"
function SubChoregraphiesMixin:initSubchoregraphies(subChoregraphy)
self.subChoregraphies = {}
self.subChoregraphies.isActive = (self.target == nil)
self.subChoregraphies.steps = subChoregraphy
self.subChoregraphies.currentTarget = 0
self.subChoregraphies.waitTime = 0
self.subChoregraphies.list = {}
end
function SubChoregraphiesMixin:startSubChoregraphies(waitTime)
self.subChoregraphies.currentTarget = 0
self.subChoregraphies.waitTime = waitTime
self:startNextTarget()
end
function SubChoregraphiesMixin:updateSubChoregraphies(dt)
for _, subchoregraphy in ipairs(self.subChoregraphies.list) do
subchoregraphy:update(dt)
end
end
function SubChoregraphiesMixin:startNextTarget()
local target = self:getNextTarget()
if (target ~= nil) then
SubChoregraphy(self, target, self.subChoregraphies.steps)
self.tweens:newTimer(self.subChoregraphies.waitTime, "startNextTarget")
end
end
function SubChoregraphiesMixin:registerSubChoregraphy(subChoregraphy)
table.insert(self.subChoregraphies.list, subChoregraphy)
self:updateSubChoregraphyIds()
end
function SubChoregraphiesMixin:removeSubChoregraphy(subChoregraphy)
self:updateSubChoregraphyIds()
table.remove(self.subChoregraphies.list, subChoregraphy.id)
self:updateSubChoregraphyIds()
end
function SubChoregraphiesMixin:updateSubChoregraphyIds()
for id, subchoregraphy in ipairs(self.subChoregraphies.list) do
subchoregraphy.id = id
end
end
function SubChoregraphiesMixin:getNextTarget()
if (self:hasNextTarget()) then
self.subChoregraphies.currentTarget = self.subChoregraphies.currentTarget + 1
return self.targetList[self.subChoregraphies.currentTarget]
end
end
function SubChoregraphiesMixin:hasNextTarget()
return (self.targetList[self.subChoregraphies.currentTarget + 1] ~= nil)
end
function SubChoregraphiesMixin:hasSubChoregraphiesActive()
return (#self.subChoregraphies.list > 0)
end
function SubChoregraphiesMixin:drawSubChoregraphies()
for _, subchoregraphy in ipairs(self.subChoregraphies.list) do
subchoregraphy:draw()
end
end
return SubChoregraphiesMixin

View file

@ -1,13 +1,13 @@
local InfosMixin = Object:extend()
function InfosMixin:initWrappers(action)
function InfosMixin:initWrappers(action, target)
self.action = action
self.fighter = action.fighter
self.actor = self.fighter.actor
self.assets = self.fighter.actor.assets
self.world = self.actor.world
self:initTargets(action.target)
self:initTargets(target or action.target)
end
function InfosMixin:initTargets(target)

View file

@ -19,5 +19,6 @@ actions["skipTo"] = require(baseURI .. "skipTo")
actions["waitActorFinished"] = require(baseURI .. "waitActorFinished")
actions["useItemEffect"] = require(baseURI .. "useItemEffect")
actions["setCounter"] = require(baseURI .. "setCounter")
actions["startSubChoregraphies"] = require(baseURI .. "startSubChoregraphies")
return actions

View file

@ -0,0 +1,21 @@
local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent"
local StartSubchoregraphiesStep = StepParent:extend()
function StartSubchoregraphiesStep:new(controller, args)
StartSubchoregraphiesStep.super.new(self, controller, args)
end
function StartSubchoregraphiesStep:start()
self.choregraphy:startSubChoregraphies(self.arguments.waitTime)
if (not self.arguments.blockProcess) then
self:finish()
end
end
function StartSubchoregraphiesStep:update(dt)
if (not self.choregraphy:hasNextTarget()) then
self:finish()
end
end
return StartSubchoregraphiesStep;

View file

@ -0,0 +1,44 @@
local SubChoregraphy = Object:extend()
local QteMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.qtes"
local StepsMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.steps"
local TagsMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.tags"
local CountersMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.counters"
local WrappersMixin = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.mixins.wrappers"
SubChoregraphy:implement(QteMixin)
SubChoregraphy:implement(StepsMixin)
SubChoregraphy:implement(TagsMixin)
SubChoregraphy:implement(CountersMixin)
SubChoregraphy:implement(WrappersMixin)
function SubChoregraphy:new(parent, target, choregraphy)
self.parent = parent
self:initWrappers(parent.action, target)
self:initSteps(choregraphy)
self:initQte()
self:initTagActions()
self:initCounters()
self:register()
end
function SubChoregraphy:register()
self.parent:registerSubChoregraphy(self)
end
function SubChoregraphy:update(dt)
self:updateQte(dt)
self:updateSteps(dt)
end
function SubChoregraphy:endChoregraphy()
self.parent:removeSubChoregraphy(self)
end
function SubChoregraphy:draw()
self:drawQte()
end
return SubChoregraphy