fix: remove input lag from QTE

This commit is contained in:
Kazhnuz 2021-07-18 18:26:15 +02:00
parent 6626dbebdf
commit 26ba64218b
2 changed files with 14 additions and 5 deletions

View file

@ -26,6 +26,7 @@ function ChoregraphySystem:new(action, choregraphy)
self.qte = {} self.qte = {}
self.qte.current = nil self.qte.current = nil
self.qte.wasSuccess = false self.qte.wasSuccess = false
self.qte.isActive = false
self.qte.list = {} self.qte.list = {}
self.finishedTagActions = {} self.finishedTagActions = {}
@ -34,7 +35,7 @@ end
function ChoregraphySystem:update(dt) function ChoregraphySystem:update(dt)
if (self.qte.current ~= nil) then if (self.qte.current ~= nil) then
self.qte.current:updateQte(dt) self.qte.current:updateQte(dt, self.qte.isActive)
end end
if (self.currentStep ~= nil) then if (self.currentStep ~= nil) then
@ -104,6 +105,7 @@ function ChoregraphySystem:addQTE(action, origin, qteBaseData, blockProcess, tag
self.qte.current:blockAction(action, blockProcess) self.qte.current:blockAction(action, blockProcess)
self.qte.current:setOrigin(origin) self.qte.current:setOrigin(origin)
self.qte.current:setTag(tag) self.qte.current:setTag(tag)
self.qte.isActive = true
end end
end end
@ -113,12 +115,16 @@ function ChoregraphySystem:isQteSuccess(qteID)
end end
function ChoregraphySystem:endQte(success) function ChoregraphySystem:endQte(success)
self.qte.current = nil self.qte.isActive = false
self.qte.wasSuccess = success self.qte.wasSuccess = success
table.insert(self.qte.list, success) table.insert(self.qte.list, success)
end end
function ChoregraphySystem:removeQte()
self.qte.current = nil
end
function ChoregraphySystem:testTagAction(tag, statut) function ChoregraphySystem:testTagAction(tag, statut)
local tagStatut = self.finishedTagActions[tag] or 0 local tagStatut = self.finishedTagActions[tag] or 0
return (statut <= tagStatut) return (statut <= tagStatut)

View file

@ -60,7 +60,7 @@ function QteParent:setOrigin(origin)
end end
end end
function QteParent:updateQte(dt) function QteParent:updateQte(dt, isActive)
if (not self.isStarted) then if (not self.isStarted) then
self:start() self:start()
self.isStarted = true self.isStarted = true
@ -68,9 +68,11 @@ function QteParent:updateQte(dt)
self:update(dt) self:update(dt)
self.tweens:update(dt) self.tweens:update(dt)
self.prompts:update(dt) self.prompts:update(dt)
if (isActive) then
self:verifyPrompts() self:verifyPrompts()
end end
end end
end
function QteParent:timerResponse(timer) function QteParent:timerResponse(timer)
if (timer == "qteTimer") then if (timer == "qteTimer") then
@ -84,7 +86,7 @@ function QteParent:timerResponse(timer)
self.timerActive = true self.timerActive = true
self.prompts.defaultTimerValue = 0 self.prompts.defaultTimerValue = 0
elseif (timer == "endQte") then elseif (timer == "endQte") then
self:endQte() self.choregraphy:removeQte()
end end
end end
@ -92,6 +94,7 @@ function QteParent:finish(success)
self.isSuccess = success self.isSuccess = success
self.timerActive = false self.timerActive = false
self.tweens:newTimer(self.prompts.BEGINTIME, "endQte") self.tweens:newTimer(self.prompts.BEGINTIME, "endQte")
self:endQte()
end end
function QteParent:verifyPrompts() function QteParent:verifyPrompts()