Make it so it's enough to walk to the goal with the ball
This commit is contained in:
parent
2dba0d5d60
commit
8886a0d99d
@ -22,7 +22,7 @@ radius = 2.0
|
||||
[node name="goal" type="Goal" unique_id=177528504 node_paths=PackedStringArray("mesh")]
|
||||
mesh = NodePath("mesh_instance_3d")
|
||||
collision_layer = 8
|
||||
collision_mask = 8
|
||||
collision_mask = 11
|
||||
|
||||
[node name="mesh_instance_3d" type="MeshInstance3D" parent="." unique_id=587608036]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
|
||||
@ -4,7 +4,9 @@ use godot::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
game::Game, net::network_manager::NetworkManager, player::ball::Ball,
|
||||
game::Game,
|
||||
net::network_manager::NetworkManager,
|
||||
player::{IPlayer, ball::Ball, weapon::WeaponType},
|
||||
replay::StandaloneReplayManager,
|
||||
};
|
||||
|
||||
@ -55,10 +57,23 @@ impl Goal {
|
||||
}
|
||||
|
||||
fn on_enter(&self, node: Gd<Node3D>) {
|
||||
if let Ok(mut ball) = node.try_cast::<Ball>()
|
||||
if !NetworkManager::singleton().bind().is_host() {
|
||||
return;
|
||||
}
|
||||
let mut is_goal = None;
|
||||
if let Ok(mut ball) = node.clone().try_cast::<Ball>()
|
||||
&& !ball.bind().entered_goal
|
||||
{
|
||||
ball.bind_mut().entered_goal = true;
|
||||
is_goal = Some(ball.bind().dropper.unwrap_or(0));
|
||||
} else if let Ok(player) = node.clone().try_dynify::<dyn IPlayer>()
|
||||
&& let Some(weapon) = player.dyn_bind().get_weapon()
|
||||
&& weapon.dyn_bind().get_type() == WeaponType::Ball
|
||||
{
|
||||
is_goal = Some(player.dyn_bind().get_player_id().unwrap_or(0));
|
||||
}
|
||||
|
||||
if let Some(player_id) = is_goal {
|
||||
if let Some(mut game) = Game::singleton() {
|
||||
let teams = game
|
||||
.bind()
|
||||
@ -68,11 +83,8 @@ impl Goal {
|
||||
.map(|(id, _)| id as u8)
|
||||
.filter(|id| *id != self.team)
|
||||
.collect();
|
||||
if NetworkManager::singleton().bind().is_host() {
|
||||
game.bind_mut().respawn_ball();
|
||||
game.bind_mut()
|
||||
.handle_goal(ball.bind().dropper.unwrap_or(0), teams);
|
||||
}
|
||||
game.bind_mut().respawn_ball();
|
||||
game.bind_mut().handle_goal(player_id, teams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user