class "engimus_vegetation_function" (VegetationFunction)

function create_engimus_vegetation_function()
	return engimus_vegetation_function()
end

function engimus_vegetation_function:__init() super()
end

function engimus_vegetation_function:init()
  self.tutors_count = 3
  self.delay_to_next_tutor = 18
  self.time_to_next_tutor = self.delay_to_next_tutor
end

function engimus_vegetation_function:update(dt)

  if (g_game:water_count() > 3) and (self.tutors_count > 0) and (self.time_to_next_tutor > 0) and (can_start_tutorial_time(1)) then
    self.time_to_next_tutor = self.time_to_next_tutor - dt
  end

  if (g_game:water_count() > 0) and (self.tutors_count > 0) and (self.time_to_next_tutor <= 0) and (can_start_tutorial_time(1.5)) then
    self.time_to_next_tutor = self.delay_to_next_tutor
    self.tutors_count = self.tutors_count - 1

    g_game:reset_tutorial_key("engimus_hint")
    g_game:start_tutorial("engimus_hint", self:vegetation():ridge():center_position())
  end
end

function engimus_vegetation_function:save(ios)
  ios:save(0)
  ios:save(self.tutors_count)
  ios:save(self.time_to_next_tutor)
end

function engimus_vegetation_function:load(ios)
  local ver = ios:load()
  self.tutors_count = ios:load()
  self.time_to_next_tutor = ios:load()
end

function engimus_vegetation_function:cursor(p)
  if (g_game:water_count() <= 0) then
    return ""
  end

  if (self:vegetation():inside_for_pour(p, self:vegetation():ridge())) then
    return "pour"
  end

  return ""
end

function engimus_vegetation_function:on_click(p)
  if (g_game:water_count() <= 0) then
    return false
  end

  if (self:vegetation():inside_for_pour(p, self:vegetation():ridge())) then
  
    if (self:vegetation():fake_pour()) then
      self:vegetation():set_upgrade_time(self:vegetation():upgrade_time() - 10);
      self.time_to_next_tutor = self.delay_to_next_tutor
    end

    return false
  end

  return false
end

function engimus_vegetation_function:restart()
end