NOTIFICATION_DELAY = 2

function init()
	done = false
	doneTimer = 0
end

function tick(dt)
	if done then
        SetBool("level.alarm", false)
        SetFloat("level.timelimit", -1)
		if doneTimer < NOTIFICATION_DELAY then
			doneTimer = doneTimer + dt
			if doneTimer >= NOTIFICATION_DELAY and not GetBool("level.notified") then
				SetString("hud.notification", GetTranslatedStringByKey("UI_HUD_NOTE_ALL_DONE_TEXT"))
                SetBool("level.notified", true)
			end
		end
		return
	end
	if not HasKey("level.total_targets") then return end

	if GetInt("level.clearedprimary")+GetInt("level.clearedsecondary") >= GetInt("level.required")
    and (not HasKey("level.extra_step") or GetBool("level.complete"))
    then
		SetBool("level.alarm", false)
		SetBool("level.alarmdisabled", true)
		SetBool("level.delivering",false)
		SetBool("level.deliveryComplete", true)
		done = true
	end
end

