cleanup
This commit is contained in:
parent
59399c3590
commit
81cb5c24d4
5 changed files with 17 additions and 43 deletions
|
|
@ -1,5 +1,4 @@
|
|||
use bevy::prelude::*;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::tiles::{self, *};
|
||||
|
||||
|
|
@ -25,7 +24,7 @@ impl Plugin for Riichi {
|
|||
.add_systems(Startup, tiles::init_tiles)
|
||||
.init_state::<GameState>()
|
||||
.add_systems(OnEnter(GameState::Setup), (wall::build_wall, hand::deal_hands, setup_done).chain())
|
||||
// .add_systems(Update, systems)
|
||||
.add_systems(Update, (hand::sort_hand).run_if(in_state(GameState::Play)))
|
||||
// semicolon stopper
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use bevy::log::tracing::instrument;
|
||||
use bevy::prelude::*;
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#![allow(unused)]
|
||||
|
||||
pub mod game;
|
||||
pub mod tiles;
|
||||
pub mod yakus;
|
||||
|
||||
pub mod game;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
use bevy::{ecs::entity::MapEntities, prelude::*};
|
||||
use strum::FromRepr;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::game::{hand::HandTiles, wall::WallTiles};
|
||||
|
||||
#[derive(Component, Debug)]
|
||||
pub struct Tile {
|
||||
|
|
|
|||
|
|
@ -18,11 +18,22 @@ enum TuiState {
|
|||
InGame,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RiichiTui {
|
||||
// player_names: Vec<String>,
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
struct InGame;
|
||||
|
||||
impl ComputedStates for InGame {
|
||||
type SourceStates = TuiState;
|
||||
|
||||
fn compute(sources: Self::SourceStates) -> Option<Self> {
|
||||
match sources {
|
||||
TuiState::MainMenu => None,
|
||||
TuiState::InGame => Some(Self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RiichiTui;
|
||||
impl Plugin for RiichiTui {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins((
|
||||
|
|
@ -45,48 +56,17 @@ impl Plugin for RiichiTui {
|
|||
// general setup
|
||||
.init_state::<TuiState>()
|
||||
.add_computed_state::<InGame>()
|
||||
.add_systems(Update, curr_state)
|
||||
|
||||
// main menu
|
||||
.add_systems(Update, (menu::draw_mainmenu, menu::mainmenu_input).run_if(in_state(TuiState::MainMenu)))
|
||||
|
||||
// gaming
|
||||
.init_resource::<render::hand::RenderedHand>()
|
||||
.add_systems(OnEnter(GameState::Play), render::hand::render_hand)
|
||||
.add_systems(Update, render::ingame::draw_ingame.run_if(in_state(InGame)))
|
||||
.add_systems(Update, render::hand::render_changed_hand.run_if(in_state(InGame).and(in_state(GameState::Play))))
|
||||
.add_systems(Update, render::ingame::draw_ingame.run_if(in_state(TuiState::InGame)))
|
||||
|
||||
// semicolon stopper
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
fn curr_state(
|
||||
curr_gamestate: Option<Res<State<GameState>>>,
|
||||
curr_tuistate: Res<State<TuiState>>,
|
||||
curr_ingame: Option<Res<State<InGame>>>,
|
||||
) {
|
||||
if let Some(curr_gamestate) = curr_gamestate && curr_gamestate.is_changed(){
|
||||
trace!("GameState: {curr_gamestate:?}")
|
||||
}
|
||||
if curr_tuistate.is_changed() {
|
||||
trace!("TuiState: {curr_tuistate:?}")
|
||||
}
|
||||
if let Some(curr_ingame) = curr_ingame && curr_ingame.is_changed(){
|
||||
trace!("InGame: {curr_ingame:?}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||
struct InGame;
|
||||
|
||||
impl ComputedStates for InGame {
|
||||
type SourceStates = TuiState;
|
||||
|
||||
fn compute(sources: Self::SourceStates) -> Option<Self> {
|
||||
match sources {
|
||||
TuiState::MainMenu => None,
|
||||
TuiState::InGame => Some(Self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue