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);
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
|
|||||||
@ -366,6 +366,14 @@ impl IPlayer for LocalPlayer {
|
|||||||
fn set_bubble_color(&mut self, color: Color) {
|
fn set_bubble_color(&mut self, color: Color) {
|
||||||
self.set_vignette_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]
|
#[godot_api]
|
||||||
|
|||||||
@ -16,6 +16,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
pickup::PickupKind,
|
pickup::PickupKind,
|
||||||
player::{
|
player::{
|
||||||
|
buffs::Buffs,
|
||||||
shootable::Shootable,
|
shootable::Shootable,
|
||||||
telegrenade::Telegrenade,
|
telegrenade::Telegrenade,
|
||||||
weapon::{BallWeapon, Weapon, WeaponType},
|
weapon::{BallWeapon, Weapon, WeaponType},
|
||||||
@ -75,6 +76,8 @@ pub trait IPlayer {
|
|||||||
fn telegrenade_teleport(&mut self, to: Vector3) -> bool;
|
fn telegrenade_teleport(&mut self, to: Vector3) -> bool;
|
||||||
fn as_gd(&self) -> DynGd<CharacterBody3D, dyn IPlayer>;
|
fn as_gd(&self) -> DynGd<CharacterBody3D, dyn IPlayer>;
|
||||||
fn set_bubble_color(&mut self, color: Color);
|
fn set_bubble_color(&mut self, color: Color);
|
||||||
|
fn get_buffs(&self) -> &Buffs;
|
||||||
|
fn get_buffs_mut(&mut self) -> &mut Buffs;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PlayerCommon {
|
pub trait PlayerCommon {
|
||||||
@ -176,6 +179,10 @@ impl<T: IPlayer + ICharacterBody3D + WithBaseField> PlayerCommon for T {
|
|||||||
fn can_take_damage(&self, source: &DamageSource) -> bool {
|
fn can_take_damage(&self, source: &DamageSource) -> bool {
|
||||||
match source {
|
match source {
|
||||||
DamageSource::Player(source_player_id) => {
|
DamageSource::Player(source_player_id) => {
|
||||||
|
if !self.get_buffs().can_take_damage() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(game) = Game::singleton() {
|
if let Some(game) = Game::singleton() {
|
||||||
let (self_team, source_team) = if let Some(self_player) =
|
let (self_team, source_team) = if let Some(self_player) =
|
||||||
game.bind().find_player(self.get_player_id().unwrap_or(0))
|
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);
|
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]
|
#[godot_api]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user