Fetch telegrenades allowed per team

This commit is contained in:
Sofia 2026-08-03 21:36:07 +03:00
parent 4c8c010174
commit 1db75b27cf
4 changed files with 32 additions and 2 deletions

View File

@ -1427,6 +1427,14 @@ impl Game {
None
}
}
pub fn get_player_team(&self, player_id: u16) -> u8 {
if let Some(player) = self.find_player(player_id) {
player.data.team
} else {
0
}
}
}
#[derive(Clone, Debug)]

View File

@ -59,6 +59,22 @@ impl GameOptions {
}
}
pub fn is_team_true(&self, team: u8, opt: GameOption) -> bool {
if let Some(opts) = self.teams.get(team as usize) {
let opt = opts
.values
.get(&opt)
.copied()
.unwrap_or(GameOptionValue::Boolean(false));
match opt {
GameOptionValue::Boolean(value) => value,
_ => false,
}
} else {
false
}
}
pub fn get_float(&self, opt: GameOption) -> f64 {
let opt = self
.values

View File

@ -449,7 +449,10 @@ impl ICharacterBody3D for LocalPlayer {
self.run_deferred(|s| {
s.telegrenades_allowed = if let Some(game) = Game::singleton() {
game.bind().opts.is_true(GameOption::TelegrenadesAllowed)
game.bind().opts.is_team_true(
game.bind().get_player_team(s.player_id.unwrap_or(0)),
GameOption::TelegrenadesAllowed,
)
} else {
false
};

View File

@ -380,7 +380,10 @@ impl ICharacterBody3D for RemotePlayer {
self.run_deferred(|s| {
s.telegrenades_allowed = if let Some(game) = Game::singleton() {
game.bind().opts.is_true(GameOption::TelegrenadesAllowed)
game.bind().opts.is_team_true(
game.bind().get_player_team(s.player_id.unwrap_or(0)),
GameOption::TelegrenadesAllowed,
)
} else {
false
};