/*
* This file is part of laurelin_client
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* Licensed under GPL-3.0-only.
* See LICENSE for licensing information.
*/
use bevy::prelude::*;
use bevy_editor_pls::EditorPlugin;
use bevy_egui::EguiPlugin;
mod api;
mod macros;
mod util;
mod plugins;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, States)]
enum AppState {
#[default]
Menu,
InGame,
}
fn main() {
let mut app = App::new();
app.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: String::from("Laurelin Client"),
..Default::default()
}),
..Default::default()
}));
info!("laurelin client initializing");
// dev
app.add_plugin(EditorPlugin::default());
// the egui plugin is also added by the editor plugin
if !app.is_plugin_added::<EguiPlugin>() {
app.add_plugin(EguiPlugin);
}
// clear color
app.insert_resource(ClearColor(Color::rgb(0.53, 0.53, 0.7)));
// add the top level app state
app.add_state::<AppState>();
// holds networking options and a request agent
app.insert_resource(NetworkingOptions {
api_address: "http://localhost:3000/api".to_string(),
req: reqwest::blocking::Client::new(),
user_token: "".to_string(),
});
// has handlers for all async tasks
app.add_plugin(plugins::AsyncTasksPlugin);
app.add_plugin(plugins::MenuPlugin);
app.add_startup_system(setup);
app.run();
info!("goodbye");
}
fn setup(mut commands: Commands) {
let camera_bundle = Camera3dBundle::default();
commands.spawn(camera_bundle);
}
#[derive(Clone, Resource)]
pub struct NetworkingOptions {
/// api address with no trailing slash
api_address: String,
/// reqwest agent
/// NOTE: mainly for the future, because it can hold cookies
req: reqwest::blocking::Client,
/// feels wrong storing this here but "it's temporary"
user_token: String,
}