From 0b5c8eb8b6b06242ad5c999bb3afdf56e614fbb4 Mon Sep 17 00:00:00 2001 From: rewin Date: Thu, 7 Dec 2023 00:55:29 +0300 Subject: [PATCH] Imsprove velocity model and add random walk --- src/lib.rs | 10 +-- src/physics.rs | 25 +++++- src/player.rs | 4 +- src/sheep.rs | 236 ++++++++++++++++++++++++++++++++++++++++++------- 4 files changed, 234 insertions(+), 41 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8e50237..22ddf82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,20 +51,14 @@ impl Plugin for GamePlugin { torch::TorchPlugin, safe_area::SafeAreaPlugin, sprite_material::SpriteMaterialPlugin, + sheep::SheepPlugin, )); //For long term updates app.insert_resource(Time::::from_seconds(1.0)); app.add_systems(Startup, (test_level::setup, sheep::setup)); - // TODO: Move to plugin - app.add_systems( - Update, - ( - sheep::scared_sheeps.before(sheep::sheep_state), - sheep::update_scared_sheeps, - ), - ); + } } diff --git a/src/physics.rs b/src/physics.rs index 85c52e5..159638d 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -4,7 +4,10 @@ pub struct PhysicsPlugin; impl Plugin for PhysicsPlugin { fn build(&self, app: &mut App) { - app.add_systems(Update, apply_velocity); + app.add_systems(Update, ( + walk_system, + apply_velocity, + ).chain()); } } @@ -16,3 +19,23 @@ fn apply_velocity(mut query: Query<(&Velocity, &mut Transform)>, time: Res