function p.new_game()
    ga_move_set_body_fly(
        std.vec(0,0,0), --Do not translate.
        0.3, --radius
        true) --Use "true up".
end

function p.load_game()
    ga_hud_window_add("win_hud", 0)
    ga_hud_window_add("win_hud_diamonds",1)
end

function p.update()
    --Death checking.
    if ga_get_i("game.player.health.amount") < 0 then
        if ga_get_sys_b("game.player.alive") then
            ga_play_sound("player_death")
            top2.kill_player()
        end
    end
    if not ga_get_sys_b("game.player.alive") then
        ga_hud_window_add("xar_win_death", 1000)
    end

    --Inventory regen, etc.
    game_inv_regen.update()
end

function p.update_passive()
    --Nothing to do.
end

function p.update_discrete_pre()
    --Nothing to do.
end

function p.update_discrete_post()
    game_movement.update_discrete()
end

function p.game_input(str)
    if (str == "help") then
        ga_console_print("Strings that can be passed to game_input:");
        ga_console_print("\n");
        ga_console_print("free_diamond")
        ga_console_print("use_equipped (primary | secondary) (start | stop)");
        ga_console_print("equip_from_screen_inv_wheel");
        ga_console_print("equip_from_screen_inv NUM");
        ga_console_print("open window hud_1");
        ga_console_print("open window hud_2");
        ga_console_print("marker (start | stop)");
        ga_console_print("cheat_giveall");
        ga_console_print("cheat_giveupgrades");
        return ""
    end

    if( str == "__game_saved__" ) then
        game_msg.add("Game saved")
        return ""
    end

    if( str:find("^__spiral_of_death__") ~= nil ) then
        num = string.gsub(str, "^__spiral_of_death__ ", "")
        --game_msg.add("*** Danger: spiral of death: " .. num)
        game_msg.add("SOD: " .. num)
        return ""
    end

    if( str:find("^move") ~= nil ) then
        --str starts with "move".
        game_movement.input(str)
        return ""
    end

    if( str == "free_diamond" ) then
        num_diamonds = ga_get_i("game.diamonds")
        num_diamonds = num_diamonds + 1
        ga_set_i("game.diamonds", num_diamonds)
        ga_play_sound("gold")
        return ""
    end

    if (str == "equip_from_screen_inv_wheel" ) then
        total = ga_get_sys_i("game.input.mouse.wheel_value")
        if (total ~= 0) then
            i = ga_get_i("xar.player.cur_wep")
            i = i + total
            while( i < 0 ) do i = i + 10 end
            i = (i % 10)
            ga_set_i("xar.player.cur_wep", i)
            xar_inv_exec.end_use()
        end
        return ""
    elseif (str == "use_equipped primary start") then
        --Can do something!
    elseif (str == "use_equipped primary stop") then
        --Can do something!
    elseif (str == "use_equipped secondary start") then
        --Can do something!
    elseif (str == "use_equipped secondary stop") then
        --Can do something!
    else
        ga_console_print("^1Error: unknown string passed to game_input: ")
        ga_console_print(str)
    end
    return ""
end

function p.screen_inv_selected()
    return ga_get_i("xar.player.cur_wep")
end

function p.killed_player()
    ga_play_sound("player_death")
end

function p.respawn_player()
    --Nothing to do.
end
