-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Cast only spells that are unlocked, add spell debug mode
- Loading branch information
Showing
8 changed files
with
145 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use bevy::prelude::*; | ||
|
||
use super::{Spell, SpellCasted}; | ||
|
||
#[derive(Resource, Default)] | ||
pub struct DebugSpell { | ||
pub active: bool, | ||
} | ||
|
||
fn toggle_debug_mod( | ||
mut debug_spell: ResMut<DebugSpell>, | ||
mut ev_spell_casted: EventReader<SpellCasted>, | ||
) { | ||
for ev in ev_spell_casted.read() { | ||
if ev.spell == Spell::Debug { | ||
debug_spell.active = !debug_spell.active; | ||
} | ||
} | ||
} | ||
|
||
pub struct DebugSpellPlugin; | ||
|
||
impl Plugin for DebugSpellPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.init_resource::<DebugSpell>() | ||
.add_systems(Update, toggle_debug_mod); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use bevy::prelude::*; | ||
use bevy_screen_diagnostics::{ | ||
ScreenDiagnostics, ScreenDiagnosticsPlugin, ScreenEntityDiagnosticsPlugin, | ||
ScreenFrameDiagnosticsPlugin, | ||
}; | ||
|
||
use crate::{spell::debug_spell::DebugSpell, GameState}; | ||
|
||
#[derive(Resource, Default)] | ||
struct Diagnostics { | ||
active: bool, | ||
} | ||
|
||
fn toggle(screen_diags: &mut ResMut<ScreenDiagnostics>) { | ||
screen_diags.modify("fps").toggle(); | ||
screen_diags.modify("ms/frame").toggle(); | ||
screen_diags.modify("entities").toggle(); | ||
} | ||
|
||
fn toggle_off(mut screen_diags: ResMut<ScreenDiagnostics>) { | ||
toggle(&mut screen_diags); | ||
} | ||
|
||
fn toggle_diagnostics( | ||
debug_spell: Res<DebugSpell>, | ||
mut diags: ResMut<Diagnostics>, | ||
mut screen_diags: ResMut<ScreenDiagnostics>, | ||
) { | ||
if debug_spell.active != diags.active { | ||
diags.active = debug_spell.active; | ||
toggle(&mut screen_diags); | ||
} | ||
} | ||
|
||
pub struct DiagnosticsPlugin; | ||
|
||
impl Plugin for DiagnosticsPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_plugins(( | ||
ScreenDiagnosticsPlugin { | ||
timestep: 1.0, | ||
style: Style { | ||
position_type: PositionType::Absolute, | ||
top: Val::Px(5.0), | ||
left: Val::Px(15.0), | ||
..default() | ||
}, | ||
..default() | ||
}, | ||
ScreenFrameDiagnosticsPlugin, | ||
ScreenEntityDiagnosticsPlugin, | ||
)) | ||
.init_resource::<Diagnostics>() | ||
.add_systems(OnEnter(GameState::Gaming), toggle_off) | ||
.add_systems( | ||
Update, | ||
toggle_diagnostics.run_if(resource_changed::<DebugSpell>()), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters