mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-08 12:07:52 -06:00
fix: avoid switching ghost back to normal during eyes animation
This commit is contained in:
@@ -98,6 +98,7 @@ pub fn ghost_state_animation_system(
|
|||||||
mut eaten_added: Query<(bevy_ecs::entity::Entity, &Ghost), Added<Eaten>>,
|
mut eaten_added: Query<(bevy_ecs::entity::Entity, &Ghost), Added<Eaten>>,
|
||||||
mut vulnerable_removed: RemovedComponents<Vulnerable>,
|
mut vulnerable_removed: RemovedComponents<Vulnerable>,
|
||||||
ghosts: Query<&Ghost>,
|
ghosts: Query<&Ghost>,
|
||||||
|
eaten_ghosts: Query<&Ghost, With<Eaten>>,
|
||||||
) {
|
) {
|
||||||
// When a ghost becomes vulnerable, switch to the frightened animation
|
// When a ghost becomes vulnerable, switch to the frightened animation
|
||||||
for (entity, ghost_type) in vulnerable_added.iter_mut() {
|
for (entity, ghost_type) in vulnerable_added.iter_mut() {
|
||||||
@@ -118,8 +119,12 @@ pub fn ghost_state_animation_system(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// When a ghost is no longer vulnerable, switch back to the normal animation
|
// When a ghost is no longer vulnerable, switch back to the normal animation
|
||||||
|
// But don't switch if the ghost is currently eaten (should keep eyes animation)
|
||||||
for entity in vulnerable_removed.read() {
|
for entity in vulnerable_removed.read() {
|
||||||
if let Ok(ghost_type) = ghosts.get(entity) {
|
if let Ok(ghost_type) = ghosts.get(entity) {
|
||||||
|
// Check if this ghost is currently eaten - if so, don't switch to normal animation
|
||||||
|
let is_eaten = eaten_ghosts.get(entity).is_ok();
|
||||||
|
if !is_eaten {
|
||||||
if let Some(animation_set) = animations.0.get(ghost_type) {
|
if let Some(animation_set) = animations.0.get(ghost_type) {
|
||||||
if let Some(animation) = animation_set.normal() {
|
if let Some(animation) = animation_set.normal() {
|
||||||
commands.entity(entity).insert(animation.clone());
|
commands.entity(entity).insert(animation.clone());
|
||||||
@@ -127,6 +132,7 @@ pub fn ghost_state_animation_system(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// System that handles eaten ghost behavior and respawn logic.
|
/// System that handles eaten ghost behavior and respawn logic.
|
||||||
|
|||||||
Reference in New Issue
Block a user