diff --git a/Cargo.lock b/Cargo.lock index d03d325..90997c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,7 +43,7 @@ checksum = "f548ad2c4031f2902e3edc1f29c29e835829437de49562d8eb5dc5584d3a1043" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -115,15 +115,15 @@ dependencies = [ "cfg-if", "downcast-rs", "log", - "thiserror 2.0.17", + "thiserror 2.0.18", "variadics_please", ] [[package]] name = "bevy_auto_plugin" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00355e2dd268a7f9c7453773753edfedda475896c0b4e7b2d015aa04f4849fd" +checksum = "f3c7761957a70588bf0b7c6120c97a47620dab684a622a0aa0a8c5c9161becd6" dependencies = [ "bevy_auto_plugin_proc_macros", "bevy_auto_plugin_shared", @@ -133,9 +133,9 @@ dependencies = [ [[package]] name = "bevy_auto_plugin_proc_macros" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d85f2558b3a8f3d5e3e8df9debbff0665cad6c7c2bfde3537e7ff247fde3cd8f" +checksum = "582998ec7135267343cdcfc441128b73bbc995be640e48e046e2a33f3ff5703f" dependencies = [ "bevy_auto_plugin_shared", "proc-macro2", @@ -143,9 +143,9 @@ dependencies = [ [[package]] name = "bevy_auto_plugin_shared" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d825af42f08348a7c2307f50aabde362e774dd906c274556bd6b71794c8476" +checksum = "999eb3756d075ac95e169f71333ac211e54e961ac55708a89731eb6134f38b7e" dependencies = [ "bevy_app", "darling 0.21.3", @@ -156,8 +156,8 @@ dependencies = [ "proc-macro2", "quote", "smart-default", - "syn 2.0.111", - "thiserror 2.0.17", + "syn 2.0.114", + "thiserror 2.0.18", ] [[package]] @@ -168,7 +168,7 @@ checksum = "70b6a05c31f54c83d681f1b8699bbaf581f06b25a40c9a6bb815625f731f5ba9" dependencies = [ "bevy_macro_utils", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -209,7 +209,7 @@ dependencies = [ "nonmax", "slotmap", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "variadics_please", ] @@ -222,7 +222,7 @@ dependencies = [ "bevy_macro_utils", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -238,7 +238,7 @@ dependencies = [ "bevy_reflect", "derive_more", "log", - "thiserror 2.0.17", + "thiserror 2.0.18", ] [[package]] @@ -271,7 +271,7 @@ checksum = "0b7272fca0bf30d8ca2571a803598856104b63e5c596d52850f811ed37c5e1e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", "toml_edit", ] @@ -290,7 +290,7 @@ dependencies = [ "rand", "rand_distr", "serde", - "thiserror 2.0.17", + "thiserror 2.0.18", "variadics_please", ] @@ -335,7 +335,7 @@ dependencies = [ "indexmap", "serde", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "variadics_please", ] @@ -349,7 +349,7 @@ dependencies = [ "indexmap", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", "uuid", ] @@ -396,7 +396,7 @@ dependencies = [ "bevy_tasks", "derive_more", "serde", - "thiserror 2.0.17", + "thiserror 2.0.18", ] [[package]] @@ -423,9 +423,9 @@ checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" [[package]] name = "bytemuck" -version = "1.24.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" +checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" dependencies = [ "bytemuck_derive", ] @@ -438,7 +438,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -455,9 +455,9 @@ checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc" -version = "1.2.50" +version = "1.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f50d563227a1c37cc0a263f64eca3334388c01c5e4c4861a9def205c614383c" +checksum = "47b26a0954ae34af09b50f0de26458fa95369a0d478d8236d3f93082b219bd29" dependencies = [ "find-msvc-tools", "jobserver", @@ -564,7 +564,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -577,7 +577,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -588,7 +588,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core 0.21.3", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -599,29 +599,29 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core 0.23.0", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] name = "derive_more" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10b768e943bed7bf2cab53df09f4bc34bfd217cdb57d971e769874c9a6710618" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" dependencies = [ "derive_more-impl", ] [[package]] name = "derive_more-impl" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d286bfdaf75e988b4a78e013ecd79c581e06399ab53fbacd2d916c2f904f30b" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 2.0.111", + "syn 2.0.114", "unicode-xid", ] @@ -682,9 +682,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "fixedbitset" @@ -743,9 +743,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.30.9" +version = "0.30.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd47b05dddf0005d850e5644cae7f2b14ac3df487979dbfff3b56f20b1a6ae46" +checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9" dependencies = [ "bytemuck", "libm", @@ -809,14 +809,14 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] name = "indexmap" -version = "2.12.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", "hashbrown", @@ -874,9 +874,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.83" +version = "0.3.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" dependencies = [ "once_cell", "wasm-bindgen", @@ -884,15 +884,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.178" +version = "0.2.180" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" [[package]] name = "libm" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "linkme" @@ -911,7 +911,7 @@ checksum = "e5cec0ec4228b4853bb129c84dbf093a27e6c7a20526da046defc334a1b017f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -922,9 +922,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "ndk" @@ -990,7 +990,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -1016,7 +1016,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -1027,15 +1027,15 @@ checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "portable-atomic" -version = "1.12.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f59e70c4aef1e55797c2e8fd94a4f2a973fc972cfde0e0b05f683667b0cd39dd" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "portable-atomic-util" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +checksum = "7a9db96d7fa8782dd8c15ce32ffe8680bbd1e978a43bf51a34d39483540495f5" dependencies = [ "portable-atomic", ] @@ -1084,18 +1084,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.103" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.42" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" dependencies = [ "proc-macro2", ] @@ -1128,9 +1128,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" dependencies = [ "getrandom", ] @@ -1202,7 +1202,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -1234,7 +1234,7 @@ checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -1270,9 +1270,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.111" +version = "2.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" dependencies = [ "proc-macro2", "quote", @@ -1290,11 +1290,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl 2.0.17", + "thiserror-impl 2.0.18", ] [[package]] @@ -1305,18 +1305,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] name = "thiserror-impl" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -1375,9 +1375,9 @@ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "uuid" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" +checksum = "ee48d38b119b0cd71fe4141b30f5ba9c7c5d9f4e7a3a8b4a674e4b6ef789976f" dependencies = [ "js-sys", "wasm-bindgen", @@ -1391,7 +1391,7 @@ checksum = "41b6d82be61465f97d42bd1d15bf20f3b0a3a0905018f38f9d6f6962055b0b5c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] [[package]] @@ -1412,18 +1412,18 @@ dependencies = [ [[package]] name = "wasip2" -version = "1.0.1+wasi-0.2.4" +version = "1.0.2+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" dependencies = [ "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" dependencies = [ "cfg-if", "once_cell", @@ -1434,9 +1434,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1444,22 +1444,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.106" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" dependencies = [ "unicode-ident", ] @@ -1565,26 +1565,26 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.46.0" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" [[package]] name = "zerocopy" -version = "0.8.31" +version = "0.8.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" +checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.31" +version = "0.8.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" +checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" dependencies = [ "proc-macro2", "quote", - "syn 2.0.111", + "syn 2.0.114", ] diff --git a/immediate_stats/Cargo.toml b/immediate_stats/Cargo.toml index a8f1ad8..c2a3f50 100644 --- a/immediate_stats/Cargo.toml +++ b/immediate_stats/Cargo.toml @@ -30,7 +30,7 @@ bevy_auto_plugin = [ bevy_app = { version = "0.18", default-features = false, optional = true, features = [ "bevy_reflect", ] } -bevy_auto_plugin = { version = "0.9", optional = true } +bevy_auto_plugin = { version = "0.10", optional = true } bevy_ecs = { version = "0.18", default-features = false, optional = true, features = [ "bevy_reflect", ] } -- 2.51.2 From 2cd2b1876b72fabc68f3bfde5daa9229e31d2061 Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Fri, 6 Feb 2026 19:15:29 -0800 Subject: [PATCH 2/8] Add Auto Plugin hooks. --- immediate_stats/src/bevy.rs | 6 ++++++ immediate_stats/src/bevy/auto_plugin.rs | 28 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 immediate_stats/src/bevy/auto_plugin.rs diff --git a/immediate_stats/src/bevy.rs b/immediate_stats/src/bevy.rs index fb59ff8..fd5f93b 100644 --- a/immediate_stats/src/bevy.rs +++ b/immediate_stats/src/bevy.rs @@ -1,6 +1,9 @@ #![cfg(feature = "bevy")] //! Contains systems and components for resetting [`StatContainer`]s in the Bevy game engine. +#[cfg(feature = "bevy_auto_plugin")] +mod auto_plugin; + use crate::StatContainer; use crate::modifier::Modifier; use crate::stat::Stat; @@ -12,6 +15,9 @@ use bevy_reflect::Reflect; use bevy_reflect::prelude::ReflectDefault; use std::marker::PhantomData; +#[cfg(feature = "bevy_auto_plugin")] +pub use auto_plugin::*; + /// Configures [system ordering](StatSystems) and registers types with the Bevy type registry. /// /// - [`StatSystems::Reset`] runs in `PreUpdate`. diff --git a/immediate_stats/src/bevy/auto_plugin.rs b/immediate_stats/src/bevy/auto_plugin.rs new file mode 100644 index 0000000..6d205fa --- /dev/null +++ b/immediate_stats/src/bevy/auto_plugin.rs @@ -0,0 +1,28 @@ +#![cfg(feature = "bevy_auto_plugin")] +//! Contains a hook for resetting [`StatContainer`]s using Bevy Auto Plugin. + +use crate::{ResetComponentPlugin, ResetResourcePlugin, StatContainer}; +use bevy_app::App; +use bevy_auto_plugin::prelude::AutoPluginBuildHook; +use bevy_ecs::component::Mutable; +use bevy_ecs::prelude::{Component, Resource}; + +/// A Bevy Auto Plugin hook that adds the [`ResetComponentPlugin`] for the component. +pub struct ResetComponentHook; + +impl + StatContainer + 'static> AutoPluginBuildHook + for ResetComponentHook +{ + fn on_build(&self, app: &mut App) { + app.add_plugins(ResetComponentPlugin::::new()); + } +} + +/// A Bevy Auto Plugin hook that adds the [`ResetResourcePlugin`] for the resource. +pub struct ResetResourceHook; + +impl AutoPluginBuildHook for ResetResourceHook { + fn on_build(&self, app: &mut App) { + app.add_plugins(ResetResourcePlugin::::new()); + } +} -- 2.51.2 From 66665e5dc48435879e573458a8665c88d125eb6a Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Fri, 6 Feb 2026 19:16:29 -0800 Subject: [PATCH 3/8] Update Auto Plugin example. --- immediate_stats/examples/simple_bevy_auto_plugin.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/immediate_stats/examples/simple_bevy_auto_plugin.rs b/immediate_stats/examples/simple_bevy_auto_plugin.rs index 4e31466..3202380 100644 --- a/immediate_stats/examples/simple_bevy_auto_plugin.rs +++ b/immediate_stats/examples/simple_bevy_auto_plugin.rs @@ -3,7 +3,7 @@ use bevy::prelude::*; use bevy_auto_plugin; -use bevy_auto_plugin::prelude::{AutoPlugin, auto_component, auto_system}; +use bevy_auto_plugin::prelude::{AutoPlugin, auto_plugin_build_hook, auto_system}; use immediate_stats::*; fn main() { @@ -17,9 +17,9 @@ fn main() { struct SpeedPlugin; // Implements `reset_modifiers` by passing the call onto `Stat`. -// This will also add the `ResetComponentPlugin` to `SpeedPlugin`. #[derive(StatContainer, Component)] -#[auto_component(plugin = SpeedPlugin)] +// Use hook to add the `ResetComponentPlugin` to `SpeedPlugin` automatically. +#[auto_plugin_build_hook(plugin = SpeedPlugin, hook = ResetComponentHook)] struct Speed(Stat); #[auto_system(plugin = SpeedPlugin, schedule = Startup)] -- 2.51.2 From 587ef25aa93e4e29dab1a45b24a875cbf76d557a Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Fri, 6 Feb 2026 19:29:44 -0800 Subject: [PATCH 4/8] Remove old Auto Plugin macro systems. --- Cargo.lock | 43 +----- immediate_stats/Cargo.toml | 6 +- immediate_stats_macros/Cargo.toml | 2 - .../src/bevy_auto_plugin.rs | 130 ------------------ immediate_stats_macros/src/lib.rs | 10 -- 5 files changed, 5 insertions(+), 186 deletions(-) delete mode 100644 immediate_stats_macros/src/bevy_auto_plugin.rs diff --git a/Cargo.lock b/Cargo.lock index 90997c3..4d9a894 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -148,7 +148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "999eb3756d075ac95e169f71333ac211e54e961ac55708a89731eb6134f38b7e" dependencies = [ "bevy_app", - "darling 0.21.3", + "darling", "inventory", "linkme", "log", @@ -539,18 +539,8 @@ version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" dependencies = [ - "darling_core 0.21.3", - "darling_macro 0.21.3", -] - -[[package]] -name = "darling" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" -dependencies = [ - "darling_core 0.23.0", - "darling_macro 0.23.0", + "darling_core", + "darling_macro", ] [[package]] @@ -567,37 +557,13 @@ dependencies = [ "syn 2.0.114", ] -[[package]] -name = "darling_core" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" -dependencies = [ - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.114", -] - [[package]] name = "darling_macro" version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ - "darling_core 0.21.3", - "quote", - "syn 2.0.114", -] - -[[package]] -name = "darling_macro" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" -dependencies = [ - "darling_core 0.23.0", + "darling_core", "quote", "syn 2.0.114", ] @@ -805,7 +771,6 @@ dependencies = [ name = "immediate_stats_macros" version = "0.4.0" dependencies = [ - "darling 0.23.0", "proc-macro-error", "proc-macro2", "quote", diff --git a/immediate_stats/Cargo.toml b/immediate_stats/Cargo.toml index c2a3f50..cec3202 100644 --- a/immediate_stats/Cargo.toml +++ b/immediate_stats/Cargo.toml @@ -20,11 +20,7 @@ bevy = [ "dep:bevy_reflect", "immediate_stats_macros/bevy", ] -bevy_auto_plugin = [ - "bevy", - "dep:bevy_auto_plugin", - "immediate_stats_macros/bevy_auto_plugin", -] +bevy_auto_plugin = ["bevy", "dep:bevy_auto_plugin"] [dependencies] bevy_app = { version = "0.18", default-features = false, optional = true, features = [ diff --git a/immediate_stats_macros/Cargo.toml b/immediate_stats_macros/Cargo.toml index c8ca10f..6791078 100644 --- a/immediate_stats_macros/Cargo.toml +++ b/immediate_stats_macros/Cargo.toml @@ -18,10 +18,8 @@ proc-macro = true [features] bevy = [] -bevy_auto_plugin = ["bevy"] [dependencies] -darling = "0.23" proc-macro2 = "1.0" proc-macro-error = "1.0" quote = "1.0" diff --git a/immediate_stats_macros/src/bevy_auto_plugin.rs b/immediate_stats_macros/src/bevy_auto_plugin.rs deleted file mode 100644 index e52a267..0000000 --- a/immediate_stats_macros/src/bevy_auto_plugin.rs +++ /dev/null @@ -1,130 +0,0 @@ -use darling::ast::NestedMeta; -use darling::{Error, FromMeta}; -use proc_macro2::{Ident, TokenStream}; -use quote::{ToTokens, format_ident, quote}; -use syn::{DeriveInput, Expr, Meta, Path}; - -/// Returns code that will register stat resetting system(s) with Bevy Auto Plugin. -pub fn register_systems(input: &DeriveInput) -> darling::Result { - let struct_name = &input.ident; - - let mut auto_plugin_attributes = AutoPluginAttributes::new(struct_name); - - for attr in &input.attrs { - if attr.path().is_ident("auto_component") { - let plugin = PluginPath::from_meta(&attr.meta)?; - auto_plugin_attributes.component_plugin = Some(plugin); - } else if attr.path().is_ident("auto_resource") - || attr.path().is_ident("auto_init_resource") - || attr.path().is_ident("auto_insert_resource") - { - let plugin = PluginPath::from_meta(&attr.meta)?; - auto_plugin_attributes.resource_plugin = Some(plugin); - } - } - - Ok(auto_plugin_attributes.into_token_stream()) -} - -pub struct AutoPluginAttributes<'a> { - ident: &'a Ident, - component_plugin: Option, - resource_plugin: Option, -} - -impl<'a> AutoPluginAttributes<'a> { - pub fn new(ident: &'a Ident) -> Self { - Self { - ident, - component_plugin: None, - resource_plugin: None, - } - } -} - -impl<'a> ToTokens for AutoPluginAttributes<'a> { - fn to_tokens(&self, tokens: &mut TokenStream) { - if let Some(plugin_path) = &self.component_plugin { - let ident = &self.ident; - let plugin = &plugin_path.0; - let system_ident = format_ident!("__reset_{ident}_component_modifiers"); - - tokens.extend(quote! { - #[bevy_auto_plugin::prelude::auto_system( - plugin = #plugin, - schedule = immediate_stats::__PreUpdate, - config( - in_set = immediate_stats::StatSystems::Reset, - ) - )] - fn #system_ident( - mut query: Query<&mut #ident, Without>, - ) { - for mut stat in &mut query { - stat.reset_modifiers(); - } - } - }); - } - - if let Some(plugin_path) = &self.resource_plugin { - let ident = &self.ident; - let plugin = &plugin_path.0; - let system_ident = format_ident!("__reset_{ident}_resource_modifiers"); - - tokens.extend(quote! { - #[bevy_auto_plugin::prelude::auto_system( - plugin = #plugin, - schedule = immediate_stats::__PreUpdate, - config( - in_set = immediate_stats::StatSystems::Reset, - ) - )] - fn #system_ident(res: Option>) { - if let Some(mut res) = res { - res.reset_modifiers(); - } - } - }); - } - } -} - -/// Represents a `plugin(PATH)` or `plugin = PATH` attribute meta. -pub struct PluginPath(pub Path); - -impl FromMeta for PluginPath { - fn from_list(items: &[NestedMeta]) -> darling::Result { - for item in items { - return match item { - NestedMeta::Meta(meta) => match meta { - Meta::Path(_) => Err(Error::custom("Expected a value for `plugin`")), - Meta::List(list) => { - if list.path.require_ident()? != "plugin" { - continue; - } - - let mut path = None; - - list.parse_nested_meta(|value_meta| { - path = Some(value_meta.path); - Ok(()) - })?; - - match path { - None => Err(Error::custom("Expected `plugin` attribute")), - Some(path) => Ok(PluginPath(path)), - } - } - Meta::NameValue(name_value) => match &name_value.value { - Expr::Path(p) => Ok(PluginPath(p.path.clone())), - _ => Err(Error::custom("Expected a path to an auto plugin")), - }, - }, - NestedMeta::Lit(_) => Err(Error::custom("Expected `plugin` attribute")), - }; - } - - Err(Error::custom("Expected `plugin` attribute")) - } -} diff --git a/immediate_stats_macros/src/lib.rs b/immediate_stats_macros/src/lib.rs index c34de75..8fae6f5 100644 --- a/immediate_stats_macros/src/lib.rs +++ b/immediate_stats_macros/src/lib.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "bevy_auto_plugin")] -mod bevy_auto_plugin; mod derive_enum; mod derive_struct; @@ -31,14 +29,6 @@ pub fn stat_container_derive(item: proc_macro::TokenStream) -> proc_macro::Token } }; - #[cfg(feature = "bevy_auto_plugin")] - { - let systems = - bevy_auto_plugin::register_systems(&tree).unwrap_or_else(darling::Error::write_errors); - quote! { #trait_impl #systems }.into() - } - - #[cfg(not(feature = "bevy_auto_plugin"))] trait_impl.into() } -- 2.51.2 From 310b8da778146a50439299e758e3faf6a6e7b5b1 Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Fri, 6 Feb 2026 19:23:38 -0800 Subject: [PATCH 5/8] Update Auto Plugin tests. --- immediate_stats/tests/bevy_auto_plugin.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/immediate_stats/tests/bevy_auto_plugin.rs b/immediate_stats/tests/bevy_auto_plugin.rs index 710258a..8cd26cf 100644 --- a/immediate_stats/tests/bevy_auto_plugin.rs +++ b/immediate_stats/tests/bevy_auto_plugin.rs @@ -4,7 +4,9 @@ extern crate immediate_stats; use crate::{Stat, StatContainer}; use bevy_app::App; -use bevy_auto_plugin::prelude::{AutoPlugin, auto_component, auto_init_resource}; +use bevy_auto_plugin::prelude::{ + AutoPlugin, auto_bind_plugin, auto_component, auto_plugin_build_hook, auto_resource, +}; use bevy_ecs::prelude::*; use immediate_stats::*; @@ -13,8 +15,11 @@ use immediate_stats::*; struct MyPlugin; #[derive(Resource, Component, StatContainer, Default, PartialEq, Debug)] -#[auto_component(plugin = MyPlugin)] -#[auto_init_resource(plugin = MyPlugin)] +#[auto_bind_plugin(plugin = MyPlugin)] +#[auto_plugin_build_hook(hook = ResetComponentHook)] +#[auto_plugin_build_hook(hook = ResetResourceHook)] +#[auto_component()] +#[auto_resource(init)] struct Health(Stat); #[test] -- 2.51.2 From 473e07f8f8fbe85f2a76d6af764f472d6f2dad81 Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Fri, 6 Feb 2026 19:39:47 -0800 Subject: [PATCH 6/8] Update docs to match new Auto Plugin --- README.md | 14 +++------ immediate_stats/src/lib.rs | 38 +++++------------------ immediate_stats/tests/bevy_auto_plugin.rs | 2 +- 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 0824898..c0b6862 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ fn main() { ### Bevy Auto Plugin If you use [Bevy Auto Plugin](https://github.com/strikeforcezero/bevy_auto_plugin/), you can also use the `bevy_auto_plugin` feature flag. -This automatically registers the required system(s) by leveraging the existing `auto_component` and `auto_resource` macros. +This adds build hooks that automatically add the reset plugin. ```rust fn main() { @@ -62,19 +62,15 @@ fn main() { #[auto_plugin(impl_plugin_trait)] struct MyPlugin; -// `StatContainer` derive hooks into the existing `auto_component` and `auto_resource` macros. -#[derive(StatContainer, Component, Resource)] -#[auto_component(plugin = MyPlugin)] // Adds `reset_component_modifiers` system. -#[auto_init_resource(plugin = MyPlugin)] // Adds `reset_resource_modifiers` system. +#[derive(StatContainer, Component)] +// Use hook to add the `ResetComponentPlugin` to `MyPlugin` automatically. +#[auto_plugin_build_hook(plugin = MyPlugin, hook = ResetComponentHook)] struct Speed(Stat); ``` -It is important to note that this only works when the `derive` is above the `auto_*` macro, -and does *not* work with `auto_bind_plugin`. - ### Version Compatibility | Bevy | Immediate Stats | |--------|-----------------| | `0.18` | `0.4` | | `0.17` | `0.3` | -| `0.16` | `0.1` - `0.2` | \ No newline at end of file +| `0.16` | `0.1` - `0.2` | diff --git a/immediate_stats/src/lib.rs b/immediate_stats/src/lib.rs index 5f7a211..6545118 100644 --- a/immediate_stats/src/lib.rs +++ b/immediate_stats/src/lib.rs @@ -50,16 +50,16 @@ //! //! ### Bevy Auto Plugin //! -//! If you use [Bevy Auto Plugin](https://github.com/strikeforcezero/bevy_auto_plugin/), -//! you can also use the `bevy_auto_plugin` feature flag. This automatically registers the required -//! system(s) by leveraging the existing `auto_component` and `auto_resource` macros. +//! If you use [Bevy Auto Plugin](https://github.com/strikeforcezero/bevy_auto_plugin/), you can also use the `bevy_auto_plugin` feature flag. +//! This adds build hooks that automatically add the reset plugin. //! #![cfg_attr(not(feature = "bevy_auto_plugin"), doc = "```rust ignore")] #![cfg_attr(feature = "bevy_auto_plugin", doc = "```rust")] //! # use bevy_app::prelude::*; //! # use bevy_ecs::prelude::*; //! # use immediate_stats::*; -//! # use bevy_auto_plugin::prelude::{AutoPlugin, auto_component, auto_resource}; +//! # use bevy_auto_plugin::prelude::{AutoPlugin, auto_plugin_build_hook, auto_resource}; +//! //! fn main() { //! App::new().add_plugins((ImmediateStatsPlugin, MyPlugin)).run(); //! } @@ -68,16 +68,12 @@ //! #[auto_plugin(impl_plugin_trait)] //! struct MyPlugin; //! -//! // `StatContainer` derive hooks into the existing `auto_component` and `auto_resource` macros. -//! #[derive(StatContainer, Component, Resource)] -//! #[auto_component(plugin = MyPlugin)] // Adds `reset_component_modifiers` system. -//! #[auto_resource(plugin = MyPlugin)] // Adds `reset_resource_modifiers` system. +//! #[derive(StatContainer, Component)] +//! // Use hook to add the `ResetComponentPlugin` to `MyPlugin` automatically. +//! #[auto_plugin_build_hook(plugin = MyPlugin, hook = ResetComponentHook)] //! struct Speed(Stat); //! ``` //! -//! It is important to note that this only works when the `derive` is above the `auto_*` macro, -//! and does *not* work with `auto_bind_plugin`. -//! //! ### Version Compatibility //! | Bevy | Immediate Stats | //! |--------|-----------------| @@ -144,26 +140,6 @@ mod stat; /// assert_eq!(partial.ignored, Stat::default().with_bonus(10)); /// } /// ``` -/// # Bevy Auto Plugin -/// If the `bevy_auto_plugin` feature flag is enabled, the existing `auto_component` and -/// `auto_resource` macros will register [`reset_component_modifiers`] and/or -/// [`reset_resource_modifiers`] automatically. -#[cfg_attr(not(feature = "bevy_auto_plugin"), doc = "```rust ignore")] -#[cfg_attr(feature = "bevy_auto_plugin", doc = "```rust")] -/// # use bevy_app::prelude::*; -/// # use bevy_ecs::prelude::*; -/// # use immediate_stats::*; -/// # use bevy_auto_plugin::prelude::{AutoPlugin, auto_component, auto_resource}; -/// #[derive(AutoPlugin)] -/// #[auto_plugin(impl_plugin_trait)] -/// struct MyPlugin; -/// -/// // `StatContainer` derive hooks into the existing `auto_component` and `auto_resource` macros. -/// #[derive(StatContainer, Component, Resource)] -/// #[auto_component(plugin = MyPlugin)] // Adds `reset_component_modifiers` system. -/// #[auto_resource(plugin = MyPlugin)] // Adds `reset_resource_modifiers` system. -/// struct Speed(Stat); -/// ``` pub use immediate_stats_macros::StatContainer; pub use modifier::*; pub use stat::*; diff --git a/immediate_stats/tests/bevy_auto_plugin.rs b/immediate_stats/tests/bevy_auto_plugin.rs index 8cd26cf..4f01dcc 100644 --- a/immediate_stats/tests/bevy_auto_plugin.rs +++ b/immediate_stats/tests/bevy_auto_plugin.rs @@ -1,4 +1,4 @@ -//! Tests the `add_component` attribute for automatic system registration. +//! Tests the `ResetComponentHook` and `ResetResourceHook`. #![cfg(feature = "bevy_auto_plugin")] extern crate immediate_stats; -- 2.51.2 From c6a1825cbe9bb1fa713751007c7cb7f19baf34b8 Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Fri, 6 Feb 2026 19:46:51 -0800 Subject: [PATCH 7/8] Fix outdated Bevy compatability table --- immediate_stats/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/immediate_stats/src/lib.rs b/immediate_stats/src/lib.rs index 6545118..f63d87d 100644 --- a/immediate_stats/src/lib.rs +++ b/immediate_stats/src/lib.rs @@ -77,6 +77,7 @@ //! ### Version Compatibility //! | Bevy | Immediate Stats | //! |--------|-----------------| +//! | `0.18` | `0.4` | //! | `0.17` | `0.3` | //! | `0.16` | `0.1` - `0.2` | -- 2.51.2 From cb9843d0c1e1be5a8b24edcacdd497940936ae5c Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Fri, 6 Feb 2026 19:49:22 -0800 Subject: [PATCH 8/8] Update version number --- Cargo.lock | 4 ++-- immediate_stats/Cargo.toml | 4 ++-- immediate_stats_macros/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d9a894..a6722f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -757,7 +757,7 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "immediate_stats" -version = "0.4.0" +version = "0.5.0" dependencies = [ "bevy", "bevy_app", @@ -769,7 +769,7 @@ dependencies = [ [[package]] name = "immediate_stats_macros" -version = "0.4.0" +version = "0.5.0" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/immediate_stats/Cargo.toml b/immediate_stats/Cargo.toml index cec3202..a30e155 100644 --- a/immediate_stats/Cargo.toml +++ b/immediate_stats/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "immediate_stats" -version = "0.4.0" +version = "0.5.0" edition = "2024" description = "Game stats that reset every frame, inspired by immediate mode GUI." categories = ["game-development", "data-structures"] @@ -31,7 +31,7 @@ bevy_ecs = { version = "0.18", default-features = false, optional = true, featur "bevy_reflect", ] } bevy_reflect = { version = "0.18", default-features = false, optional = true } -immediate_stats_macros = { path = "../immediate_stats_macros", version = "0.4.0", default-features = false } +immediate_stats_macros = { path = "../immediate_stats_macros", version = "0.5.0", default-features = false } [dev-dependencies] bevy = { version = "0.18", default-features = false } diff --git a/immediate_stats_macros/Cargo.toml b/immediate_stats_macros/Cargo.toml index 6791078..5f7bc2e 100644 --- a/immediate_stats_macros/Cargo.toml +++ b/immediate_stats_macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "immediate_stats_macros" -version = "0.4.0" +version = "0.5.0" edition = "2024" description = "Game stats that reset every frame, inspired by immediate mode GUI." categories = ["game-development", "data-structures"]