--Override this function to make a tape loop last for "infinite" time
--Only on Day 1!

Hooks:PostHook( SecurityCamera, "sync_net_event", "parisian_cigars_camsyncnetevhook", function(self, event_id)

	if(event_id == 99) then
		self:_hack_parcig_cam_asset()
	elseif(event_id == 98) then
		self:_unhack_parcig_cam_asset()
	end

end )

function SecurityCamera:_hack_parcig_cam_asset()

	self._unit:contour():add("mark_unit_friendly")
	managers.mission:set_job_value(self:q_get_jobid_name(), 0)
	
	if(managers.mission:get_job_value("vo") == 1) then
		managers.dialog:queue_dialog("q011pc_diag_favor_buy" .. tostring(math.random(1, 3)), {
			skip_idle_check = true,
			case = "russian",
			on_unit = managers.dialog._bain_unit
		})
	end

end

function SecurityCamera:_unhack_parcig_cam_asset()

	self._unit:contour():remove("mark_unit_friendly")
	managers.mission:set_job_value(self:q_get_jobid_name(), 1)
	
	if(managers.mission:get_job_value("vo") == 1) then
		managers.dialog:queue_dialog("q011pc_diag_favor_unbuy" .. tostring(math.random(1, 3)), {
			skip_idle_check = true,
			case = "russian",
			on_unit = managers.dialog._bain_unit
		})
	end

end

--No, I'm not proud of this function.. OK?
--Converts the unit id of the camera into the right job id
function SecurityCamera:q_get_jobid_name()

	local unit_id = tostring(self._unit:unit_data().unit_id)
	
	if(unit_id == "102977") then
		return "cam1"
	elseif(unit_id == "104916") then
		return "cam2"
	elseif(unit_id == "104917") then
		return "cam3"
	elseif(unit_id == "104918") then
		return "cam4"
	elseif(unit_id == "104921") then
		return "cam5"
	elseif(unit_id == "104924") then
		return "cam6"
	elseif(unit_id == "104925") then
		return "cam7"
	elseif(unit_id == "104926") then
		return "cam8"
	elseif(unit_id == "104927") then
		return "cam9"
	elseif(unit_id == "106400") then
		return "cam10"
	elseif(unit_id == "106401") then
		return "cam11"
	elseif(unit_id == "106402") then
		return "cam12"
	elseif(unit_id == "106403") then
		return "cam13"
	elseif(unit_id == "106404") then
		return "cam14"
	elseif(unit_id == "106405") then
		return "cam15"
	elseif(unit_id == "106410") then
		return "cam16"
	elseif(unit_id == "106411") then
		return "cam17"
	elseif(unit_id == "106412") then
		return "cam18"
	end
	
	return "cam_none"
end