local MovingView = Object:extend()

local DEFAULT_GRIDSIZE = 2

function MovingView:new(owner, actor)
  self.owner = owner
  self.actor = actor
  self.world = actor.world
end

function MovingView:update(dt)

end

function MovingVew:start()
  local character = self.actor:getCharacterData();
  local gridsize = character.move
  if (gridsize == nil) then
    gridsize = DEFAULT_GRIDSIZE
    core.debug:warning("cbs/character", "move value is nil")
  end
  local x, y = utils.math.round(self.actor.x), utils.math.round(self.actor.y)
  self.world.cursor:setGrid(x, y, "circle", gridsize, 1, self.owner)
  self.actor.x, self.actor.y = x, y
  self.owner:setStartData(x, y, self.actor.direction)

  self.world.cursor:set(x, y, "cursorMove")
end

function MovingView:receiveSignal(signal, id)
  if (signal == "positionSelected") then
    self.actor:set
  elseif (signal == "characterMoved") then
    self.world:resetActiveGrid()
    self:endView()
  end
end

return MovingView
