Revert "Possibly fix bugs with ball in replay"

This reverts commit 9a33403761.
This commit is contained in:
Sofia 2026-07-27 01:36:20 +03:00
parent 327e19fd1a
commit 463004639c
8 changed files with 26 additions and 50 deletions

View File

@ -1162,9 +1162,7 @@ impl Game {
if let Some(player) = self.find_player_mut(player_id) {
if let Some(character) = &mut player.character {
character
.dyn_bind_mut()
.take_damage(source, damage, false, true);
character.dyn_bind_mut().take_damage(source, damage, false);
}
}
}
@ -1173,7 +1171,7 @@ impl Game {
pub fn handle_kill(&mut self, source: DamageSource, player_id: u16) {
if let Some(player) = self.find_player_mut(player_id) {
if let Some(character) = &mut player.character {
character.dyn_bind_mut().kill(source.clone(), true);
character.dyn_bind_mut().kill(source.clone());
self.on_kill(source, player_id);
}
}

View File

@ -70,12 +70,9 @@ impl Killbox {
pub fn kill(&mut self, node: Gd<Node3D>) {
if let Ok(mut player) = node.clone().try_dynify::<dyn IPlayer>() {
if NetworkManager::singleton().bind().is_host() {
player.dyn_bind_mut().take_damage(
DamageSource::Killbox(self.kind),
1000,
true,
true,
);
player
.dyn_bind_mut()
.take_damage(DamageSource::Killbox(self.kind), 1000, true);
}
} else if let Ok(_) = node.try_cast::<Ball>() {
if let Some(game) = &mut Game::singleton() {

View File

@ -145,7 +145,6 @@ impl Map {
{
let mut ball = ball_prefab.instantiate_as::<Ball>();
ball.bind_mut().dropper = player_id;
ball.bind_mut().active = true;
self.base_mut().add_child(&ball);
if let Some(transform) = transform {
ball.set_global_position(transform.location.into());
@ -173,7 +172,6 @@ impl Map {
{
let mut ball = ball_prefab.instantiate_as::<Ball>();
ball.bind_mut().dropper = player_id;
ball.bind_mut().active = false;
self.base_mut().add_child(&ball);
if let Some(transform) = transform {
ball.set_global_position(transform.location.into());

View File

@ -12,7 +12,6 @@ use crate::{
#[class(base=RigidBody3D, init)]
pub struct Ball {
pub dropper: Option<u16>,
pub active: bool,
alive_for: f64,
@ -50,9 +49,6 @@ impl Ball {
}
fn on_collision(&mut self, node: Gd<Node>) {
if !self.active {
return;
}
if let Ok(player) = node.try_dynify::<dyn IPlayer>()
&& let Some(player_id) = player.dyn_bind().get_player_id()
{

View File

@ -171,7 +171,7 @@ impl IPlayer for LocalPlayer {
fn apply_look_up(&mut self, _look: f32) {}
fn try_shoot(&mut self, to: Vector3, deal_damage: bool) -> bool {
if self.try_shoot_common(to, deal_damage, deal_damage) {
if self.try_shoot_common(to, deal_damage) {
if let Some(game) = &mut Game::singleton()
&& let Some(recorder) = game.bind_mut().recorder()
{
@ -209,7 +209,7 @@ impl IPlayer for LocalPlayer {
}
}
fn take_damage(&mut self, source: DamageSource, damage: i32, kill: bool, drop_ball: bool) {
fn take_damage(&mut self, source: DamageSource, damage: i32, kill: bool) {
self.run_deferred(move |s| {
if s.can_take_damage(&source) {
let (signal, player, kind) = source.into_signal();
@ -220,7 +220,7 @@ impl IPlayer for LocalPlayer {
});
s.health -= damage;
if kill && s.health <= 0 {
s.kill(source, drop_ball);
s.kill(source);
}
}
if let Some(health_label) = &mut s.health_label {
@ -237,10 +237,8 @@ impl IPlayer for LocalPlayer {
self.dead_for
}
fn kill(&mut self, source: DamageSource, drop_ball: bool) {
if drop_ball {
fn kill(&mut self, source: DamageSource) {
self.drop_ball(false);
}
let (signal, player, kind) = source.into_signal();
self.run_deferred(move |s| s.signals().on_die().emit(signal, player, kind));
@ -721,6 +719,6 @@ impl LocalPlayer {
#[godot_dyn]
impl Shootable for LocalPlayer {
fn on_shoot(&mut self, source: DamageSource, damage: i32, _: Vector3) {
self.take_damage(source, damage, true, true);
self.take_damage(source, damage, true);
}
}

View File

@ -47,15 +47,9 @@ pub trait IPlayer {
fn jump(&mut self);
fn try_shoot(&mut self, to: Vector3, deal_damage: bool) -> bool;
fn try_punch(&mut self, to: Vector3, deal_damage: bool) -> bool;
fn take_damage(
&mut self,
source_player: DamageSource,
damage: i32,
kill: bool,
drop_ball: bool,
);
fn take_damage(&mut self, source_player: DamageSource, damage: i32, kill: bool);
fn is_dead(&self) -> bool;
fn kill(&mut self, source_player: DamageSource, drop_ball: bool);
fn kill(&mut self, source_player: DamageSource);
fn dead_for(&self) -> f64;
fn swap_weapon(&mut self, weapon: WeaponType, drop_ball: bool);
fn get_weapon(&self) -> Option<DynGd<Node3D, dyn Weapon>>;
@ -70,7 +64,7 @@ pub trait PlayerCommon {
fn drop_ball_common(&mut self, with_velocity: bool) -> bool;
fn get_look_dir(&self) -> Vector3;
fn can_take_damage(&self, source: &DamageSource) -> bool;
fn try_shoot_common(&mut self, to: Vector3, deal_damage: bool, drop_ball: bool) -> bool;
fn try_shoot_common(&mut self, to: Vector3, deal_damage: bool) -> bool;
fn try_punch_common(&mut self, to: Vector3, deal_damage: bool) -> bool;
}
@ -182,12 +176,12 @@ impl<T: IPlayer + ICharacterBody3D + WithBaseField> PlayerCommon for T {
true
}
fn try_shoot_common(&mut self, to: Vector3, deal_damage: bool, drop_ball: bool) -> bool {
fn try_shoot_common(&mut self, to: Vector3, deal_damage: bool) -> bool {
if self.is_dead() {
return false;
}
if drop_ball && self.drop_ball(true) {
if self.drop_ball(true) {
return true;
}

View File

@ -126,7 +126,7 @@ impl IPlayer for RemotePlayer {
}
fn try_shoot(&mut self, to: Vector3, deal_damage: bool) -> bool {
self.try_shoot_common(to, deal_damage, deal_damage)
self.try_shoot_common(to, deal_damage)
}
fn try_punch(&mut self, to: Vector3, deal_damage: bool) -> bool {
@ -138,7 +138,7 @@ impl IPlayer for RemotePlayer {
}
}
fn take_damage(&mut self, source: DamageSource, damage: i32, kill: bool, drop_ball: bool) {
fn take_damage(&mut self, source: DamageSource, damage: i32, kill: bool) {
self.run_deferred(move |s| {
if s.can_take_damage(&source) {
let (signal, player, kind) = source.into_signal();
@ -149,7 +149,7 @@ impl IPlayer for RemotePlayer {
});
s.health -= damage;
if kill && s.health <= 0 {
s.kill(source, drop_ball);
s.kill(source);
}
}
if let Some(health_bar) = &mut s.health_bar {
@ -167,10 +167,8 @@ impl IPlayer for RemotePlayer {
self.dead_for
}
fn kill(&mut self, source: DamageSource, drop_ball: bool) {
if drop_ball {
fn kill(&mut self, source: DamageSource) {
self.drop_ball(false);
}
let (signal, player, kind) = source.into_signal();
self.run_deferred(move |s| s.signals().on_die().emit(signal, player, kind));
@ -288,6 +286,6 @@ impl RemotePlayer {
#[godot_dyn]
impl Shootable for RemotePlayer {
fn on_shoot(&mut self, source: DamageSource, damage: i32, _: Vector3) {
self.take_damage(source, damage, true, true);
self.take_damage(source, damage, true);
}
}

View File

@ -197,7 +197,7 @@ impl INode for ReplayPlayback {
match event {
ReplayEvent::Death(damage_source, player_id) => {
if let Some(character) = self.player_characters.get_mut(player_id) {
character.bind_mut().kill(*damage_source, false);
character.bind_mut().kill(*damage_source);
}
}
ReplayEvent::Shoot(player_id, to) => {
@ -234,12 +234,9 @@ impl INode for ReplayPlayback {
}
ReplayEvent::TakeDamage(player_id, damage_source, damage) => {
if let Some(character) = self.player_characters.get_mut(player_id) {
character.bind_mut().take_damage(
*damage_source,
*damage,
false,
false,
);
character
.bind_mut()
.take_damage(*damage_source, *damage, false);
}
}
}