local StepParent = Object:extend()

function StepParent:new(choregraphySystem, arguments)
  self.choregraphy = choregraphySystem
  self.arguments = arguments
  self.isStarted = false
end

function StepParent:updateStep(dt)
  if (not self.isStarted) then
    self:start()
    self.isStarted = true
  else
    self:update(dt)
  end
end

function StepParent:getStepCoordinate()
  local argx, argy = self.arguments.x, self.arguments.y
  argx = argx * self.choregraphy.actor.start.direction
  if (self.arguments.origin == "target") then
    local target = self.choregraphy.action.target
    local x, y = target.actor:getCoordinate()
    return x + argx, y + argy
  elseif (self.arguments.origin == "start") then
    local x, y = self.choregraphy.actor.start.x, self.choregraphy.actor.start.y
    return x + argx, y + argy
  elseif (self.arguments.origin == "actor") then
    local x, y = self.choregraphy.actor:getCoordinate()
    return x + argx, y + argy
  end
end

function StepParent:finish()
  print("action finished")
  self.choregraphy:endStep()
end

return StepParent
