Game stats that reset every frame, inspired by immediate mode GUI.
gamedev bevy stats
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Started on Derive Macro.

AlephCubed 45faad03

+1055
+1
.gitignore
··· 1 + /target
+8
.idea/.gitignore
··· 1 + # Default ignored files 2 + /shelf/ 3 + /workspace.xml 4 + # Editor-based HTTP Client requests 5 + /httpRequests/ 6 + # Datasource local storage ignored files 7 + /dataSources/ 8 + /dataSources.local.xml
+836
Cargo.lock
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "ahash" 7 + version = "0.8.11" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" 10 + dependencies = [ 11 + "cfg-if", 12 + "const-random", 13 + "getrandom", 14 + "once_cell", 15 + "version_check", 16 + "zerocopy", 17 + ] 18 + 19 + [[package]] 20 + name = "allocator-api2" 21 + version = "0.2.21" 22 + source = "registry+https://github.com/rust-lang/crates.io-index" 23 + checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" 24 + 25 + [[package]] 26 + name = "async-executor" 27 + version = "1.13.1" 28 + source = "registry+https://github.com/rust-lang/crates.io-index" 29 + checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" 30 + dependencies = [ 31 + "async-task", 32 + "concurrent-queue", 33 + "fastrand", 34 + "futures-lite", 35 + "slab", 36 + ] 37 + 38 + [[package]] 39 + name = "async-task" 40 + version = "4.7.1" 41 + source = "registry+https://github.com/rust-lang/crates.io-index" 42 + checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" 43 + 44 + [[package]] 45 + name = "autocfg" 46 + version = "1.4.0" 47 + source = "registry+https://github.com/rust-lang/crates.io-index" 48 + checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 49 + 50 + [[package]] 51 + name = "bevy_app" 52 + version = "0.15.3" 53 + source = "registry+https://github.com/rust-lang/crates.io-index" 54 + checksum = "a0ac033a388b8699d241499a43783a09e6a3bab2430f1297c6bd4974095efb3f" 55 + dependencies = [ 56 + "bevy_derive", 57 + "bevy_ecs", 58 + "bevy_tasks", 59 + "bevy_utils", 60 + "console_error_panic_hook", 61 + "ctrlc", 62 + "derive_more", 63 + "downcast-rs", 64 + "wasm-bindgen", 65 + "web-sys", 66 + ] 67 + 68 + [[package]] 69 + name = "bevy_derive" 70 + version = "0.15.3" 71 + source = "registry+https://github.com/rust-lang/crates.io-index" 72 + checksum = "57d94761ce947b0a2402fd949fe1e7a5b1535293130ba4cd9893be6295d4680a" 73 + dependencies = [ 74 + "bevy_macro_utils", 75 + "quote", 76 + "syn", 77 + ] 78 + 79 + [[package]] 80 + name = "bevy_ecs" 81 + version = "0.15.3" 82 + source = "registry+https://github.com/rust-lang/crates.io-index" 83 + checksum = "1597106cc01e62e6217ccb662e0748b2ce330893f27c7dc17bac33e0bb99bca9" 84 + dependencies = [ 85 + "bevy_ecs_macros", 86 + "bevy_ptr", 87 + "bevy_tasks", 88 + "bevy_utils", 89 + "bitflags", 90 + "concurrent-queue", 91 + "derive_more", 92 + "disqualified", 93 + "fixedbitset 0.5.7", 94 + "nonmax", 95 + "petgraph", 96 + "smallvec", 97 + ] 98 + 99 + [[package]] 100 + name = "bevy_ecs_macros" 101 + version = "0.15.3" 102 + source = "registry+https://github.com/rust-lang/crates.io-index" 103 + checksum = "f453adf07712b39826bc5845e5b0887ce03204ee8359bbe6b40a9afda60564a1" 104 + dependencies = [ 105 + "bevy_macro_utils", 106 + "proc-macro2", 107 + "quote", 108 + "syn", 109 + ] 110 + 111 + [[package]] 112 + name = "bevy_macro_utils" 113 + version = "0.15.3" 114 + source = "registry+https://github.com/rust-lang/crates.io-index" 115 + checksum = "8bb6ded1ddc124ea214f6a2140e47a78d1fe79b0638dad39419cdeef2e1133f1" 116 + dependencies = [ 117 + "proc-macro2", 118 + "quote", 119 + "syn", 120 + "toml_edit", 121 + ] 122 + 123 + [[package]] 124 + name = "bevy_ptr" 125 + version = "0.15.3" 126 + source = "registry+https://github.com/rust-lang/crates.io-index" 127 + checksum = "89fe0b0b919146939481a3a7c38864face2c6d0fd2c73ab3d430dc693ecd9b11" 128 + 129 + [[package]] 130 + name = "bevy_tasks" 131 + version = "0.15.3" 132 + source = "registry+https://github.com/rust-lang/crates.io-index" 133 + checksum = "028630ddc355563bd567df1076db3515858aa26715ddf7467d2086f9b40e5ab1" 134 + dependencies = [ 135 + "async-executor", 136 + "futures-channel", 137 + "futures-lite", 138 + "pin-project", 139 + "wasm-bindgen-futures", 140 + ] 141 + 142 + [[package]] 143 + name = "bevy_utils" 144 + version = "0.15.3" 145 + source = "registry+https://github.com/rust-lang/crates.io-index" 146 + checksum = "63c2174d43a0de99f863c98a472370047a2bfa7d1e5cec8d9d647fb500905d9d" 147 + dependencies = [ 148 + "ahash", 149 + "bevy_utils_proc_macros", 150 + "getrandom", 151 + "hashbrown 0.14.5", 152 + "thread_local", 153 + "tracing", 154 + "web-time", 155 + ] 156 + 157 + [[package]] 158 + name = "bevy_utils_proc_macros" 159 + version = "0.15.3" 160 + source = "registry+https://github.com/rust-lang/crates.io-index" 161 + checksum = "94847541f6dd2e28f54a9c2b0e857da5f2631e2201ebc25ce68781cdcb721391" 162 + dependencies = [ 163 + "proc-macro2", 164 + "quote", 165 + "syn", 166 + ] 167 + 168 + [[package]] 169 + name = "bitflags" 170 + version = "2.9.0" 171 + source = "registry+https://github.com/rust-lang/crates.io-index" 172 + checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" 173 + 174 + [[package]] 175 + name = "bumpalo" 176 + version = "3.17.0" 177 + source = "registry+https://github.com/rust-lang/crates.io-index" 178 + checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" 179 + 180 + [[package]] 181 + name = "cfg-if" 182 + version = "1.0.0" 183 + source = "registry+https://github.com/rust-lang/crates.io-index" 184 + checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 185 + 186 + [[package]] 187 + name = "cfg_aliases" 188 + version = "0.2.1" 189 + source = "registry+https://github.com/rust-lang/crates.io-index" 190 + checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" 191 + 192 + [[package]] 193 + name = "concurrent-queue" 194 + version = "2.5.0" 195 + source = "registry+https://github.com/rust-lang/crates.io-index" 196 + checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" 197 + dependencies = [ 198 + "crossbeam-utils", 199 + ] 200 + 201 + [[package]] 202 + name = "console_error_panic_hook" 203 + version = "0.1.7" 204 + source = "registry+https://github.com/rust-lang/crates.io-index" 205 + checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" 206 + dependencies = [ 207 + "cfg-if", 208 + "wasm-bindgen", 209 + ] 210 + 211 + [[package]] 212 + name = "const-random" 213 + version = "0.1.18" 214 + source = "registry+https://github.com/rust-lang/crates.io-index" 215 + checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" 216 + dependencies = [ 217 + "const-random-macro", 218 + ] 219 + 220 + [[package]] 221 + name = "const-random-macro" 222 + version = "0.1.16" 223 + source = "registry+https://github.com/rust-lang/crates.io-index" 224 + checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" 225 + dependencies = [ 226 + "getrandom", 227 + "once_cell", 228 + "tiny-keccak", 229 + ] 230 + 231 + [[package]] 232 + name = "crossbeam-utils" 233 + version = "0.8.21" 234 + source = "registry+https://github.com/rust-lang/crates.io-index" 235 + checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" 236 + 237 + [[package]] 238 + name = "crunchy" 239 + version = "0.2.3" 240 + source = "registry+https://github.com/rust-lang/crates.io-index" 241 + checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" 242 + 243 + [[package]] 244 + name = "ctrlc" 245 + version = "3.4.5" 246 + source = "registry+https://github.com/rust-lang/crates.io-index" 247 + checksum = "90eeab0aa92f3f9b4e87f258c72b139c207d251f9cbc1080a0086b86a8870dd3" 248 + dependencies = [ 249 + "nix", 250 + "windows-sys", 251 + ] 252 + 253 + [[package]] 254 + name = "derive_more" 255 + version = "1.0.0" 256 + source = "registry+https://github.com/rust-lang/crates.io-index" 257 + checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" 258 + dependencies = [ 259 + "derive_more-impl", 260 + ] 261 + 262 + [[package]] 263 + name = "derive_more-impl" 264 + version = "1.0.0" 265 + source = "registry+https://github.com/rust-lang/crates.io-index" 266 + checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" 267 + dependencies = [ 268 + "proc-macro2", 269 + "quote", 270 + "syn", 271 + "unicode-xid", 272 + ] 273 + 274 + [[package]] 275 + name = "disqualified" 276 + version = "1.0.0" 277 + source = "registry+https://github.com/rust-lang/crates.io-index" 278 + checksum = "c9c272297e804878a2a4b707cfcfc6d2328b5bb936944613b4fdf2b9269afdfd" 279 + 280 + [[package]] 281 + name = "downcast-rs" 282 + version = "1.2.1" 283 + source = "registry+https://github.com/rust-lang/crates.io-index" 284 + checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" 285 + 286 + [[package]] 287 + name = "equivalent" 288 + version = "1.0.2" 289 + source = "registry+https://github.com/rust-lang/crates.io-index" 290 + checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 291 + 292 + [[package]] 293 + name = "fastrand" 294 + version = "2.3.0" 295 + source = "registry+https://github.com/rust-lang/crates.io-index" 296 + checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" 297 + 298 + [[package]] 299 + name = "fixedbitset" 300 + version = "0.4.2" 301 + source = "registry+https://github.com/rust-lang/crates.io-index" 302 + checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" 303 + 304 + [[package]] 305 + name = "fixedbitset" 306 + version = "0.5.7" 307 + source = "registry+https://github.com/rust-lang/crates.io-index" 308 + checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" 309 + 310 + [[package]] 311 + name = "futures-channel" 312 + version = "0.3.31" 313 + source = "registry+https://github.com/rust-lang/crates.io-index" 314 + checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" 315 + dependencies = [ 316 + "futures-core", 317 + ] 318 + 319 + [[package]] 320 + name = "futures-core" 321 + version = "0.3.31" 322 + source = "registry+https://github.com/rust-lang/crates.io-index" 323 + checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" 324 + 325 + [[package]] 326 + name = "futures-io" 327 + version = "0.3.31" 328 + source = "registry+https://github.com/rust-lang/crates.io-index" 329 + checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" 330 + 331 + [[package]] 332 + name = "futures-lite" 333 + version = "2.6.0" 334 + source = "registry+https://github.com/rust-lang/crates.io-index" 335 + checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" 336 + dependencies = [ 337 + "fastrand", 338 + "futures-core", 339 + "futures-io", 340 + "parking", 341 + "pin-project-lite", 342 + ] 343 + 344 + [[package]] 345 + name = "getrandom" 346 + version = "0.2.15" 347 + source = "registry+https://github.com/rust-lang/crates.io-index" 348 + checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 349 + dependencies = [ 350 + "cfg-if", 351 + "js-sys", 352 + "libc", 353 + "wasi", 354 + "wasm-bindgen", 355 + ] 356 + 357 + [[package]] 358 + name = "hashbrown" 359 + version = "0.14.5" 360 + source = "registry+https://github.com/rust-lang/crates.io-index" 361 + checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" 362 + dependencies = [ 363 + "ahash", 364 + "allocator-api2", 365 + "serde", 366 + ] 367 + 368 + [[package]] 369 + name = "hashbrown" 370 + version = "0.15.2" 371 + source = "registry+https://github.com/rust-lang/crates.io-index" 372 + checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" 373 + 374 + [[package]] 375 + name = "immediate_stats" 376 + version = "0.1.0" 377 + dependencies = [ 378 + "bevy_app", 379 + "bevy_ecs", 380 + "immediate_stats_macros", 381 + ] 382 + 383 + [[package]] 384 + name = "immediate_stats_macros" 385 + version = "0.1.0" 386 + dependencies = [ 387 + "proc-macro2", 388 + "quote", 389 + "syn", 390 + ] 391 + 392 + [[package]] 393 + name = "indexmap" 394 + version = "2.8.0" 395 + source = "registry+https://github.com/rust-lang/crates.io-index" 396 + checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" 397 + dependencies = [ 398 + "equivalent", 399 + "hashbrown 0.15.2", 400 + ] 401 + 402 + [[package]] 403 + name = "js-sys" 404 + version = "0.3.77" 405 + source = "registry+https://github.com/rust-lang/crates.io-index" 406 + checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" 407 + dependencies = [ 408 + "once_cell", 409 + "wasm-bindgen", 410 + ] 411 + 412 + [[package]] 413 + name = "libc" 414 + version = "0.2.171" 415 + source = "registry+https://github.com/rust-lang/crates.io-index" 416 + checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" 417 + 418 + [[package]] 419 + name = "log" 420 + version = "0.4.26" 421 + source = "registry+https://github.com/rust-lang/crates.io-index" 422 + checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" 423 + 424 + [[package]] 425 + name = "memchr" 426 + version = "2.7.4" 427 + source = "registry+https://github.com/rust-lang/crates.io-index" 428 + checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 429 + 430 + [[package]] 431 + name = "nix" 432 + version = "0.29.0" 433 + source = "registry+https://github.com/rust-lang/crates.io-index" 434 + checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" 435 + dependencies = [ 436 + "bitflags", 437 + "cfg-if", 438 + "cfg_aliases", 439 + "libc", 440 + ] 441 + 442 + [[package]] 443 + name = "nonmax" 444 + version = "0.5.5" 445 + source = "registry+https://github.com/rust-lang/crates.io-index" 446 + checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" 447 + 448 + [[package]] 449 + name = "once_cell" 450 + version = "1.21.1" 451 + source = "registry+https://github.com/rust-lang/crates.io-index" 452 + checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" 453 + 454 + [[package]] 455 + name = "parking" 456 + version = "2.2.1" 457 + source = "registry+https://github.com/rust-lang/crates.io-index" 458 + checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" 459 + 460 + [[package]] 461 + name = "petgraph" 462 + version = "0.6.5" 463 + source = "registry+https://github.com/rust-lang/crates.io-index" 464 + checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" 465 + dependencies = [ 466 + "fixedbitset 0.4.2", 467 + "indexmap", 468 + ] 469 + 470 + [[package]] 471 + name = "pin-project" 472 + version = "1.1.10" 473 + source = "registry+https://github.com/rust-lang/crates.io-index" 474 + checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" 475 + dependencies = [ 476 + "pin-project-internal", 477 + ] 478 + 479 + [[package]] 480 + name = "pin-project-internal" 481 + version = "1.1.10" 482 + source = "registry+https://github.com/rust-lang/crates.io-index" 483 + checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" 484 + dependencies = [ 485 + "proc-macro2", 486 + "quote", 487 + "syn", 488 + ] 489 + 490 + [[package]] 491 + name = "pin-project-lite" 492 + version = "0.2.16" 493 + source = "registry+https://github.com/rust-lang/crates.io-index" 494 + checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" 495 + 496 + [[package]] 497 + name = "proc-macro2" 498 + version = "1.0.94" 499 + source = "registry+https://github.com/rust-lang/crates.io-index" 500 + checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" 501 + dependencies = [ 502 + "unicode-ident", 503 + ] 504 + 505 + [[package]] 506 + name = "quote" 507 + version = "1.0.40" 508 + source = "registry+https://github.com/rust-lang/crates.io-index" 509 + checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 510 + dependencies = [ 511 + "proc-macro2", 512 + ] 513 + 514 + [[package]] 515 + name = "rustversion" 516 + version = "1.0.20" 517 + source = "registry+https://github.com/rust-lang/crates.io-index" 518 + checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" 519 + 520 + [[package]] 521 + name = "serde" 522 + version = "1.0.219" 523 + source = "registry+https://github.com/rust-lang/crates.io-index" 524 + checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" 525 + dependencies = [ 526 + "serde_derive", 527 + ] 528 + 529 + [[package]] 530 + name = "serde_derive" 531 + version = "1.0.219" 532 + source = "registry+https://github.com/rust-lang/crates.io-index" 533 + checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" 534 + dependencies = [ 535 + "proc-macro2", 536 + "quote", 537 + "syn", 538 + ] 539 + 540 + [[package]] 541 + name = "slab" 542 + version = "0.4.9" 543 + source = "registry+https://github.com/rust-lang/crates.io-index" 544 + checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 545 + dependencies = [ 546 + "autocfg", 547 + ] 548 + 549 + [[package]] 550 + name = "smallvec" 551 + version = "1.14.0" 552 + source = "registry+https://github.com/rust-lang/crates.io-index" 553 + checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" 554 + 555 + [[package]] 556 + name = "syn" 557 + version = "2.0.100" 558 + source = "registry+https://github.com/rust-lang/crates.io-index" 559 + checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" 560 + dependencies = [ 561 + "proc-macro2", 562 + "quote", 563 + "unicode-ident", 564 + ] 565 + 566 + [[package]] 567 + name = "thread_local" 568 + version = "1.1.8" 569 + source = "registry+https://github.com/rust-lang/crates.io-index" 570 + checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" 571 + dependencies = [ 572 + "cfg-if", 573 + "once_cell", 574 + ] 575 + 576 + [[package]] 577 + name = "tiny-keccak" 578 + version = "2.0.2" 579 + source = "registry+https://github.com/rust-lang/crates.io-index" 580 + checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" 581 + dependencies = [ 582 + "crunchy", 583 + ] 584 + 585 + [[package]] 586 + name = "toml_datetime" 587 + version = "0.6.8" 588 + source = "registry+https://github.com/rust-lang/crates.io-index" 589 + checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" 590 + 591 + [[package]] 592 + name = "toml_edit" 593 + version = "0.22.24" 594 + source = "registry+https://github.com/rust-lang/crates.io-index" 595 + checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" 596 + dependencies = [ 597 + "indexmap", 598 + "toml_datetime", 599 + "winnow", 600 + ] 601 + 602 + [[package]] 603 + name = "tracing" 604 + version = "0.1.41" 605 + source = "registry+https://github.com/rust-lang/crates.io-index" 606 + checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" 607 + dependencies = [ 608 + "pin-project-lite", 609 + "tracing-core", 610 + ] 611 + 612 + [[package]] 613 + name = "tracing-core" 614 + version = "0.1.33" 615 + source = "registry+https://github.com/rust-lang/crates.io-index" 616 + checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" 617 + dependencies = [ 618 + "once_cell", 619 + ] 620 + 621 + [[package]] 622 + name = "unicode-ident" 623 + version = "1.0.18" 624 + source = "registry+https://github.com/rust-lang/crates.io-index" 625 + checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 626 + 627 + [[package]] 628 + name = "unicode-xid" 629 + version = "0.2.6" 630 + source = "registry+https://github.com/rust-lang/crates.io-index" 631 + checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" 632 + 633 + [[package]] 634 + name = "version_check" 635 + version = "0.9.5" 636 + source = "registry+https://github.com/rust-lang/crates.io-index" 637 + checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" 638 + 639 + [[package]] 640 + name = "wasi" 641 + version = "0.11.0+wasi-snapshot-preview1" 642 + source = "registry+https://github.com/rust-lang/crates.io-index" 643 + checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 644 + 645 + [[package]] 646 + name = "wasm-bindgen" 647 + version = "0.2.100" 648 + source = "registry+https://github.com/rust-lang/crates.io-index" 649 + checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" 650 + dependencies = [ 651 + "cfg-if", 652 + "once_cell", 653 + "rustversion", 654 + "wasm-bindgen-macro", 655 + ] 656 + 657 + [[package]] 658 + name = "wasm-bindgen-backend" 659 + version = "0.2.100" 660 + source = "registry+https://github.com/rust-lang/crates.io-index" 661 + checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" 662 + dependencies = [ 663 + "bumpalo", 664 + "log", 665 + "proc-macro2", 666 + "quote", 667 + "syn", 668 + "wasm-bindgen-shared", 669 + ] 670 + 671 + [[package]] 672 + name = "wasm-bindgen-futures" 673 + version = "0.4.50" 674 + source = "registry+https://github.com/rust-lang/crates.io-index" 675 + checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" 676 + dependencies = [ 677 + "cfg-if", 678 + "js-sys", 679 + "once_cell", 680 + "wasm-bindgen", 681 + "web-sys", 682 + ] 683 + 684 + [[package]] 685 + name = "wasm-bindgen-macro" 686 + version = "0.2.100" 687 + source = "registry+https://github.com/rust-lang/crates.io-index" 688 + checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" 689 + dependencies = [ 690 + "quote", 691 + "wasm-bindgen-macro-support", 692 + ] 693 + 694 + [[package]] 695 + name = "wasm-bindgen-macro-support" 696 + version = "0.2.100" 697 + source = "registry+https://github.com/rust-lang/crates.io-index" 698 + checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" 699 + dependencies = [ 700 + "proc-macro2", 701 + "quote", 702 + "syn", 703 + "wasm-bindgen-backend", 704 + "wasm-bindgen-shared", 705 + ] 706 + 707 + [[package]] 708 + name = "wasm-bindgen-shared" 709 + version = "0.2.100" 710 + source = "registry+https://github.com/rust-lang/crates.io-index" 711 + checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" 712 + dependencies = [ 713 + "unicode-ident", 714 + ] 715 + 716 + [[package]] 717 + name = "web-sys" 718 + version = "0.3.77" 719 + source = "registry+https://github.com/rust-lang/crates.io-index" 720 + checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" 721 + dependencies = [ 722 + "js-sys", 723 + "wasm-bindgen", 724 + ] 725 + 726 + [[package]] 727 + name = "web-time" 728 + version = "1.1.0" 729 + source = "registry+https://github.com/rust-lang/crates.io-index" 730 + checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" 731 + dependencies = [ 732 + "js-sys", 733 + "wasm-bindgen", 734 + ] 735 + 736 + [[package]] 737 + name = "windows-sys" 738 + version = "0.59.0" 739 + source = "registry+https://github.com/rust-lang/crates.io-index" 740 + checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 741 + dependencies = [ 742 + "windows-targets", 743 + ] 744 + 745 + [[package]] 746 + name = "windows-targets" 747 + version = "0.52.6" 748 + source = "registry+https://github.com/rust-lang/crates.io-index" 749 + checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 750 + dependencies = [ 751 + "windows_aarch64_gnullvm", 752 + "windows_aarch64_msvc", 753 + "windows_i686_gnu", 754 + "windows_i686_gnullvm", 755 + "windows_i686_msvc", 756 + "windows_x86_64_gnu", 757 + "windows_x86_64_gnullvm", 758 + "windows_x86_64_msvc", 759 + ] 760 + 761 + [[package]] 762 + name = "windows_aarch64_gnullvm" 763 + version = "0.52.6" 764 + source = "registry+https://github.com/rust-lang/crates.io-index" 765 + checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 766 + 767 + [[package]] 768 + name = "windows_aarch64_msvc" 769 + version = "0.52.6" 770 + source = "registry+https://github.com/rust-lang/crates.io-index" 771 + checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 772 + 773 + [[package]] 774 + name = "windows_i686_gnu" 775 + version = "0.52.6" 776 + source = "registry+https://github.com/rust-lang/crates.io-index" 777 + checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 778 + 779 + [[package]] 780 + name = "windows_i686_gnullvm" 781 + version = "0.52.6" 782 + source = "registry+https://github.com/rust-lang/crates.io-index" 783 + checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 784 + 785 + [[package]] 786 + name = "windows_i686_msvc" 787 + version = "0.52.6" 788 + source = "registry+https://github.com/rust-lang/crates.io-index" 789 + checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 790 + 791 + [[package]] 792 + name = "windows_x86_64_gnu" 793 + version = "0.52.6" 794 + source = "registry+https://github.com/rust-lang/crates.io-index" 795 + checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 796 + 797 + [[package]] 798 + name = "windows_x86_64_gnullvm" 799 + version = "0.52.6" 800 + source = "registry+https://github.com/rust-lang/crates.io-index" 801 + checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 802 + 803 + [[package]] 804 + name = "windows_x86_64_msvc" 805 + version = "0.52.6" 806 + source = "registry+https://github.com/rust-lang/crates.io-index" 807 + checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 808 + 809 + [[package]] 810 + name = "winnow" 811 + version = "0.7.4" 812 + source = "registry+https://github.com/rust-lang/crates.io-index" 813 + checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" 814 + dependencies = [ 815 + "memchr", 816 + ] 817 + 818 + [[package]] 819 + name = "zerocopy" 820 + version = "0.7.35" 821 + source = "registry+https://github.com/rust-lang/crates.io-index" 822 + checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" 823 + dependencies = [ 824 + "zerocopy-derive", 825 + ] 826 + 827 + [[package]] 828 + name = "zerocopy-derive" 829 + version = "0.7.35" 830 + source = "registry+https://github.com/rust-lang/crates.io-index" 831 + checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" 832 + dependencies = [ 833 + "proc-macro2", 834 + "quote", 835 + "syn", 836 + ]
+14
Cargo.toml
··· 1 + [package] 2 + name = "immediate_stats" 3 + version = "0.1.0" 4 + edition = "2024" 5 + keywords = ["game", "bevy", "stats"] 6 + categories = ["game-development", "data-structures"] 7 + 8 + [features] 9 + bevy = ["bevy_ecs", "bevy_app"] 10 + 11 + [dependencies] 12 + bevy_app = { version = "0.15.3", default-features = false, optional = true } 13 + bevy_ecs = { version = "0.15", default-features = false, optional = true } 14 + immediate_stats_macros = { path = "immediate_stats_macros" }
+47
immediate_stats_macros/Cargo.lock
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "immediate_stats_macros" 7 + version = "0.1.0" 8 + dependencies = [ 9 + "proc-macro2", 10 + "quote", 11 + "syn", 12 + ] 13 + 14 + [[package]] 15 + name = "proc-macro2" 16 + version = "1.0.94" 17 + source = "registry+https://github.com/rust-lang/crates.io-index" 18 + checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" 19 + dependencies = [ 20 + "unicode-ident", 21 + ] 22 + 23 + [[package]] 24 + name = "quote" 25 + version = "1.0.40" 26 + source = "registry+https://github.com/rust-lang/crates.io-index" 27 + checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 28 + dependencies = [ 29 + "proc-macro2", 30 + ] 31 + 32 + [[package]] 33 + name = "syn" 34 + version = "2.0.100" 35 + source = "registry+https://github.com/rust-lang/crates.io-index" 36 + checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" 37 + dependencies = [ 38 + "proc-macro2", 39 + "quote", 40 + "unicode-ident", 41 + ] 42 + 43 + [[package]] 44 + name = "unicode-ident" 45 + version = "1.0.18" 46 + source = "registry+https://github.com/rust-lang/crates.io-index" 47 + checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
+12
immediate_stats_macros/Cargo.toml
··· 1 + [package] 2 + name = "immediate_stats_macros" 3 + version = "0.1.0" 4 + edition = "2024" 5 + 6 + [lib] 7 + proc-macro = true 8 + 9 + [dependencies] 10 + proc-macro2 = "1.0" 11 + quote = "1.0" 12 + syn = { version = "2.0", features = ["full"] }
+97
immediate_stats_macros/src/lib.rs
··· 1 + use proc_macro::{TokenStream}; 2 + use quote::quote; 3 + use std::collections::HashMap; 4 + use proc_macro2::Ident; 5 + use syn::{Data, DeriveInput}; 6 + 7 + #[derive(Default)] 8 + struct Stat { 9 + base: Option<Ident>, 10 + bonus: Option<Ident>, 11 + multiplier: Option<Ident>, 12 + } 13 + 14 + impl Stat { 15 + fn set(&mut self, attr_type: AttrType, ident: Ident) { 16 + match attr_type { 17 + AttrType::Base => self.base = Some(ident), 18 + AttrType::Bonus => self.bonus = Some(ident), 19 + AttrType::Multiplier => self.multiplier = Some(ident), 20 + } 21 + } 22 + } 23 + 24 + enum AttrType { 25 + Base, Bonus, Multiplier, 26 + } 27 + 28 + impl TryFrom<&String> for AttrType { 29 + type Error = (); 30 + 31 + fn try_from(value: &String) -> Result<Self, Self::Error> { 32 + match value.as_str() { 33 + "base" => Ok(Self::Base), 34 + "bonus" => Ok(Self::Bonus), 35 + "multiplier" => Ok(Self::Multiplier), 36 + _ => Err(()), 37 + } 38 + } 39 + } 40 + 41 + impl TryFrom<&Ident> for AttrType { 42 + type Error = (); 43 + 44 + fn try_from(value: &Ident) -> Result<Self, Self::Error> { 45 + Self::try_from(&value.to_string()) 46 + } 47 + } 48 + 49 + #[proc_macro_derive(StatContainer, attributes(base, bonus, multiplier))] 50 + pub fn stat_container_derive(item: TokenStream) -> TokenStream { 51 + let tree: DeriveInput = syn::parse(item) 52 + .expect("A valid TokenStream"); 53 + 54 + let struct_name = &tree.ident; 55 + 56 + let mut stats: HashMap<String, Stat> = HashMap::new(); 57 + 58 + match tree.data { 59 + Data::Struct(s) => { 60 + for field in s.fields { 61 + let ident = field.ident.unwrap(); 62 + 63 + for attr in field.attrs { 64 + let path = attr.meta.path(); 65 + 66 + let Ok(attr_ident) = path.require_ident() else { continue }; 67 + let Ok(attr_type) = AttrType::try_from(attr_ident) else { continue }; 68 + 69 + let stat_ident = path.segments.first().unwrap().ident.to_string(); 70 + let stat = match stats.get_mut(&stat_ident) { 71 + Some(s) => s, 72 + None => { 73 + stats.insert(stat_ident.clone(), Stat::default()); 74 + stats.get_mut(&stat_ident).unwrap() 75 + }, 76 + }; 77 + 78 + stat.set(attr_type, ident.clone()); 79 + } 80 + } 81 + }, 82 + Data::Enum(_) => todo!(), 83 + Data::Union(_) => unimplemented!(), 84 + } 85 + 86 + let bonuses = stats.values().filter_map(|x| x.bonus.clone()); 87 + let multipliers = stats.values().filter_map(|x| x.multiplier.clone()); 88 + 89 + quote! { 90 + impl StatContainer for #struct_name { 91 + fn reset_modifiers(&mut self) { 92 + #(self.#bonuses = 0;)* 93 + #(self.#multipliers = 1.0;)* 94 + } 95 + } 96 + }.into() 97 + }
+40
src/lib.rs
··· 1 + pub trait StatContainer { 2 + /// Resets all stat bonuses to zero, and stat multipliers to one. 3 + fn reset_modifiers(&mut self); 4 + } 5 + 6 + #[cfg(test)] 7 + mod tests { 8 + use immediate_stats_macros::StatContainer; 9 + use super::*; 10 + 11 + #[derive(StatContainer, PartialEq, Debug)] 12 + struct Health { 13 + #[base(health)] 14 + health_base: i32, 15 + #[bonus(health)] 16 + health_bonus: i32, 17 + #[multiplier(health)] 18 + health_multiplier: f32, 19 + } 20 + 21 + #[test] 22 + fn default() { 23 + let mut h = Health { 24 + health_base: 10, 25 + health_bonus: 3, 26 + health_multiplier: 1.5, 27 + }; 28 + 29 + h.reset_modifiers(); 30 + 31 + assert_eq!( 32 + h, 33 + Health { 34 + health_base: 10, 35 + health_bonus: 0, 36 + health_multiplier: 1.0, 37 + } 38 + ); 39 + } 40 + }