A convenience library to genericize generating values for a given field. Includes a batteries-included component trait that can be utilized to automatically update another component with new values.
```rust use bevy::prelude::*;
use bevyvariableproperty::prelude::*;
fn main() { let p1 = Property::Static(Vec2::new(0.0, 1.0)); let p2 = Property::RandomRange((Vec2::new(0.0, -100.0)..=Vec2::new(100.0, 0.0)).into()); let p3 = Property::Random;
for _ in 0..10 {
for p in [&p1, &p2, &p3] {
println!("{:?}", p.get_value());
}
}
}
```
```rust, norun use bevy::prelude::*; use bevyvariable_property::prelude::*;
struct MyComponent(pub IntervalProperty
fn main() { App::new() .addplugins(DefaultPlugins) .addstartupsystem(setup) .addsystem(tick) .run(); }
fn setup(mut commands: Commands) { commands.spawn(Camera2dBundle::default()); commands.spawn(MyComponent(IntervalProperty::new( (0.0..=100.0).into(), 0.5, ))); }
fn tick(mut query: Query<&mut MyComponent>, time: Res
```
```rust, norun use bevy::{prelude::*, sprite::MaterialMesh2dBundle}; use bevyvariableproperty::{intervalproperty::, prelude::};
pub struct MyIntervalProperty(pub IntervalProperty
impl AsMut
impl IntervalPropertyComponent for MyIntervalProperty {
type Property = Property
fn update(new_value: &Vec2, target: &mut Transform) {
target.translation = new_value.extend(target.translation.z);
}
}
fn main() { App::new() .addplugins(DefaultPlugins) .addstartupsystem(setup) .addsystem(MyIntervalProperty::system) .run(); }
fn setup(
mut commands: Commands,
mut meshes: ResMut