chore: remove tweener-based movement

This commit is contained in:
Kazhnuz 2021-08-07 10:40:07 +02:00
parent 80d18a2825
commit 062070faae

View file

@ -2,7 +2,6 @@ local ParentObject = require "scenes.battlesystem.actors.parent"
local Movable = ParentObject:extend() local Movable = ParentObject:extend()
local MOVEMENT_NONE = "none" local MOVEMENT_NONE = "none"
local MOVEMENT_TWEENER = "tweener"
local MOVEMENT_MOTION = "motion" local MOVEMENT_MOTION = "motion"
local MOVEMENT_TARGET = "target" local MOVEMENT_TARGET = "target"
@ -50,27 +49,14 @@ end
function Movable:stopMoving() function Movable:stopMoving()
self.xspeed, self.yspeed, self.zspeed = 0,0,0 self.xspeed, self.yspeed, self.zspeed = 0,0,0
self.speed = 0 self.speed = 0
if (self.movementType == MOVEMENT_TWEENER) then
self:finishAction("goTo")
self.tweens:removeNamedTween("goTo")
self.tweens:removeTimer("goTo")
self.tweens:removeTimer("resetMovement")
end
self:finishAction("goTo") self:finishAction("goTo")
self:updatePreviousPosition() self:updatePreviousPosition()
self:resetMovementType() self:resetMovementType()
end end
function Movable:updateMovement(dt) function Movable:updateMovement(dt)
if (self.movementType == MOVEMENT_TWEENER) then
self:updateTweenerSpeed(dt)
self.speed = math.sqrt(self.xspeed^2 + self.yspeed^2)
elseif (self.movementType == MOVEMENT_MOTION) or (self.movementType == MOVEMENT_TARGET) then
self:updateMotion(dt) self:updateMotion(dt)
end
self:updateDirection() self:updateDirection()
self:updatePreviousPosition() self:updatePreviousPosition()
end end
@ -80,7 +66,7 @@ function Movable:updatePreviousPosition()
self.zprevious = self.z self.zprevious = self.z
end end
-- Tweener movement functions -- GoTo movement functions
function Movable:goTo(dx, dy, duration, easing) function Movable:goTo(dx, dy, duration, easing)
self:stopMoving() self:stopMoving()
@ -100,11 +86,6 @@ function Movable:goTo3D(dx, dy, dz, duration, easing)
self.movementType = MOVEMENT_TARGET self.movementType = MOVEMENT_TARGET
end end
function Movable:updateTweenerSpeed(dt)
self.xspeed = (self.x - self.xprevious) / dt
self.yspeed = (self.y - self.yprevious) / dt
end
-- MOTION HANDLING -- MOTION HANDLING
function Movable:setMotion(speed, angle, vertAngle) function Movable:setMotion(speed, angle, vertAngle)