From 77c1bd1e6a0d804a1d0666cdc003bd97981bbece Mon Sep 17 00:00:00 2001 From: yuni Date: Tue, 11 Jun 2024 00:58:56 +0200 Subject: [PATCH] add game::JupiterPos resource --- src/actor.rs | 20 ++++---------------- src/game.rs | 12 +++++++++++- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index 755fd0d..c5e98a3 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -555,18 +555,12 @@ fn handle_wants_maxvelocity( &WantsMaxVelocity, Option<&OrbitsJupiter>, )>, - id2pos: Res, + jupiter_pos: Res, ) { let dt = time.delta_seconds(); - let jupiter_pos: DVec3 = if let Some(jupiter_pos) = id2pos.0.get(cmd::ID_JUPITER) { - *jupiter_pos - } else { - warn!("Could not determine Jupiter's position"); - DVec3::ZERO - }; for (pos, mut v, engine, maxv, orbits_jupiter) in &mut query { let target_velocity = if orbits_jupiter.is_some() { - let relative_pos = pos.0 - jupiter_pos; + let relative_pos = pos.0 - jupiter_pos.0; nature::orbital_velocity(relative_pos, nature::JUPITER_MASS) } else { DVec3::ZERO @@ -672,21 +666,15 @@ fn handle_gravity( time: Res