use bevy::prelude::*;
use bevy_steamworks::SteamworksPlugin;

pub fn plugin(app: &mut App) {
    let app_id = 1603000;

    // should only be done in production builds
    #[cfg(not(debug_assertions))]
    if steamworks::restart_app_if_necessary(app_id.into()) {
        info!("Restarting app via steam");
        return;
    }

    info!("steam app init: {app_id}");

    match SteamworksPlugin::init_app(app_id) {
        Ok(plugin) => {
            info!("steam app init done");
            app.add_plugins(plugin);
        }
        Err(e) => {
            warn!("steam init error: {e:?}");
        }
    };
}
