feat: initial version of the new choregraphy system
This commit is contained in:
parent
2085b9df2c
commit
a5ec563480
2 changed files with 62 additions and 0 deletions
|
@ -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
|
|
@ -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
|
Loading…
Reference in a new issue