From a5ec563480c50a0f3468c40fd717e73acf122b0a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 24 Jul 2020 19:16:33 +0200 Subject: [PATCH] feat: initial version of the new choregraphy system --- .../fighters/systems/choregraphy/init.lua | 46 +++++++++++++++++++ .../systems/choregraphy/step/parent.lua | 16 +++++++ 2 files changed, 62 insertions(+) create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/parent.lua 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 new file mode 100644 index 0000000..b1e8006 --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/init.lua @@ -0,0 +1,46 @@ +local ChoregraphySystem = Object:extend() + +local choregraphyUtils = require "game.utils.choregraphy" + +function ChoregraphySystem:new(action, choregraphy) + self.action = action + self.fighter = action.fighter + self.actor = self.fighter.actor + + self.currentStepId = 0 + self.currentStep = nil + self.stepList = choregraphy +end + +function ChoregraphySystem:update(dt) + if (self.currentStep ~= nil) then + self.currentStep:update(dt) + 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) + --self.currentStep = self.stepList[self.currentStepId] + else + self:endChoregraphy() + end +end + +function ChoregraphySystem:endStep() + self.currentStep = nil +end + +function ChoregraphySystem:endChoregraphy() + self.action:choregraphyEnded() +end + +function ChoregraphySystem:haveNextStep() + return ((self.currentStepId + 1) <= #self.stepList) +end + +return ChoregraphySystem diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/parent.lua new file mode 100644 index 0000000..5694e3f --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/fighters/systems/choregraphy/step/parent.lua @@ -0,0 +1,16 @@ +local StepParent = Object:extend() + +function StepParent:new(choregraphySystem, name, arguments) + self.name = name + self.choregraphy = choregraphySystem + self.arguments = arguments + self.isStarted = false +end + +function StepParent:update(dt) + if (not self.isStarted) then + self:startStep() + end +end + +return StepParent