From 78abd3047fc6dca59cf48aa37d3d741c27494075 Mon Sep 17 00:00:00 2001 From: Varoon Pazhyanur Date: Mon, 15 Jan 2024 00:07:38 -0600 Subject: [PATCH] Max_player_projectiles should be an unsigned integer. This isnt javascript --- src/game/resources.rs | 2 +- src/weapon/mod.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/game/resources.rs b/src/game/resources.rs index 1bb77916..db7fab02 100644 --- a/src/game/resources.rs +++ b/src/game/resources.rs @@ -12,7 +12,7 @@ pub struct GameParametersResource { pub camera_zoom_out_scale: f32, /// Maximum possible projectiles for 1 of the player/mobs shots. Mainly kept low for perf and as /// a hard cap (along with fire rate) on how much of a "bullet hell" each mob/player creates. - pub max_player_projectiles: f32, + pub max_player_projectiles: u16, /// Maximum possible speed of an entity pub max_speed: f32, /// Maximum angle between the first and last projectile diff --git a/src/weapon/mod.rs b/src/weapon/mod.rs index e4af66d0..85e65260 100644 --- a/src/weapon/mod.rs +++ b/src/weapon/mod.rs @@ -86,18 +86,19 @@ pub fn update_weapon_system( pub(crate) trait WeaponProjectileInitialVelocitiesExt { /// The initial velocities of `n` projectiles using existing/'partially evaluated' params. - /// Could be evenly spaced, or something else based on the struct params. - fn get_linvels(&self, max_projectiles: f32) -> Vec; + /// Could be evenly spaced, or something else based on the struct params. max_projectiles + /// should be greater than 0. + fn get_linvels(&self, max_projectiles: u16) -> Vec; } impl WeaponProjectileInitialVelocitiesExt for WeaponProjectileData { - fn get_linvels(&self, max_projectiles: f32) -> Vec { + fn get_linvels(&self, max_projectiles: u16) -> Vec { match &self.spread_pattern { SpreadPattern::Arc(arc_pattern) => { // Get the segment of a spread angle let spread_angle_segment = { // percentage of the game's maximum amount of projectiles being spawned let total_projectiles_percent = - (self.count as f32 - 1.) / (max_projectiles - 1.); + (self.count as f32 - 1.) / (max_projectiles as f32 - 1.); // indicates the angle between the first and last projectile let spread_arc = arc_pattern .max_spread