Skip to content

Commit ad2b14a

Browse files
authored
feat: map selection and game loading state (#18)
* wip: map selection and game loading state * fix: navmesh generation not triggered, wrong states * fix: regenerate navmesh if already exists * fix: game flow app state * feat: show a preview of the selected map as image * feat: selected map text color
1 parent 819c862 commit ad2b14a

File tree

27 files changed

+549
-191
lines changed

27 files changed

+549
-191
lines changed
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

assets/maps/tiny_town/preview.png

Lines changed: 3 additions & 0 deletions
Loading

src/enemy/shooting/components.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use bevy::prelude::*;
22

33
#[derive(Component)]
4-
pub struct EnemyBullet;
4+
pub struct EnemyBullet {
5+
pub origin_enemy: Entity,
6+
}
57

68
/// A timer so that enemies don't just shoot every frame but every x seconds
79
#[derive(Component)]

src/enemy/shooting/systems.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,19 @@ pub fn detect_player_bullet_collision_with_enemy(
5454

5555
pub fn enemy_shoot_player(
5656
mut commands: Commands,
57-
enemy_query: Query<(&Enemy, &Transform, &EnemyShootPlayerCooldownTimer)>,
57+
enemy_query: Query<(
58+
Entity,
59+
&Enemy,
60+
&Transform,
61+
&EnemyShootPlayerCooldownTimer,
62+
)>,
5863
) {
59-
for (enemy, enemy_transform, enemy_shoot_player_cooldown_timer) in
60-
enemy_query
64+
for (
65+
enemy_entity,
66+
enemy,
67+
enemy_transform,
68+
enemy_shoot_player_cooldown_timer,
69+
) in enemy_query
6170
{
6271
if enemy.state != EnemyState::AttackPlayer
6372
|| !enemy_shoot_player_cooldown_timer.0.just_finished()
@@ -87,7 +96,9 @@ pub fn enemy_shoot_player(
8796
LinearVelocity(world_bullet_velocity),
8897
RigidBody::Kinematic,
8998
DespawnTimer(Timer::from_seconds(3.0, TimerMode::Once)),
90-
EnemyBullet,
99+
EnemyBullet {
100+
origin_enemy: enemy_entity,
101+
},
91102
CollidingEntities::default(),
92103
));
93104
}

src/enemy/spawn/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
},
99
nav_mesh_pathfinding::{ArchipelagoRef, ENEMY_AGENT_RADIUS},
1010
};
11-
use avian3d::math::PI;
11+
use avian3d::{math::PI, prelude::LinearVelocity};
1212
use bevy::prelude::*;
1313
use bevy_landmass::{
1414
Agent, Agent3dBundle, AgentSettings, AgentTarget3d, ArchipelagoRef3d,
@@ -138,6 +138,7 @@ fn handle_spawn_enemies_at_enemy_spawn_locations_message(
138138
TimerMode::Repeating,
139139
)),
140140
Visibility::Visible,
141+
LinearVelocity::ZERO,
141142
))
142143
.with_child((
143144
Transform {

0 commit comments

Comments
 (0)