Fix ball problem in a neater way
This commit is contained in:
parent
463004639c
commit
6992bc5eff
@ -117,6 +117,7 @@ impl Map {
|
||||
node.bind_mut().player_id = Some(player_id);
|
||||
node.bind_mut().player_name = player.name.clone();
|
||||
node.bind_mut().player_color = player.color.clone().into();
|
||||
node.bind_mut().replay_mode = true;
|
||||
self.base_mut().add_child(&node);
|
||||
|
||||
node.bind_mut()
|
||||
|
||||
@ -301,6 +301,10 @@ impl IPlayer for LocalPlayer {
|
||||
fn get_camera_origin(&self) -> Option<Gd<Node3D>> {
|
||||
self.camera_origin.clone()
|
||||
}
|
||||
|
||||
fn is_replay_mode(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[godot_api]
|
||||
|
||||
@ -56,6 +56,7 @@ pub trait IPlayer {
|
||||
fn take_weapon(&mut self) -> Option<DynGd<Node3D, dyn Weapon>>;
|
||||
fn drop_ball(&mut self, with_velocity: bool) -> bool;
|
||||
fn get_camera_origin(&self) -> Option<Gd<Node3D>>;
|
||||
fn is_replay_mode(&self) -> bool;
|
||||
}
|
||||
|
||||
pub trait PlayerCommon {
|
||||
@ -181,7 +182,7 @@ impl<T: IPlayer + ICharacterBody3D + WithBaseField> PlayerCommon for T {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.drop_ball(true) {
|
||||
if !self.is_replay_mode() && self.drop_ball(true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ pub struct RemotePlayer {
|
||||
pub player_id: Option<u16>,
|
||||
pub player_name: String,
|
||||
pub player_color: Color,
|
||||
pub replay_mode: bool,
|
||||
|
||||
movement_dir: Vector3,
|
||||
y_speed: f32,
|
||||
@ -168,7 +169,9 @@ impl IPlayer for RemotePlayer {
|
||||
}
|
||||
|
||||
fn kill(&mut self, source: DamageSource) {
|
||||
if !self.replay_mode {
|
||||
self.drop_ball(false);
|
||||
}
|
||||
|
||||
let (signal, player, kind) = source.into_signal();
|
||||
self.run_deferred(move |s| s.signals().on_die().emit(signal, player, kind));
|
||||
@ -223,6 +226,10 @@ impl IPlayer for RemotePlayer {
|
||||
fn get_camera_origin(&self) -> Option<Gd<Node3D>> {
|
||||
self.camera_origin.clone()
|
||||
}
|
||||
|
||||
fn is_replay_mode(&self) -> bool {
|
||||
self.replay_mode
|
||||
}
|
||||
}
|
||||
|
||||
#[godot_api]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user