Add option for telegrenades_allowed
This commit is contained in:
parent
a4711b132e
commit
0ad90d24dd
@ -167,6 +167,10 @@ impl Default for GameOptions {
|
||||
opts.insert(GameOption::AllowAnyTeam, GameOptionValue::Boolean(false));
|
||||
opts.insert(GameOption::FriendlyFire, GameOptionValue::Boolean(true));
|
||||
opts.insert(GameOption::GoalsNeededToWin, GameOptionValue::Number(10.));
|
||||
opts.insert(
|
||||
GameOption::TelegrenadesAllowed,
|
||||
GameOptionValue::Boolean(true),
|
||||
);
|
||||
Self { values: opts }
|
||||
}
|
||||
}
|
||||
@ -195,6 +199,8 @@ pub enum GameOption {
|
||||
FriendlyFire,
|
||||
/// The number of goals needed to win a match
|
||||
GoalsNeededToWin,
|
||||
/// Whether telegrenades are allowed or not.
|
||||
TelegrenadesAllowed,
|
||||
}
|
||||
|
||||
impl ToString for GameOption {
|
||||
@ -204,6 +210,7 @@ impl ToString for GameOption {
|
||||
GameOption::AllowAnyTeam => "Allow anyone to select any teams",
|
||||
GameOption::FriendlyFire => "Friendly fire",
|
||||
GameOption::GoalsNeededToWin => "Goals needed to win",
|
||||
GameOption::TelegrenadesAllowed => "Telegrenades allowed",
|
||||
}
|
||||
.to_owned()
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ use godot::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
game_manager::{Game, GameManager},
|
||||
game_manager::{Game, GameManager, GameOption},
|
||||
game_settings::{GameSettings, GameSettingsManager},
|
||||
killbox::KillboxKind,
|
||||
net::{
|
||||
@ -92,6 +92,7 @@ pub struct LocalPlayer {
|
||||
telegrenade_cd: f64,
|
||||
telegrenade: Option<Gd<Telegrenade>>,
|
||||
telegrenade_cd_remaining: f64,
|
||||
telegrenades_allowed: bool,
|
||||
|
||||
base: Base<CharacterBody3D>,
|
||||
}
|
||||
@ -170,6 +171,10 @@ impl IPlayer for LocalPlayer {
|
||||
fn apply_look_up(&mut self, _look: f32) {}
|
||||
|
||||
fn try_throw_telegrenade(&mut self, to: Vector3) -> bool {
|
||||
if !self.telegrenades_allowed {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.telegrenade_cd_remaining > 0. {
|
||||
return false;
|
||||
}
|
||||
@ -385,6 +390,12 @@ impl ICharacterBody3D for LocalPlayer {
|
||||
.on_lock_changed()
|
||||
.connect_other(self, |s, lock| s.set_lock(lock));
|
||||
}
|
||||
|
||||
self.telegrenades_allowed = if let Some(game) = Game::singleton() {
|
||||
game.bind().opts.is_true(GameOption::TelegrenadesAllowed)
|
||||
} else {
|
||||
false
|
||||
};
|
||||
}
|
||||
|
||||
fn process(&mut self, delta: f64) {
|
||||
@ -499,7 +510,7 @@ impl ICharacterBody3D for LocalPlayer {
|
||||
|
||||
fn input(&mut self, event: Gd<InputEvent>) {
|
||||
if self.locked {
|
||||
if event.is_action_pressed("throw_telegrenade") {
|
||||
if event.is_action_pressed("throw_telegrenade") && self.telegrenades_allowed {
|
||||
if let Some(telegrenade) = &mut self.telegrenade {
|
||||
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
|
||||
match peer {
|
||||
|
||||
@ -8,6 +8,7 @@ use godot::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
game_manager::{Game, GameOption},
|
||||
killbox::KillboxKind,
|
||||
pickup::PickupKind,
|
||||
player::{
|
||||
@ -68,6 +69,7 @@ pub struct RemotePlayer {
|
||||
telegrenade_cd: f64,
|
||||
telegrenade: Option<Gd<Telegrenade>>,
|
||||
telegrenade_cd_remaining: f64,
|
||||
telegrenades_allowed: bool,
|
||||
|
||||
base: Base<CharacterBody3D>,
|
||||
}
|
||||
@ -141,6 +143,10 @@ impl IPlayer for RemotePlayer {
|
||||
}
|
||||
|
||||
fn try_throw_telegrenade(&mut self, to: Vector3) -> bool {
|
||||
if !self.telegrenades_allowed {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.telegrenade_cd_remaining > 0. {
|
||||
return false;
|
||||
}
|
||||
@ -302,6 +308,12 @@ impl ICharacterBody3D for RemotePlayer {
|
||||
|
||||
self.swap_weapon(WeaponType::Raygun, false);
|
||||
self.update_health_bar();
|
||||
|
||||
self.telegrenades_allowed = if let Some(game) = Game::singleton() {
|
||||
game.bind().opts.is_true(GameOption::TelegrenadesAllowed)
|
||||
} else {
|
||||
false
|
||||
};
|
||||
}
|
||||
|
||||
fn process(&mut self, delta: f64) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user