turn debug
This commit is contained in:
parent
4c8929ac68
commit
007ddf56b1
3 changed files with 33 additions and 15 deletions
|
|
@ -7,6 +7,7 @@ use crate::{
|
|||
drag::{CardDropped, MousePosition},
|
||||
},
|
||||
grid::Grid,
|
||||
turns::TurnUnit,
|
||||
unit::UnitTextures,
|
||||
};
|
||||
|
||||
|
|
@ -29,6 +30,7 @@ pub fn card_playing_system(
|
|||
AnimatedTransform::identity(),
|
||||
Transform::from_translation(mouse_position.0),
|
||||
bundle,
|
||||
TurnUnit,
|
||||
))
|
||||
.id();
|
||||
if grid.try_set(mouse_position.0.truncate(), unit) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use bevy::prelude::*;
|
|||
|
||||
use crate::buttons;
|
||||
use crate::card;
|
||||
use crate::turns::TurnState;
|
||||
use crate::turns::try_confirm_turn;
|
||||
|
||||
const PANEL_BORDER: Color = Color::srgb_u8(36, 36, 143);
|
||||
|
|
@ -13,10 +14,14 @@ pub struct DevToolsPlugin;
|
|||
|
||||
impl Plugin for DevToolsPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, setup_debug_menu);
|
||||
app.add_systems(Startup, setup_debug_menu)
|
||||
.add_systems(Update, print_state);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
struct TurnStateLabel;
|
||||
|
||||
fn setup_debug_menu(mut commands: Commands) {
|
||||
let root = commands
|
||||
.spawn((
|
||||
|
|
@ -53,6 +58,14 @@ fn setup_debug_menu(mut commands: Commands) {
|
|||
BorderColor::all(PANEL_BORDER),
|
||||
BackgroundColor(PANEL_BACKGROUND),
|
||||
ChildOf(root),
|
||||
children![(
|
||||
Text::new(""),
|
||||
TextFont {
|
||||
font_size: 11.0,
|
||||
..default()
|
||||
},
|
||||
TurnStateLabel
|
||||
)],
|
||||
))
|
||||
.id();
|
||||
|
||||
|
|
@ -73,6 +86,18 @@ fn setup_debug_menu(mut commands: Commands) {
|
|||
);
|
||||
}
|
||||
|
||||
fn print_state(
|
||||
mut state_label: Single<&mut Text, With<TurnStateLabel>>,
|
||||
state: Res<State<TurnState>>,
|
||||
) {
|
||||
state_label.0 = match state.get() {
|
||||
TurnState::Turn => "Your turn".to_string(),
|
||||
TurnState::PreEffectProcess => "Processing pre unit effects".to_string(),
|
||||
TurnState::UnitProcess => "Processing units".to_string(),
|
||||
TurnState::PostEffectProcess => "Processing post unit effects".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn button(child_of: Entity, text: impl Into<String>) -> impl Bundle {
|
||||
(
|
||||
Button,
|
||||
|
|
|
|||
19
src/turns.rs
19
src/turns.rs
|
|
@ -16,7 +16,7 @@ impl Plugin for TurnSystemPlugin {
|
|||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct TurnBusy(pub bool);
|
||||
pub struct TurnBusy;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct TurnPreEffect;
|
||||
|
|
@ -38,17 +38,17 @@ pub enum TurnState {
|
|||
|
||||
fn pre_effect_setup(mut commands: Commands, query: Query<Entity, With<TurnPreEffect>>) {
|
||||
for effect in query {
|
||||
commands.entity(effect).insert(TurnBusy(false));
|
||||
commands.entity(effect).insert(TurnBusy);
|
||||
}
|
||||
}
|
||||
fn unit_setup(mut commands: Commands, query: Query<Entity, With<TurnUnit>>) {
|
||||
for unit in query {
|
||||
commands.entity(unit).insert(TurnBusy(false));
|
||||
commands.entity(unit).insert(TurnBusy);
|
||||
}
|
||||
}
|
||||
fn post_effect_setup(mut commands: Commands, query: Query<Entity, With<TurnPostEffect>>) {
|
||||
for effect in query {
|
||||
commands.entity(effect).insert(TurnBusy(false));
|
||||
commands.entity(effect).insert(TurnBusy);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -59,16 +59,7 @@ pub fn try_confirm_turn(mut commands: Commands, turn_state: Res<State<TurnState>
|
|||
}
|
||||
|
||||
fn process_busy_turnables(mut commands: Commands, query: Query<(Entity, &TurnBusy)>) {
|
||||
let mut advance_flag: bool = true;
|
||||
for (turnable, component) in query {
|
||||
if component.0 {
|
||||
commands.entity(turnable).remove::<TurnBusy>();
|
||||
} else {
|
||||
advance_flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if advance_flag {
|
||||
if query.iter().len() == 0 {
|
||||
commands.run_system_cached(try_advance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue