From 4b43f43c750f8a7f48ab009b28004dcdf1e24134 Mon Sep 17 00:00:00 2001 From: Mikhail Mitrofanov Date: Thu, 18 Jun 2026 12:38:59 +0300 Subject: [PATCH] Migration works --- .gitignore | 1 + Cargo.lock | 130 ++++++++++++++++++++-------------------- src/main.rs | 24 +++++++- src/plate_automation.rs | 21 ++++--- src/seed_automation.rs | 20 ++++++- 5 files changed, 116 insertions(+), 80 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf..40d9aca 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/.idea \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index aad77c6..eba0b13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,7 +110,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" dependencies = [ "alsa-sys", - "bitflags 2.9.1", + "bitflags 2.13.0", "cfg-if", "libc", ] @@ -132,7 +132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" dependencies = [ "android-properties", - "bitflags 2.9.1", + "bitflags 2.13.0", "cc", "jni 0.22.4", "libc", @@ -478,7 +478,7 @@ dependencies = [ "bevy_reflect", "bevy_tasks", "bevy_utils", - "bitflags 2.9.1", + "bitflags 2.13.0", "blake3", "crossbeam-channel", "derive_more", @@ -594,7 +594,7 @@ dependencies = [ "bevy_transform", "bevy_utils", "bevy_window", - "bitflags 2.9.1", + "bitflags 2.13.0", "nonmax", "radsort", "smallvec", @@ -673,7 +673,7 @@ dependencies = [ "bevy_reflect", "bevy_tasks", "bevy_utils", - "bitflags 2.9.1", + "bitflags 2.13.0", "bumpalo", "concurrent-queue", "derive_more", @@ -862,7 +862,7 @@ dependencies = [ "bevy_platform", "bevy_reflect", "bevy_utils", - "bitflags 2.9.1", + "bitflags 2.13.0", "bytemuck", "futures-lite", "guillotiere", @@ -1053,7 +1053,7 @@ dependencies = [ "bevy_platform", "bevy_reflect", "bevy_transform", - "bitflags 2.9.1", + "bitflags 2.13.0", "bytemuck", "derive_more", "hexasphere", @@ -1093,7 +1093,7 @@ dependencies = [ "bevy_shader", "bevy_transform", "bevy_utils", - "bitflags 2.9.1", + "bitflags 2.13.0", "bytemuck", "derive_more", "fixedbitset", @@ -1171,7 +1171,7 @@ dependencies = [ "bevy_transform", "bevy_utils", "bevy_window", - "bitflags 2.9.1", + "bitflags 2.13.0", "nonmax", "radsort", "smallvec", @@ -1255,7 +1255,7 @@ dependencies = [ "bevy_transform", "bevy_utils", "bevy_window", - "bitflags 2.9.1", + "bitflags 2.13.0", "bytemuck", "derive_more", "downcast-rs 2.0.2", @@ -1378,7 +1378,7 @@ dependencies = [ "bevy_text", "bevy_transform", "bevy_utils", - "bitflags 2.9.1", + "bitflags 2.13.0", "bytemuck", "derive_more", "fixedbitset", @@ -1646,7 +1646,7 @@ version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "cexpr", "clang-sys", "itertools 0.13.0", @@ -1681,12 +1681,12 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" dependencies = [ "bytemuck", - "serde", + "serde_core", ] [[package]] @@ -1790,7 +1790,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "log", "polling", "rustix 0.38.44", @@ -2013,7 +2013,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "core-foundation 0.10.1", "libc", ] @@ -2053,7 +2053,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cadaea21e24c49c0c82116f2b465ae6a49d63c90e428b0f8d9ae1f638ac91f" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "fontdb", "harfrust", "linebender_resource_handle", @@ -2212,7 +2212,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.6.2", "libc", "objc2 0.6.4", @@ -2704,7 +2704,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "gpu-alloc-types", ] @@ -2714,7 +2714,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", ] [[package]] @@ -2735,7 +2735,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "gpu-descriptor-types", "hashbrown 0.15.5", ] @@ -2746,7 +2746,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", ] [[package]] @@ -2783,7 +2783,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0caaee032384c10dd597af4579c67dee16650d862a9ccbe1233ff1a379abc07" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "bytemuck", "core_maths", "read-fonts 0.36.0", @@ -2909,7 +2909,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "533e68a5842e734946fe159fb03fc9bbbb254f590dd0d8ad321ae5ff7beca2c1" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "inotify-sys", "libc", ] @@ -3074,7 +3074,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff7f53bdf698e7aa7ec916411bbdc8078135da11b66db5182675b2227f6c0d07" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", ] [[package]] @@ -3128,7 +3128,7 @@ version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "libc", "plain", "redox_syscall 0.8.1", @@ -3231,7 +3231,7 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00c15a6f673ff72ddcc22394663290f870fb224c1bfce55734a75c414150e605" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block", "core-graphics-types 0.2.0", "foreign-types", @@ -3274,7 +3274,7 @@ checksum = "066cf25f0e8b11ee0df221219010f213ad429855f57c494f995590c861a9a7d8" dependencies = [ "arrayvec", "bit-set", - "bitflags 2.9.1", + "bitflags 2.13.0", "cfg-if", "cfg_aliases", "codespan-reporting", @@ -3316,7 +3316,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "jni-sys 0.3.1", "log", "ndk-sys 0.5.0+25.2.9519653", @@ -3330,7 +3330,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "jni-sys 0.3.1", "log", "ndk-sys 0.6.0+11769913", @@ -3369,7 +3369,7 @@ version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "cfg-if", "cfg_aliases", "libc", @@ -3492,7 +3492,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "libc", "objc2 0.5.2", @@ -3508,7 +3508,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "objc2 0.5.2", "objc2-core-location", @@ -3532,7 +3532,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation", @@ -3544,7 +3544,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", ] [[package]] @@ -3583,7 +3583,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "dispatch", "libc", @@ -3596,7 +3596,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "libc", "objc2-core-foundation", ] @@ -3619,7 +3619,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation", @@ -3631,7 +3631,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "objc2 0.5.2", "objc2-foundation", @@ -3654,7 +3654,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "objc2 0.5.2", "objc2-cloud-kit", @@ -3686,7 +3686,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "objc2 0.5.2", "objc2-core-location", @@ -3878,7 +3878,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "crc32fast", "fdeflate", "flate2", @@ -3989,9 +3989,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.40" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -4140,7 +4140,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", ] [[package]] @@ -4149,7 +4149,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b44b894f2a6e36457d665d1e08c3866add6ed5e70050c1b4ba8a8ddedb02ce7" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", ] [[package]] @@ -4203,7 +4203,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4147b952f3f819eca0e99527022f7d6a8d05f111aeb0a62960c74eb283bec8fc" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "once_cell", "serde", "serde_derive", @@ -4244,7 +4244,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "errno", "libc", "linux-raw-sys 0.4.15", @@ -4257,7 +4257,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "errno", "libc", "linux-raw-sys 0.12.1", @@ -4464,7 +4464,7 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "calloop", "calloop-wayland-source", "cursor-icon", @@ -4507,7 +4507,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", ] [[package]] @@ -5063,7 +5063,7 @@ version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "hashbrown 0.15.5", "indexmap", "semver", @@ -5089,7 +5089,7 @@ version = "0.31.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "645c7c96bb74690c3189b5c9cb4ca1627062bb23693a4fad9d8c3de958260144" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "rustix 1.1.4", "wayland-backend", "wayland-scanner", @@ -5101,7 +5101,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "cursor-icon", "wayland-backend", ] @@ -5123,7 +5123,7 @@ version = "0.32.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "563a85523cade2429938e790815fd7319062103b9f4a2dc806e9b53b95982d8f" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "wayland-backend", "wayland-client", "wayland-scanner", @@ -5135,7 +5135,7 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "wayland-backend", "wayland-client", "wayland-protocols", @@ -5148,7 +5148,7 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "wayland-backend", "wayland-client", "wayland-protocols", @@ -5204,7 +5204,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfe68bac7cde125de7a731c3400723cadaaf1703795ad3f4805f187459cd7a77" dependencies = [ "arrayvec", - "bitflags 2.9.1", + "bitflags 2.13.0", "cfg-if", "cfg_aliases", "document-features", @@ -5233,7 +5233,7 @@ dependencies = [ "arrayvec", "bit-set", "bit-vec", - "bitflags 2.9.1", + "bitflags 2.13.0", "bytemuck", "cfg_aliases", "document-features", @@ -5293,7 +5293,7 @@ dependencies = [ "arrayvec", "ash", "bit-set", - "bitflags 2.9.1", + "bitflags 2.13.0", "block", "bytemuck", "cfg-if", @@ -5338,7 +5338,7 @@ version = "27.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afdcf84c395990db737f2dd91628706cb31e86d72e53482320d368e52b5da5eb" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "bytemuck", "js-sys", "log", @@ -5836,7 +5836,7 @@ dependencies = [ "ahash", "android-activity", "atomic-waker", - "bitflags 2.9.1", + "bitflags 2.13.0", "block2 0.5.1", "bytemuck", "calloop", @@ -5961,7 +5961,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", - "bitflags 2.9.1", + "bitflags 2.13.0", "indexmap", "log", "serde", @@ -6035,7 +6035,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.9.1", + "bitflags 2.13.0", "dlib", "log", "once_cell", diff --git a/src/main.rs b/src/main.rs index a383366..9648f69 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ fn main() { .add_plugins(DefaultPlugins) .add_systems(Startup, setup) .insert_resource(Time::::from_hz(1024.0)) - .add_systems(Update, keyboard_input_system) + // .add_systems(Update, automation_keyboard_input_system) .add_systems(Update, seed_automation::update_automation_seed) .add_systems(Update, seed_automation::update_automation_view_seed) .add_systems(Update, plate_automation::update_automation_plate) @@ -44,5 +44,27 @@ fn setup(mut commands: Commands, mut images: ResMut>) { commands.insert_resource(SeededRng(seeded_rng)); } +// fn automation_keyboard_input_system(keys: Res>, mut commands: Commands) { +// if keys.just_pressed(KeyCode::Space) { +// commands.spawn((AutomationNext,)); +// } +// +// if keys.just_pressed(KeyCode::Tab) { +// commands.spawn((AutomationMigrate,)); +// } +// +// if keys.just_pressed(KeyCode::AltLeft) { +// commands.spawn((AutomationScale,)); +// } +// } +// +// #[derive(Component)] +// struct AutomationNext; +// +// #[derive(Component)] +// struct AutomationScale; +// +// #[derive(Component)] +// struct AutomationMigrate; #[derive(Resource)] struct SeededRng(ChaCha8Rng); diff --git a/src/plate_automation.rs b/src/plate_automation.rs index 96763a9..be3724f 100644 --- a/src/plate_automation.rs +++ b/src/plate_automation.rs @@ -3,7 +3,7 @@ use crate::basic::{IntoImage, Table}; use bevy::asset::{Assets, RenderAssetUsages}; use bevy::image::{BevyDefault, Image}; use bevy::input::ButtonInput; -use bevy::prelude::{Component, KeyCode, Query, ResMut, Sprite}; +use bevy::prelude::{Component, KeyCode, Query, Res, ResMut, Sprite}; use bevy::render::render_resource::{Extent3d, TextureDimension, TextureFormat}; use rand::RngExt; use rand_chacha::ChaCha8Rng; @@ -12,6 +12,9 @@ pub fn update_automation_view_plate( query: Query<(&Sprite, &PlateAutomation)>, mut images: ResMut>, ) { + if query.is_empty() { + return; + } let (sprite, automation) = query.iter().next().unwrap(); let size = automation.world.side as u32; let data = automation.world.get_image_data(); @@ -34,8 +37,12 @@ pub fn update_automation_view_plate( pub fn update_automation_plate( mut query: Query<&mut PlateAutomation>, mut seeded_rng: ResMut, - keys: ResMut>, + keys: Res>, ) { + if query.is_empty() { + return; + } + let mut automation = query.iter_mut().next().unwrap(); if keys.just_pressed(KeyCode::Space) { let random = &mut seeded_rng.0; @@ -55,14 +62,6 @@ pub struct PlateAutomation { impl PlateAutomation { fn next(&mut self, rng: &mut ChaCha8Rng) { - let len = (self.world.side * self.world.side) as f32; - loop { - let index = (rng.random::() * len) as usize; - if *self.world.get(index) { - continue; - } - self.world.set(index, true); - break; - } + println!("Next for plate automation"); } } diff --git a/src/seed_automation.rs b/src/seed_automation.rs index 5256a15..d13577d 100644 --- a/src/seed_automation.rs +++ b/src/seed_automation.rs @@ -3,15 +3,20 @@ use crate::basic::{IntoImage, Table}; use bevy::asset::{Assets, RenderAssetUsages}; use bevy::image::{BevyDefault, Image}; use bevy::input::ButtonInput; -use bevy::prelude::{Commands, Component, Entity, KeyCode, Query, ResMut, Sprite}; +use bevy::prelude::{Commands, Component, Entity, KeyCode, Query, Res, ResMut, Sprite}; use bevy::render::render_resource::{Extent3d, TextureDimension, TextureFormat}; use rand::RngExt; use rand_chacha::ChaCha8Rng; +use crate::plate_automation::PlateAutomation; pub fn update_automation_view_seed( query: Query<(&Sprite, &SeedAutomation)>, mut images: ResMut>, ) { + if query.is_empty() { + return; + } + let (sprite, automation) = query.iter().next().unwrap(); let size = automation.world.side as u32; let data = automation.world.get_image_data(); @@ -34,15 +39,24 @@ pub fn update_automation_view_seed( pub fn update_automation_seed( mut query: Query<(&mut SeedAutomation, Entity)>, mut seeded_rng: ResMut, - keys: ResMut>, + keys: Res>, mut commands: Commands) { + + if query.is_empty() { + return; + } + let (mut automation, entity) = query.iter_mut().next().unwrap(); + if keys.just_pressed(KeyCode::Space){ let random = &mut seeded_rng.0; automation.next(random) } if keys.just_pressed(KeyCode::Tab){ - commands.entity(entity).; + println!("Switching to PlateAutomation"); + commands.entity(entity).remove::().insert(PlateAutomation{ + world: automation.world.clone() + }); } }