From e5f58a88aabe9c0a1a49f55d3c7e0b28ec72bdd9 Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Tue, 2 Jun 2026 20:26:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20-=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snake-game/src/startup.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/snake-game/src/startup.rs b/snake-game/src/startup.rs index 5177b1b..80ff026 100644 --- a/snake-game/src/startup.rs +++ b/snake-game/src/startup.rs @@ -96,22 +96,32 @@ fn spawn_snake(commands: &mut Commands) { commands .entity(tail) - // .observe( |event: On, mut query: Query<(&mut Direction, &Transform)>, snake_path: Res| { - trace!("first observer working"); if let Ok((mut direction, transform)) = query.get_mut(event.0) { if let Some(new_direction) = snake_path.pick(transform) { + trace!("change direction for {:?} to {:?}", event.0, new_direction); *direction = new_direction; } } }, ) - .observe(|event: On| { - trace!("second observer working"); - }); + .observe( + |event: On, + query: Query<(Entity, &Transform), With>, + mut snake_path: ResMut| { + if let Ok((entity, transform)) = query.get(event.0) { + if let Some(removed) = snake_path.pop(transform) { + trace!( + "removed direction {:?} from snake_path by End entity {:?}", + removed, entity + ); + } + } + }, + ); } /// Создать координатную сетку