Make spawn protection work
This commit is contained in:
parent
6a2d8564d5
commit
a71bc513ac
@ -41,6 +41,15 @@ impl Buffs {
|
||||
}
|
||||
player.set_bubble_color(new_bubble_color);
|
||||
}
|
||||
|
||||
pub fn can_take_damage(&self) -> bool {
|
||||
for buff in &self.buffs {
|
||||
match buff.kind {
|
||||
BuffKind::SpawnProtection => return false,
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@ -366,6 +366,14 @@ impl IPlayer for LocalPlayer {
|
||||
fn set_bubble_color(&mut self, color: Color) {
|
||||
self.set_vignette_color(color);
|
||||
}
|
||||
|
||||
fn get_buffs(&self) -> &Buffs {
|
||||
&self.buffs
|
||||
}
|
||||
|
||||
fn get_buffs_mut(&mut self) -> &mut Buffs {
|
||||
&mut self.buffs
|
||||
}
|
||||
}
|
||||
|
||||
#[godot_api]
|
||||
|
||||
@ -16,6 +16,7 @@ use crate::{
|
||||
},
|
||||
pickup::PickupKind,
|
||||
player::{
|
||||
buffs::Buffs,
|
||||
shootable::Shootable,
|
||||
telegrenade::Telegrenade,
|
||||
weapon::{BallWeapon, Weapon, WeaponType},
|
||||
@ -75,6 +76,8 @@ pub trait IPlayer {
|
||||
fn telegrenade_teleport(&mut self, to: Vector3) -> bool;
|
||||
fn as_gd(&self) -> DynGd<CharacterBody3D, dyn IPlayer>;
|
||||
fn set_bubble_color(&mut self, color: Color);
|
||||
fn get_buffs(&self) -> &Buffs;
|
||||
fn get_buffs_mut(&mut self) -> &mut Buffs;
|
||||
}
|
||||
|
||||
pub trait PlayerCommon {
|
||||
@ -176,6 +179,10 @@ impl<T: IPlayer + ICharacterBody3D + WithBaseField> PlayerCommon for T {
|
||||
fn can_take_damage(&self, source: &DamageSource) -> bool {
|
||||
match source {
|
||||
DamageSource::Player(source_player_id) => {
|
||||
if !self.get_buffs().can_take_damage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(game) = Game::singleton() {
|
||||
let (self_team, source_team) = if let Some(self_player) =
|
||||
game.bind().find_player(self.get_player_id().unwrap_or(0))
|
||||
|
||||
@ -307,6 +307,14 @@ impl IPlayer for RemotePlayer {
|
||||
mesh.bind_mut().set_bubble_color(color);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_buffs(&self) -> &Buffs {
|
||||
&self.buffs
|
||||
}
|
||||
|
||||
fn get_buffs_mut(&mut self) -> &mut Buffs {
|
||||
&mut self.buffs
|
||||
}
|
||||
}
|
||||
|
||||
#[godot_api]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user