From 55d66eef85de8b698d0c03b9a61cce52c6cd1ff9 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 24 Jul 2020 19:12:37 +0200 Subject: [PATCH] feat: add bases for the new choregraphy system --- .../game/utils/choregraphy/arguments.lua | 12 +++++ .../game/utils/choregraphy/init.lua | 45 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 sonic-radiance.love/game/utils/choregraphy/arguments.lua create mode 100644 sonic-radiance.love/game/utils/choregraphy/init.lua diff --git a/sonic-radiance.love/game/utils/choregraphy/arguments.lua b/sonic-radiance.love/game/utils/choregraphy/arguments.lua new file mode 100644 index 0000000..0adabd0 --- /dev/null +++ b/sonic-radiance.love/game/utils/choregraphy/arguments.lua @@ -0,0 +1,12 @@ +return { + ["wait"] = {"duration"}, + ["addGFX"] = {'sprite', "origin", "x", "y", "affectedByDirection", 'blockProcess'}, + ["playSFX"] = {"sfx"}, + ["sendDamage"] = {"power", "accuracy", "isSpecial", "isAerial"}, + ["goTo"] = {"origin", "x", "y", "duration", "blockProcess"}, + ["setAnimation"] = {"animation", "blockProcess"}, + ["jump"] = {"power", "blockProcess"}, + ["jumpTo"] = {"origin", "x", "y", "duration", "blockProcess"}, + ["jumpBack"] = {"duration", "blockProcess"}, + --[name] = {args}, +} diff --git a/sonic-radiance.love/game/utils/choregraphy/init.lua b/sonic-radiance.love/game/utils/choregraphy/init.lua new file mode 100644 index 0000000..5aa85a0 --- /dev/null +++ b/sonic-radiance.love/game/utils/choregraphy/init.lua @@ -0,0 +1,45 @@ +ChoregraphyUtils = {} + +function ChoregraphyUtils.getStepStructure(stepName) + local stepTypeList = require "game.utils.choregraphy.arguments" + return stepTypeList[stepName] +end + +function ChoregraphyUtils.stepExists(stepName) + return (ChoregraphyUtils.getStepStructure(stepName) ~= nil) +end + +function ChoregraphyUtils.validate(stepBaseDatas) + local structure = ChoregraphyUtils.getStepStructure(stepBaseDatas[1]) + if (structure == nil) then + return false + else + return ((#structure + 2) == #stepBaseDatas) + end +end + +function ChoregraphyUtils.getStepDatas(stepBaseDatas) + + local stepData = {} + stepData.name = stepBaseDatas[1] + + if (ChoregraphyUtils.validate(stepBaseDatas)) then + stepData.condition = stepBaseDatas[2] + + local structure = ChoregraphyUtils.getStepStructure(stepData.name) + + stepData.arguments = {} + + for i, argumentName in ipairs(structure) do + local argumentContent = stepBaseDatas[i + 2] + stepData.arguments[argumentName] = argumentContent + end + + return stepData + else + error("L'étape " .. stepData.name .. " à un nbr d'argument incorrect") + end + +end + +return ChoregraphyUtils