// IW6 GSC SOURCE
// Generated by https://github.com/xensik/gsc-tool

init_unlock()
{
    load_unlock_from_table();
}

init_player_unlock()
{
    self.unlock_list = [];

    if ( isdefined( level.unlock_registration_func ) )
        [[ level.unlock_registration_func ]]();

    if ( maps\mp\alien\_utility::is_true( level.include_default_unlocks ) )
        register_default_unlocks();
}

register_default_unlocks()
{
    register_unlock( "UNLOCK_ESCAPE", 1, 1, ::default_init );
    register_unlock( "UNLOCK_ESCAPE_10_TIMES", 2, 10, ::default_init );
    register_unlock( "UNLOCK_ESCAPE_20_TIMES", 3, 20, ::default_init );
    register_unlock( "UNLOCK_ESCAPE_50_TIMES", 4, 50, ::default_init );
}

register_unlock( var_0, var_1, var_2, var_3 )
{
    var_4 = spawnstruct();
    var_4 [[ var_3 ]]( var_1, var_2 );
    self.unlock_list[var_0] = var_4;
}

default_init( var_0, var_1 )
{
    self.progress = 0;
    self.index_map = var_0;
    self.goal = var_1;
}

update_progress( var_0 )
{
    self.progress = self.progress + var_0;
}

is_goal_achieved()
{
    return self.progress >= self.goal;
}

is_valid_unlock( var_0 )
{
    return isdefined( var_0 );
}

update_unlock( var_0, var_1 )
{
    var_2 = self.unlock_list[var_0];

    if ( !is_valid_unlock( var_2 ) )
        return;

    var_2 update_progress( var_1 );

    if ( var_2 is_goal_achieved() )
        var_3 = level.alien_unlock_data[var_2.index_map];
}

update_escape_item_unlock( var_0 )
{
    foreach ( var_2 in var_0 )
    {
        var_3 = var_2 maps\mp\alien\_persistence::get_player_escaped();
        var_2 update_personal_escape_item_unlock( var_3 );
        var_4 = var_2 maps\mp\alien\_prestige::get_num_nerf_selected();
        var_5 = var_2 maps\mp\alien\_persistence::get_player_highest_nerf_escape_count();

        if ( var_4 > var_5 )
            var_2 setcoopplayerdata( "alienPlayerStats", "headShots", var_4 );
    }
}

update_personal_escape_item_unlock( var_0 )
{
    update_unlock( "UNLOCK_ESCAPE", 1 );
    update_unlock( "UNLOCK_ESCAPE_10_TIMES", var_0 );
    update_unlock( "UNLOCK_ESCAPE_20_TIMES", var_0 );
    update_unlock( "UNLOCK_ESCAPE_50_TIMES", var_0 );
}

load_unlock_from_table()
{
    level.alien_unlock_data = [];

    if ( isdefined( level.alien_unlock_table ) )
        var_0 = level.alien_unlock_table;
    else
        var_0 = "mp/alien/unlocktable.csv";

    for ( var_1 = 100; var_1 <= 110; var_1++ )
    {
        var_2 = tablelookup( var_0, 0, var_1, 1 );

        if ( var_2 == "" )
            break;

        var_3 = tablelookup( var_0, 0, var_1, 3 );
        var_4 = spawnstruct();
        var_4.item = var_2;
        var_4.type = var_3;
        level.alien_unlock_data[level.alien_unlock_data.size] = var_4;
    }
}
