Skip to content

Commit 03c1df7

Browse files
authored
0 16 (#5)
* 0.16- compiling, some stuff is not yet working * Migration complete * Game Turns into substate * observer in children * Animations for UI
1 parent 68c9c24 commit 03c1df7

File tree

19 files changed

+1582
-714
lines changed

19 files changed

+1582
-714
lines changed

Cargo.lock

Lines changed: 901 additions & 358 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,27 @@ opt-level = 1
2121
opt-level = 2
2222

2323
[workspace.dependencies]
24-
bevy = {version = "0.15"}
24+
bevy = {version = "0.16"}
2525
serde = { version = "1", features = ["derive"] }
2626
serde_json = "1"
2727

2828
[dependencies]
2929
game_core = {path = "crates/game_core", features = ["bevy"]}
3030
console_error_panic_hook = "0.1"
31-
bevy = {workspace = true, default-features = true}
31+
bevy = {workspace = true, default-features = true, features = ["configurable_error_handler"]}
3232
serde = {workspace = true}
3333
serde_json = {workspace = true}
3434
inline_tweak = "1"
35-
bevy_tweening = "0.12"
36-
bevy_pkv = "0.12"
35+
bevy_tweening = "0.13"
36+
bevy_pkv = "0.13"
3737
rand = "0.8"
38-
bevy_asset_loader = "0.22"
38+
bevy_asset_loader = "0.23.0-rc.3"
3939
webbrowser = "1"
40-
#bevy_ecss = {git = "https://github.com/afonsolage/bevy_ecss.git", rev = "ea1ef7bd5eab5fff289c7426018ecc8ab5669823"}
41-
bevy_common_assets = { version = "0.12", features = ["json"] }
42-
bevy_simple_text_input = "0.10"
40+
bevy_common_assets = { version = "0.13", features = ["json"] }
41+
bevy_simple_text_input = "0.11"
4342

4443
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
45-
bevy-inspector-egui = "0.29"
44+
bevy-inspector-egui = "0.31"
4645
#iyes_perf_ui = "0.2"
4746

4847
[target.'cfg(target_arch = "wasm32")'.dependencies.web-sys]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![slavic castles logo](https://i.imgur.com/h6HYvQc.png "Slavic Castles Logo")
22

3-
Card game prototype written in Rust with Bevy 0.15
3+
Card game prototype written in Rust with Bevy 0.16
44

55
itch.io page: [itch.io](https://leinnan.itch.io/slavic-castles)
66
Play live here: [wasm version](https://leinnan.github.io/castles_fight/)

crates/game_core/src/data/player.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use crate::consts;
12
#[cfg(feature = "bevy")]
23
use bevy::{prelude::Component, reflect::Reflect};
3-
use crate::consts;
44
use serde::{Deserialize, Serialize};
55

66
#[derive(Copy, Debug, Clone, Serialize, Deserialize)]

src/base_systems/debug.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::fmt;
21
use bevy::app::{App, Plugin};
32
use bevy::prelude::*;
43
use bevy_inspector_egui::bevy_egui::{egui, EguiContext, EguiPlugin};
54
use bevy_inspector_egui::{
65
bevy_inspector::hierarchy::SelectedEntities, DefaultInspectorConfigPlugin,
76
};
7+
use std::fmt;
88
// use iyes_perf_ui::prelude::*;
99

1010
// const MY_ACCENT_COLOR32: bevy_inspector_egui::bevy_egui::egui::Color32 =
@@ -57,21 +57,24 @@ pub struct DebugPlugin;
5757

5858
impl Plugin for DebugPlugin {
5959
fn build(&self, app: &mut App) {
60+
app.add_plugins(EguiPlugin {
61+
enable_multipass_for_primary_context: false,
62+
});
6063
app.add_systems(Startup, configure_egui);
6164
app.add_systems(
62-
Update,
65+
bevy_inspector_egui::bevy_egui::EguiContextPass,
6366
inspector_ui, //.run_if(not(in_state(crate::states::MainState::Editor))),
6467
)
6568
// .add_systems(
6669
// Update,
6770
// (toggle_perf_ui).run_if(input_just_pressed(KeyCode::F2)),
6871
// )
69-
.add_plugins(bevy::diagnostic::FrameTimeDiagnosticsPlugin)
70-
.add_plugins(bevy::diagnostic::EntityCountDiagnosticsPlugin)
71-
.add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin)
72+
// .add_plugins(bevy::diagnostic::FrameTimeDiagnosticsPlugin)
73+
// .add_plugins(bevy::diagnostic::EntityCountDiagnosticsPlugin)
74+
// .add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin)
7275
// .add_plugins(PerfUiPlugin)
7376
// .insert_resource(bevy_mod_picking::debug::DebugPickingMode::Normal)
74-
.add_plugins((EguiPlugin, DefaultInspectorConfigPlugin));
77+
.add_plugins(DefaultInspectorConfigPlugin);
7578
}
7679
}
7780
// fn toggle_perf_ui(q: Query<Entity, With<PerfUiRoot>>, mut commands: Commands) {
@@ -128,7 +131,7 @@ fn inspector_ui(
128131
}
129132
let Ok(egui_context) = world
130133
.query_filtered::<&mut EguiContext, With<PrimaryWindow>>()
131-
.get_single(world)
134+
.single(world)
132135
else {
133136
return;
134137
};

src/base_systems/turn_based.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::states::game_states::GameState;
12
use bevy::prelude::*;
23

34
#[derive(Default, Debug, Reflect, Component)]
@@ -6,7 +7,8 @@ pub struct CurrentActorToken;
67
#[derive(Deref, DerefMut, Component, Default, Reflect)]
78
pub struct ActorTurn(pub usize);
89

9-
#[derive(Debug, Hash, PartialEq, Eq, Default, Clone, States)]
10+
#[derive(Debug, Hash, PartialEq, Eq, Default, Clone, SubStates)]
11+
#[source(GameState = GameState::Game)]
1012
pub enum GameTurnSteps {
1113
#[default]
1214
SearchForAgents,
@@ -17,21 +19,24 @@ pub enum GameTurnSteps {
1719
pub fn register_system(app: &mut App) {
1820
app.register_type::<ActorTurn>()
1921
.register_type::<CurrentActorToken>()
20-
.init_state::<GameTurnSteps>()
22+
.add_sub_state::<GameTurnSteps>()
2123
.add_systems(OnExit(GameTurnSteps::PerformAction), remove_token)
2224
.add_systems(
2325
Update,
24-
search_for_actors.run_if(in_state(GameTurnSteps::SearchForAgents)),
26+
search_for_actors.run_if(
27+
in_state(GameTurnSteps::SearchForAgents)
28+
.and(not(crate::states::game::game_ended_condition)),
29+
),
2530
);
2631
}
2732

2833
pub fn search_for_actors(
2934
mut commands: Commands,
3035
q: Query<(&ActorTurn, Entity)>,
3136
mut next_state: ResMut<NextState<GameTurnSteps>>,
32-
) {
37+
) -> Result {
3338
if q.is_empty() {
34-
return;
39+
return Ok(());
3540
}
3641

3742
let mut lowest_delay = (usize::MAX, Entity::PLACEHOLDER);
@@ -42,19 +47,26 @@ pub fn search_for_actors(
4247
}
4348
}
4449
if lowest_delay.0 < usize::MAX {
45-
commands.entity(lowest_delay.1).insert(CurrentActorToken);
50+
commands
51+
.get_entity(lowest_delay.1)?
52+
.insert(CurrentActorToken);
4653
next_state.set(GameTurnSteps::ActionSelection);
4754
info!("FOUNDED ACTOR ENTITY {:?}", lowest_delay.1);
4855
}
56+
57+
Ok(())
4958
}
5059

5160
fn remove_token(
5261
mut commands: Commands,
5362
mut query: Query<(Entity, &mut ActorTurn), With<CurrentActorToken>>,
5463
) {
55-
let Ok((entity, mut delay)) = query.get_single_mut() else {
64+
warn!("Remove token");
65+
let Ok((entity, mut delay)) = query.single_mut() else {
5666
return;
5767
};
5868
delay.0 = **delay + 2;
59-
commands.entity(entity).remove::<CurrentActorToken>();
69+
if let Ok(mut e) = commands.get_entity(entity) {
70+
e.remove::<CurrentActorToken>();
71+
}
6072
}

0 commit comments

Comments
 (0)