Fetch telegrenades allowed per team
This commit is contained in:
parent
4c8c010174
commit
1db75b27cf
@ -1427,6 +1427,14 @@ impl Game {
|
|||||||
None
|
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)]
|
#[derive(Clone, Debug)]
|
||||||
|
|||||||
@ -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 {
|
pub fn get_float(&self, opt: GameOption) -> f64 {
|
||||||
let opt = self
|
let opt = self
|
||||||
.values
|
.values
|
||||||
|
|||||||
@ -449,7 +449,10 @@ impl ICharacterBody3D for LocalPlayer {
|
|||||||
|
|
||||||
self.run_deferred(|s| {
|
self.run_deferred(|s| {
|
||||||
s.telegrenades_allowed = if let Some(game) = Game::singleton() {
|
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 {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|||||||
@ -380,7 +380,10 @@ impl ICharacterBody3D for RemotePlayer {
|
|||||||
|
|
||||||
self.run_deferred(|s| {
|
self.run_deferred(|s| {
|
||||||
s.telegrenades_allowed = if let Some(game) = Game::singleton() {
|
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 {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user