/*
* 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_rapier3d::prelude::*;
use crate::{api::game::Game, game_status::GameStatus, AppState, Global};
use self::card::VisualCardBundle;
use super::GameDetailsCallEvent;
mod card;
mod hand;
mod supply;
mod ui;
pub struct GamePlugin;
impl Plugin for GamePlugin {
fn build(&self, app: &mut App) {
app.insert_resource(GameData::default())
.add_plugin(ui::GameUIPlugin)
.add_plugin(card::CardPlugin)
.add_plugin(supply::SupplyPlugin)
.add_plugin(hand::HandPlugin)
.add_system(game_setup.in_schedule(OnEnter(AppState::InGame)));
}
}
#[derive(Resource)]
pub struct GameData {
pub game: Option<Game>,
pub game_status: Option<GameStatus>,
pub parsing_data: bool,
}
impl Default for GameData {
fn default() -> Self {
Self {
game: None,
game_status: None,
parsing_data: false,
}
}
}
fn game_setup(
mut commands: Commands,
mut details_ev_w: EventWriter<GameDetailsCallEvent>,
global: Res<Global>,
) {
details_ev_w.send(GameDetailsCallEvent {
game_id: global.cur_game_id.clone(),
});
// create the playing surface
commands
.spawn(Collider::cuboid(20., 0.5, 20.))
.insert(TransformBundle::from(Transform::from_xyz(0., -0.5, 0.)));
}