Compare commits
No commits in common. "9d78db008d76e4d2c754e180e2d1b333520f121d" and "430de3e1f1ada2a570b11e6eec3066ec85c15855" have entirely different histories.
9d78db008d
...
430de3e1f1
@ -305,19 +305,14 @@ impl IPlayer for LocalPlayer {
|
||||
if let Some(mut weapon) = self.get_weapon()
|
||||
&& let Some(camera_origin) = &self.camera_origin
|
||||
{
|
||||
if weapon.dyn_bind_mut().shoot(
|
||||
weapon.dyn_bind_mut().shoot(
|
||||
rid,
|
||||
self.player_id.unwrap_or(0),
|
||||
camera_origin.get_global_position(),
|
||||
to,
|
||||
camera_origin.get_global_basis().col_b(),
|
||||
deal_damage,
|
||||
) {
|
||||
weapon.set_rotation(Vector3::RIGHT * 0.3);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@ -556,13 +551,6 @@ impl ICharacterBody3D for LocalPlayer {
|
||||
} else {
|
||||
(0., 0.)
|
||||
};
|
||||
let done_cd_percent =
|
||||
1. - (weapon.dyn_bind().get_remaining_cd() / weapon.dyn_bind().get_max_cd());
|
||||
let new_weapon_rot = weapon
|
||||
.get_rotation()
|
||||
.lerp(Vector3::ZERO, 0.03 * done_cd_percent as f32);
|
||||
weapon.set_rotation(new_weapon_rot);
|
||||
|
||||
let prev_weapon_pos = weapon.get_position();
|
||||
let new_y = prev_weapon_pos.y.lerp(target_y as f32, 0.2);
|
||||
let new_x = prev_weapon_pos.x.lerp(target_x as f32, 0.2);
|
||||
@ -722,16 +710,11 @@ impl LocalPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn_weapon(&mut self, mut weapon: DynGd<Node3D, dyn Weapon>) {
|
||||
let prev_cd = if let Some(mut weapon) = self.weapon.take() {
|
||||
let prev_cd = weapon.dyn_bind().get_remaining_cd();
|
||||
fn spawn_weapon(&mut self, weapon: DynGd<Node3D, dyn Weapon>) {
|
||||
if let Some(mut weapon) = self.weapon.take() {
|
||||
weapon.queue_free();
|
||||
prev_cd
|
||||
} else {
|
||||
0.
|
||||
};
|
||||
}
|
||||
if let Some(weapon_node) = &mut self.weapon_node {
|
||||
weapon.dyn_bind_mut().set_remaining_cd(prev_cd);
|
||||
weapon_node.add_child(&weapon);
|
||||
self.weapon = Some(weapon);
|
||||
}
|
||||
|
||||
@ -80,17 +80,12 @@ impl SoldierMesh {
|
||||
|
||||
fn spawn_weapon(
|
||||
&mut self,
|
||||
mut node: DynGd<Node3D, dyn Weapon>,
|
||||
node: DynGd<Node3D, dyn Weapon>,
|
||||
) -> Option<DynGd<Node3D, dyn Weapon>> {
|
||||
let prev_cd = if let Some(mut weapon) = self.current_weapon.take() {
|
||||
let rem = weapon.dyn_bind().get_remaining_cd();
|
||||
if let Some(mut weapon) = self.current_weapon.take() {
|
||||
weapon.queue_free();
|
||||
rem
|
||||
} else {
|
||||
0.
|
||||
};
|
||||
}
|
||||
if let Some(hand) = &mut self.hand_attachment {
|
||||
node.dyn_bind_mut().set_remaining_cd(prev_cd);
|
||||
hand.add_child(&node);
|
||||
self.current_weapon = Some(node.clone());
|
||||
Some(node)
|
||||
|
||||
@ -23,9 +23,6 @@ pub trait Weapon {
|
||||
deal_damage: bool,
|
||||
) -> bool;
|
||||
fn get_type(&self) -> WeaponType;
|
||||
fn get_max_cd(&self) -> f64;
|
||||
fn get_remaining_cd(&self) -> f64;
|
||||
fn set_remaining_cd(&mut self, cd: f64);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, PartialOrd)]
|
||||
@ -130,18 +127,6 @@ impl Weapon for Raygun {
|
||||
fn get_type(&self) -> WeaponType {
|
||||
WeaponType::Raygun
|
||||
}
|
||||
|
||||
fn get_max_cd(&self) -> f64 {
|
||||
self.cooldown
|
||||
}
|
||||
|
||||
fn get_remaining_cd(&self) -> f64 {
|
||||
self.cooldown_remaining
|
||||
}
|
||||
|
||||
fn set_remaining_cd(&mut self, cd: f64) {
|
||||
self.cooldown_remaining = cd;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(GodotClass)]
|
||||
@ -234,18 +219,6 @@ impl Weapon for Shotgun {
|
||||
fn get_type(&self) -> WeaponType {
|
||||
WeaponType::Shotgun
|
||||
}
|
||||
|
||||
fn get_max_cd(&self) -> f64 {
|
||||
self.cooldown
|
||||
}
|
||||
|
||||
fn get_remaining_cd(&self) -> f64 {
|
||||
self.cooldown_remaining
|
||||
}
|
||||
|
||||
fn set_remaining_cd(&mut self, cd: f64) {
|
||||
self.cooldown_remaining = cd;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(GodotClass)]
|
||||
@ -307,14 +280,4 @@ impl Weapon for BallWeapon {
|
||||
fn get_type(&self) -> WeaponType {
|
||||
WeaponType::Ball
|
||||
}
|
||||
|
||||
fn get_max_cd(&self) -> f64 {
|
||||
0.
|
||||
}
|
||||
|
||||
fn get_remaining_cd(&self) -> f64 {
|
||||
0.
|
||||
}
|
||||
|
||||
fn set_remaining_cd(&mut self, _: f64) {}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user