From ed099bd77f8996ac3014f57bb985143ee5fc6448 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 17 Jul 2021 22:59:12 +0200 Subject: [PATCH] feat: add way to skip to a step --- .../datas/parsers/choregraphystep.lua | 1 + .../fighters/systems/choregraphy/init.lua | 20 +++++++++++++++++++ .../systems/choregraphy/step/init.lua | 1 + .../systems/choregraphy/step/skipTo.lua | 12 +++++++++++ 4 files changed, 34 insertions(+) create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/skipTo.lua diff --git a/sonic-radiance.love/datas/parsers/choregraphystep.lua b/sonic-radiance.love/datas/parsers/choregraphystep.lua index 2c40ccb..0358723 100644 --- a/sonic-radiance.love/datas/parsers/choregraphystep.lua +++ b/sonic-radiance.love/datas/parsers/choregraphystep.lua @@ -12,6 +12,7 @@ return { ["jumpBack"] = {"duration", "blockProcess"}, ["waitActorFinished"] = {"waitFor"}, ["waitFor"] = {"waitFor"}, + ["skipTo"] = {"skipTo"}, ["addQTE"] = {"qteData", "origin", "blockProcess"}, ["useItemEffect"] = {}, --[name] = {args}, 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 4939688..c42e139 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 @@ -43,6 +43,26 @@ function ChoregraphySystem:update(dt) end end +function ChoregraphySystem:findTaggedAction(tag) + for stepId, step in ipairs(self.stepList) do + if (step[1] == "taggedAction") and (step[2] == tag) then + return stepId + end + end + return 0 +end + +function ChoregraphySystem:skipToStepByTag(tag) + self:skipToStep(self:findTaggedAction(tag)) +end + +function ChoregraphySystem:skipToStep(id) + if (self.stepList[id] ~= nil) then + self.currentStepId = id - 1 + self:switchStep() + end +end + function ChoregraphySystem:switchStep() if self:haveNextStep() then self.currentStepId = self.currentStepId + 1 diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua index 478299b..f968f33 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/init.lua @@ -11,6 +11,7 @@ actions["sendDamage"] = require(baseURI .. "sendDamage") actions["setAnimation"] = require(baseURI .. "setAnimation") actions["wait"] = require(baseURI .. "wait") actions["waitFor"] = require(baseURI .. "waitFor") +actions["skipTo"] = require(baseURI .. "skipTo") actions["waitActorFinished"] = require(baseURI .. "waitActorFinished") actions["useItemEffect"] = require(baseURI .. "useItemEffect") diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/skipTo.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/skipTo.lua new file mode 100644 index 0000000..780d1fb --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/skipTo.lua @@ -0,0 +1,12 @@ +local StepParent = require "scenes.battlesystem.controllers.fighters.systems.choregraphy.step.parent" +local SkipToStep = StepParent:extend() + +function SkipToStep:new(system, args) + SkipToStep.super.new(self, system, args) +end + +function SkipToStep:start() + self.choregraphy:skipToStepByTag(self.arguments.skipTo) +end + +return SkipToStep