mirror of
https://github.com/bevyengine/bevy
synced 2024-11-14 00:47:32 +00:00
694c06f3d0
# Objective Currently the `missing_docs` lint is allowed-by-default and enabled at crate level when their documentations is complete (see #3492). This PR proposes to inverse this logic by making `missing_docs` warn-by-default and mark crates with imcomplete docs allowed. ## Solution Makes `missing_docs` warn at workspace level and allowed at crate level when the docs is imcomplete.
42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
//! In this example we add a counter resource and increase it's value in one system,
|
|
//! while a different system prints the current count to the console.
|
|
|
|
use bevy_ecs::prelude::*;
|
|
use rand::Rng;
|
|
use std::ops::Deref;
|
|
|
|
fn main() {
|
|
// Create a world
|
|
let mut world = World::new();
|
|
|
|
// Add the counter resource
|
|
world.insert_resource(Counter { value: 0 });
|
|
|
|
// Create a schedule
|
|
let mut schedule = Schedule::default();
|
|
|
|
// Add systems to increase the counter and to print out the current value
|
|
schedule.add_systems((increase_counter, print_counter).chain());
|
|
|
|
for iteration in 1..=10 {
|
|
println!("Simulating frame {iteration}/10");
|
|
schedule.run(&mut world);
|
|
}
|
|
}
|
|
|
|
// Counter resource to be increased and read by systems
|
|
#[derive(Debug, Resource)]
|
|
struct Counter {
|
|
pub value: i32,
|
|
}
|
|
|
|
fn increase_counter(mut counter: ResMut<Counter>) {
|
|
if rand::thread_rng().gen_bool(0.5) {
|
|
counter.value += 1;
|
|
println!(" Increased counter value");
|
|
}
|
|
}
|
|
|
|
fn print_counter(counter: Res<Counter>) {
|
|
println!(" {:?}", counter.deref());
|
|
}
|