Skip to content

Commit 832f2bd

Browse files
committed
refactor(mob): remove commented code and improve code clarity
Removed unnecessary commented-out code to improve readability and maintainability. The changes do not alter the behavior of the code but make it cleaner and easier to understand.
1 parent f5e243a commit 832f2bd

File tree

1 file changed

+2
-11
lines changed
  • squash-the-creeps/rust/src

1 file changed

+2
-11
lines changed

squash-the-creeps/rust/src/mob.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,61 +20,52 @@ pub struct Mob {
2020
#[godot_api]
2121
impl ICharacterBody3D for Mob {
2222
fn physics_process(&mut self, _delta: f64) {
23-
// move_and_slide()
2423
self.base_mut().move_and_slide();
2524
}
2625
}
2726
#[godot_api]
2827
impl Mob {
2928
#[func]
3029
pub fn initialize(&mut self, start_position: Vector3, player_position: Vector3) {
31-
// look_at_from_position(start_position, player_position, Vector3.UP)
3230
self.base_mut()
3331
.look_at_from_position(start_position, player_position);
3432

35-
// rotate_y(randf_range(-PI / 4, PI / 4))
3633
self.base_mut()
3734
.rotate_y(rand::rng().random_range(-PI / 4.0..PI / 4.0));
3835

39-
// var random_speed = randf_range(min_speed, max_speed)
4036
let random_speed = rand::rng().random_range(self.min_speed..self.max_speed);
4137

4238
// We calculate a forward velocity first, which represents the speed.
43-
// velocity = Vector3.FORWARD * random_speed
4439
self.base_mut()
4540
.set_velocity(Vector3::FORWARD * random_speed);
4641

4742
let rotation = self.base().get_rotation();
4843
let velocity = self.base().get_velocity();
4944

5045
// We then rotate the vector based on the mob's Y rotation to move in the direction it's looking.
51-
// velocity = velocity.rotated(Vector3.UP, rotation.y)
5246
self.base_mut()
5347
.set_velocity(velocity.rotated(Vector3::UP, rotation.y));
5448

55-
// $AnimationPlayer.speed_scale = random_speed / min_speed
5649
let animation_speed = rand::rng().random_range(1.0..6.0);
50+
5751
self.base()
5852
.get_node_as::<AnimationPlayer>("AnimationPlayer")
5953
.set_speed_scale(animation_speed as f32)
6054
}
55+
6156
// Emitted when the player jumped on the mob.
62-
// signal squashed
6357
#[signal]
6458
pub fn squashed();
6559

6660
#[func]
6761
pub fn squash(&mut self) {
68-
// squashed.emit()
6962
self.signals().squashed().emit();
7063

71-
// queue_free()
7264
self.base_mut().queue_free();
7365
}
7466

7567
#[func]
7668
fn on_visible_on_screen_notifier_3d_screen_exited(&mut self) {
77-
// queue_free()
7869
self.base_mut().queue_free();
7970
}
8071
}

0 commit comments

Comments
 (0)