Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhu committed Nov 11, 2024
1 parent d6cc57c commit aeee011
Show file tree
Hide file tree
Showing 12 changed files with 535 additions and 599 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ env:

# Before enabling LFS, please take a look at GitHub's documentation for costs and quota limits:
# https://docs.github.com/en/repositories/working-with-files/managing-large-files/about-storage-and-bandwidth-usage
git_lfs: false
git_lfs: true
jobs:
# Determine the version number for this workflow.
get-version:
Expand Down
28 changes: 13 additions & 15 deletions src/enemy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn ai_system(
}
}

fn separation(position: Vec2, neighbours: &Vec<Vec2>) -> Vec2 {
fn separation(position: Vec2, neighbours: &[Vec2]) -> Vec2 {
if neighbours.is_empty() {
return Vec2::ZERO;
}
Expand All @@ -170,19 +170,17 @@ fn spawn_final_boss_system(
query: Query<(), With<FinalBoss>>,
player_query: Query<&Transform, With<IsPlayer>>,
) {
if game_time.0.elapsed_secs() > 60.0 * 10.0 {
if query.is_empty() {
// Spawn final boss
let pos = player_query
.get_single()
.map(|transform| transform.translation.truncate())
.unwrap_or_default();
let spawn_point = pos + Math::random_2d_unit_vector() * 1000.0;
spawn_final_boss(
&mut commands,
&fonts,
spawn_point.extend(RenderLayer::Enemy.as_z()),
)
}
if (game_time.0.elapsed_secs() > 60.0 * 10.0) & query.is_empty() {
// Spawn final boss
let pos = player_query
.get_single()
.map(|transform| transform.translation.truncate())
.unwrap_or_default();
let spawn_point = pos + Math::random_2d_unit_vector() * 1000.0;
spawn_final_boss(
&mut commands,
&fonts,
spawn_point.extend(RenderLayer::Enemy.as_z()),
)
}
}
6 changes: 2 additions & 4 deletions src/gameplay/effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ pub fn hit_flash_system(time: Res<Time>, mut query: Query<(&mut Text, &mut HitFl
if !hit_flash.timer.paused() && hit_flash.timer.elapsed().is_zero() {
// Store the actual colour once
if hit_flash.original_colour.is_none() {
hit_flash.original_colour = text
.sections
.first()
.and_then(|section| Some(section.style.color));
hit_flash.original_colour =
text.sections.first().map(|section| section.style.color);
}
// Set to flash colour
text.sections
Expand Down
10 changes: 5 additions & 5 deletions src/gameplay/gamelogic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ pub struct TakeDamageEvent {

#[derive(PartialEq)]
pub enum Allegiance {
PLAYER,
ENEMY,
Friend,
Enemy,
}

#[derive(Component)]
pub struct Targettable(pub Allegiance);

impl Default for Targettable {
fn default() -> Self {
Targettable(Allegiance::ENEMY)
Targettable(Allegiance::Enemy)
}
}

Expand All @@ -93,7 +93,7 @@ pub struct WillTarget(pub Vec<Allegiance>);

impl Default for WillTarget {
fn default() -> Self {
WillTarget(vec![Allegiance::PLAYER])
WillTarget(vec![Allegiance::Friend])
}
}

Expand Down Expand Up @@ -293,7 +293,7 @@ pub fn death_system(
points.value += worth_points.value;
}

if let Some(_) = is_player {
if is_player.is_some() {
game_state.set(GameState::GameOver);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gameplay/hud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn bar(current: i32, max: i32, width: i32) -> String {
}
let bars: usize = (current.clamp(0, max) * width / max)
.try_into()
.unwrap_or_else(|_| 0);
.unwrap_or(0);
format!(
"{}{}",
String::from('|').repeat(bars),
Expand Down
6 changes: 3 additions & 3 deletions src/gameplay/physics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Physics {
}
}

pub fn add_force(&mut self, force: Vec2) -> () {
pub fn add_force(&mut self, force: Vec2) {
self.acceleration += force;
}
}
Expand Down Expand Up @@ -71,8 +71,8 @@ pub fn physics_system(
) {
for (mut transform, mut physics, base_rotation) in &mut query {
// Not sure how to avoid cloning here
let current_acceleration = physics.acceleration.clone();
let drag = physics.drag.clone();
let current_acceleration = physics.acceleration;
let drag = physics.drag;
physics.velocity += current_acceleration;
transform.translation += physics.velocity.extend(0.0) * time.delta_seconds();
// println!("Player translate at {:?}", transform.translation);
Expand Down
4 changes: 2 additions & 2 deletions src/gameplay/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ fn spawn_player(In(config): In<SpawnPlayer>, mut commands: Commands, player_asse
collider: Collider {
radius: config.radius,
},
targettable: Targettable(Allegiance::PLAYER),
will_target: WillTarget(vec![Allegiance::ENEMY]),
targettable: Targettable(Allegiance::Friend),
will_target: WillTarget(vec![Allegiance::Enemy]),
..default()
},
BaseGlyphRotation {
Expand Down
2 changes: 1 addition & 1 deletion src/gameplay/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fn button(parent: &mut ChildBuilder, fonts: &Res<Fonts>, upgrade: UpgradeEvent)
});
parent.spawn(TextBundle {
text: Text::from_section(
format!("{}", upgrade.describe()),
upgrade.describe().to_string(),
TextStyle {
font: fonts.primary.clone(),
font_size: 14.0,
Expand Down
Loading

0 comments on commit aeee011

Please sign in to comment.