Skip to content

Commit

Permalink
chore: bump bevy dependency to v0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
umut-sahin committed Mar 30, 2024
1 parent 446ecd7 commit d967e87
Show file tree
Hide file tree
Showing 37 changed files with 135 additions and 145 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all -- --deny warnings
args: --all-targets -- --deny warnings

- name: Clippy (wasm)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all --target wasm32-unknown-unknown --no-default-features --features wasm-development -- --deny warnings
args: --all-targets --target wasm32-unknown-unknown --no-default-features --features wasm-development -- --deny warnings

build-native:
strategy:
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: --all
args: --all-targets

build-wasm:
name: Build (wasm)
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: --all --target wasm32-unknown-unknown --no-default-features --features wasm-development
args: --all-targets --target wasm32-unknown-unknown --no-default-features --features wasm-development

publish:
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
8 changes: 4 additions & 4 deletions enemies/sweet/src/chocolate_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl IEnemy for ChocolateBar {
}

fn collider(&self) -> Collider {
Collider::ball(SIZE)
Collider::circle(SIZE)
}

fn spawn(&self, world: &mut World, position: Position) {
Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn spawn(
mut counter: ResMut<EnemyCounter>,
) {
let mesh = MaterialMesh2dBundle {
mesh: meshes.add(shape::Circle::new(SIZE).into()).into(),
mesh: meshes.add(Circle::new(SIZE)).into(),
material: materials.add(ColorMaterial::from(COLOR)),
transform: Transform::from_translation(position.extend(Depth::Enemy.z())),
..default()
Expand Down Expand Up @@ -141,14 +141,14 @@ pub fn attack(

let projectile_entity = ProjectileBundle::builder()
.mesh(MaterialMesh2dBundle {
mesh: meshes.add(shape::Circle::new(PROJECTILE_SIZE).into()).into(),
mesh: meshes.add(Circle::new(PROJECTILE_SIZE)).into(),
material: materials.add(ColorMaterial::from(PROJECTILE_COLOR)),
transform: Transform::from_translation(
enemy_position.extend(Depth::Projectile.z()),
),
..default()
})
.collider(Collider::ball(PROJECTILE_SIZE))
.collider(Collider::circle(PROJECTILE_SIZE))
.position(enemy_position)
.velocity(LinearVelocity(player_direction * PROJECTILE_SPEED))
.damage(DAMAGE)
Expand Down
4 changes: 2 additions & 2 deletions enemies/sweet/src/gummy_bear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl IEnemy for GummyBear {
}

fn collider(&self) -> Collider {
Collider::ball(SIZE)
Collider::circle(SIZE)
}

fn spawn(&self, world: &mut World, position: Position) {
Expand Down Expand Up @@ -82,7 +82,7 @@ pub fn spawn(
mut counter: ResMut<EnemyCounter>,
) {
let mesh = MaterialMesh2dBundle {
mesh: meshes.add(shape::Circle::new(SIZE).into()).into(),
mesh: meshes.add(Circle::new(SIZE)).into(),
material: materials.add(ColorMaterial::from(Color::RED)),
transform: Transform::from_translation(position.extend(Depth::Enemy.z())),
..default()
Expand Down
22 changes: 11 additions & 11 deletions game/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ version = "0.0.0"
edition = "2021"

[dependencies]
bevy = { version = "0.12", features = ["serialize"] }
bevy-persistent = { version = "0.4" }
bevy_console = { version = "0.10" }
bevy_editor_pls = { version = "0.7", optional = true }
bevy_prng = { version = "0.2", features = ["rand_chacha"] }
bevy_rand = { version = "0.4" }
bevy_xpbd_2d = { version = "0.3" }
clap = { version = "4.3", features = ["derive"] }
bevy = { version = "0.13", features = ["serialize"] }
bevy-persistent = { version = "0.5" }
bevy_console = { version = "0.11" }
bevy_editor_pls = { version = "0.8", optional = true }
bevy_prng = { version = "0.5", features = ["rand_chacha"] }
bevy_rand = { version = "0.5" }
bevy_xpbd_2d = { version = "0.4" }
clap = { version = "4.5", features = ["derive"] }
dirs = { version = "5.0" }
leafwing-input-manager = { version = "0.11" }
leafwing-input-manager = { version = "0.13" }
rand = { version = "0.8" }
serde = { version = "1.0", features = ["derive"] }
smallvec = { version = "1.11", features = ["serde"] }
smallvec = { version = "1.13", features = ["serde"] }
smol_str = { version = "0.2" }
strum = { version = "0.26" }
strum_macros = { version = "0.26" }
typed-builder = { version = "0.18" }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
bevy-persistent-windows = { version = "0.4" }
bevy-persistent-windows = { version = "0.5" }

[target.'cfg(target_family = "wasm")'.dependencies]
instant = { version = "0.1" }
Expand Down
7 changes: 6 additions & 1 deletion game/src/camera/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ use crate::prelude::*;

/// Spawns the main camera.
pub fn spawn_main_camera(mut commands: Commands) {
commands.spawn((Name::new("Main Camera"), MainCamera, Camera2dBundle::default()));
commands.spawn((
Name::new("Main Camera"),
MainCamera,
Camera2dBundle::default(),
IsDefaultUiCamera,
));
}


Expand Down
16 changes: 5 additions & 11 deletions game/src/combat/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ pub struct ProjectileBundle {

impl ProjectileBundle {
/// Spawns the projectile.
fn spawn<'w, 's, 'a>(
fn spawn<'c>(
self,
commands: &'a mut Commands<'w, 's>,
commands: &'c mut Commands,
layers: CollisionLayers,
additional_components: impl Bundle,
) -> EntityCommands<'w, 's, 'a> {
) -> EntityCommands<'c> {
commands.spawn((
// Tags
Name::new("Projectile"),
Expand All @@ -57,10 +57,7 @@ impl ProjectileBundle {
}

/// Spawns the projectile toward the player.
pub fn spawn_toward_player<'w, 's, 'a>(
self,
commands: &'a mut Commands<'w, 's>,
) -> EntityCommands<'w, 's, 'a> {
pub fn spawn_toward_player<'c>(self, commands: &'c mut Commands) -> EntityCommands<'c> {
let layers = CollisionLayers::new(
[Layer::Projectile, Layer::DamagePlayer],
[Layer::MapBound, Layer::MapObstacle, Layer::PlayerHitBox],
Expand All @@ -69,10 +66,7 @@ impl ProjectileBundle {
}

/// Spawns the projectile toward enemies.
pub fn spawn_toward_enemies<'w, 's, 'a>(
self,
commands: &'a mut Commands<'w, 's>,
) -> EntityCommands<'w, 's, 'a> {
pub fn spawn_toward_enemies<'c>(self, commands: &'c mut Commands) -> EntityCommands<'c> {
let layers = CollisionLayers::new(
[Layer::Projectile, Layer::DamageEnemies],
[Layer::MapBound, Layer::MapObstacle, Layer::EnemyHitBox],
Expand Down
2 changes: 1 addition & 1 deletion game/src/combat/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn find_enemies_in_range_sorted_by_distance(
area,
position.xy(),
0.00,
SpatialQueryFilter::new().with_masks([Layer::EnemyHitBox]),
SpatialQueryFilter::from_mask([Layer::EnemyHitBox]),
);

let mut enemies_in_range = intersections
Expand Down
8 changes: 4 additions & 4 deletions game/src/configuration/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ impl KeyBindings {
impl Default for KeyBindings {
fn default() -> KeyBindings {
KeyBindings {
up: smallvec![KeyCode::W, KeyCode::Up],
left: smallvec![KeyCode::A, KeyCode::Left],
down: smallvec![KeyCode::S, KeyCode::Down],
right: smallvec![KeyCode::D, KeyCode::Right],
up: smallvec![KeyCode::KeyW, KeyCode::ArrowUp],
left: smallvec![KeyCode::KeyA, KeyCode::ArrowLeft],
down: smallvec![KeyCode::KeyS, KeyCode::ArrowDown],
right: smallvec![KeyCode::KeyD, KeyCode::ArrowRight],
dash: smallvec![KeyCode::Space],
pause: smallvec![KeyCode::Escape],
}
Expand Down
6 changes: 3 additions & 3 deletions game/src/core/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ impl Plugin for CorePlugin {
app.register_type::<DiagnosticsOverlayState>();

// Add states to the application.
app.add_state::<AppState>();
app.add_state::<GameState>();
app.add_state::<DiagnosticsOverlayState>();
app.init_state::<AppState>();
app.init_state::<GameState>();
app.init_state::<DiagnosticsOverlayState>();

// Transition to game mode selection screen when starting in game.
let args = app.world.resource::<Args>();
Expand Down
16 changes: 9 additions & 7 deletions game/src/enemy/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ pub struct EnemyBundle<E: Component + IEnemy> {

impl<E: Component + IEnemy> EnemyBundle<E> {
/// Spawns the enemy.
pub fn spawn<'w, 's, 'a>(
pub fn spawn<'c>(
self,
commands: &'a mut Commands<'w, 's>,
commands: &'c mut Commands,
counter: &mut EnemyCounter,
) -> EntityCommands<'w, 's, 'a> {
) -> EntityCommands<'c> {
counter.increment();

let name = self.enemy.name();
Expand All @@ -53,14 +53,16 @@ impl<E: Component + IEnemy> EnemyBundle<E> {
let speed = self.enemy.speed();
let collider = self.enemy.collider();

let mut collision_layers =
CollisionLayers::new([Layer::Enemy], [Layer::MapBound, Layer::Enemy]);
let mut collision_groups = LayerMask::from([Layer::Enemy]);
let mut collision_masks = LayerMask::from([Layer::MapBound, Layer::Enemy]);

if contact_damage.is_some() {
collision_layers = collision_layers.add_group(Layer::DamagePlayer);
collision_layers = collision_layers.add_mask(Layer::PlayerHitBox);
collision_groups.add([Layer::DamagePlayer]);
collision_masks.add([Layer::PlayerHitBox]);
}

let collision_layers = CollisionLayers::new(collision_groups, collision_masks);

let mut enemy = commands.spawn((
// Tags
Name::new(format!("Enemy {} [{}]", counter.get(), name)),
Expand Down
4 changes: 2 additions & 2 deletions game/src/enemy/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ pub fn spawn_enemy(world: &mut World, map_bounds: &MapBounds, spawn: &mut EnemyS
) -> Option<f32> {
let ray = spatial.cast_ray(
*origin,
direction,
Direction2d::new(direction).ok()?,
max_distance,
false,
SpatialQueryFilter::default().with_masks([Layer::MapBound]),
SpatialQueryFilter::from_mask([Layer::MapBound]),
);
ray.map(|details| details.time_of_impact)
}
Expand Down
12 changes: 6 additions & 6 deletions game/src/input/actions/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ impl GameAction {
// Extend the input map from key bindings.
let key_bindings = app.world.resource::<Persistent<KeyBindings>>();
for key_code in key_bindings.up.iter().cloned() {
input_map.insert(key_code, GameAction::MoveUp);
input_map.insert(GameAction::MoveUp, key_code);
}
for key_code in key_bindings.left.iter().cloned() {
input_map.insert(key_code, GameAction::MoveLeft);
input_map.insert(GameAction::MoveLeft, key_code);
}
for key_code in key_bindings.down.iter().cloned() {
input_map.insert(key_code, GameAction::MoveDown);
input_map.insert(GameAction::MoveDown, key_code);
}
for key_code in key_bindings.right.iter().cloned() {
input_map.insert(key_code, GameAction::MoveRight);
input_map.insert(GameAction::MoveRight, key_code);
}
for key_code in key_bindings.dash.iter().cloned() {
input_map.insert(key_code, GameAction::Dash);
input_map.insert(GameAction::Dash, key_code);
}
for key_code in key_bindings.pause.iter().cloned() {
input_map.insert(key_code, GameAction::Pause);
input_map.insert(GameAction::Pause, key_code);
}

// Insert the input map resource.
Expand Down
6 changes: 3 additions & 3 deletions game/src/input/actions/game_over_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ impl GameOverMenuAction {
app.add_plugins(InputManagerPlugin::<GameOverMenuAction>::default());

// Create the input map.
let mut input_map = InputMap::new([(KeyCode::Return, GameOverMenuAction::Select)]);
let mut input_map = InputMap::new([(GameOverMenuAction::Select, KeyCode::Enter)]);

// Extend the input map from key bindings.
let key_bindings = app.world.resource::<Persistent<KeyBindings>>();
for key_code in key_bindings.up.iter().cloned() {
input_map.insert(key_code, GameOverMenuAction::Up);
input_map.insert(GameOverMenuAction::Up, key_code);
}
for key_code in key_bindings.down.iter().cloned() {
input_map.insert(key_code, GameOverMenuAction::Down);
input_map.insert(GameOverMenuAction::Down, key_code);
}

// Insert the input map resource.
Expand Down
6 changes: 3 additions & 3 deletions game/src/input/actions/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ impl GlobalAction {
// Create the input map.
let mut input_map = InputMap::default();

input_map.insert(KeyCode::F11, GlobalAction::ToggleFullscreen);
input_map.insert(KeyCode::F10, GlobalAction::ToggleDiagnosticsOverlay);
input_map.insert(GlobalAction::ToggleFullscreen, KeyCode::F11);
input_map.insert(GlobalAction::ToggleDiagnosticsOverlay, KeyCode::F10);

#[cfg(feature = "development")]
input_map.insert(
UserInput::chord([KeyCode::ControlLeft, KeyCode::P]),
GlobalAction::TogglePhysicsDebug,
UserInput::chord([KeyCode::ControlLeft, KeyCode::KeyP]),
);

// Insert the input map resource.
Expand Down
6 changes: 3 additions & 3 deletions game/src/input/actions/main_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ impl MainMenuAction {
app.add_plugins(InputManagerPlugin::<MainMenuAction>::default());

// Create the input map.
let mut input_map = InputMap::new([(KeyCode::Return, MainMenuAction::Select)]);
let mut input_map = InputMap::new([(MainMenuAction::Select, KeyCode::Enter)]);

// Extend the input map from key bindings.
let key_bindings = app.world.resource::<Persistent<KeyBindings>>();
for key_code in key_bindings.up.iter().cloned() {
input_map.insert(key_code, MainMenuAction::Up);
input_map.insert(MainMenuAction::Up, key_code);
}
for key_code in key_bindings.down.iter().cloned() {
input_map.insert(key_code, MainMenuAction::Down);
input_map.insert(MainMenuAction::Down, key_code);
}

// Insert the input map resource.
Expand Down
8 changes: 4 additions & 4 deletions game/src/input/actions/pause_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ impl PauseMenuAction {

// Create the input map.
let mut input_map = InputMap::new([
(KeyCode::Escape, PauseMenuAction::Resume),
(KeyCode::Return, PauseMenuAction::Select),
(PauseMenuAction::Resume, KeyCode::Escape),
(PauseMenuAction::Select, KeyCode::Enter),
]);

// Extend the input map from key bindings.
let key_bindings = app.world.resource::<Persistent<KeyBindings>>();
for key_code in key_bindings.up.iter().cloned() {
input_map.insert(key_code, PauseMenuAction::Up);
input_map.insert(PauseMenuAction::Up, key_code);
}
for key_code in key_bindings.down.iter().cloned() {
input_map.insert(key_code, PauseMenuAction::Down);
input_map.insert(PauseMenuAction::Down, key_code);
}

// Insert the input map resource.
Expand Down
8 changes: 4 additions & 4 deletions game/src/input/actions/player_selection_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ impl PlayerSelectionScreenAction {

// Create the input map.
let mut input_map = InputMap::new([
(KeyCode::Escape, PlayerSelectionScreenAction::Back),
(KeyCode::Return, PlayerSelectionScreenAction::Select),
(PlayerSelectionScreenAction::Back, KeyCode::Escape),
(PlayerSelectionScreenAction::Select, KeyCode::Enter),
]);

// Extend the input map from key bindings.
let key_bindings = app.world.resource::<Persistent<KeyBindings>>();
for key_code in key_bindings.up.iter().cloned() {
input_map.insert(key_code, PlayerSelectionScreenAction::Up);
input_map.insert(PlayerSelectionScreenAction::Up, key_code);
}
for key_code in key_bindings.down.iter().cloned() {
input_map.insert(key_code, PlayerSelectionScreenAction::Down);
input_map.insert(PlayerSelectionScreenAction::Down, key_code);
}

// Insert the input map resource.
Expand Down
Loading

0 comments on commit d967e87

Please sign in to comment.