Compare commits
No commits in common. "e6d07de73468a08736dd251578917ea218e89631" and "cda93ffaacb76d7b8f2ccfd4f7b43850eaea26b3" have entirely different histories.
e6d07de734
...
cda93ffaac
@ -10,13 +10,13 @@ glow_enabled = true
|
|||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_oh8vq"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_oh8vq"]
|
||||||
|
|
||||||
[node name="player" type="LocalPlayer" unique_id=863055906 node_paths=PackedStringArray("camera", "soldier_mesh", "collider", "effects", "dead_cam_target", "respawn_label", "ball_origin", "weapon_node", "pause_panel", "exit_to_lobby", "settings_panel", "scoreboard")]
|
[node name="player" type="LocalPlayer" unique_id=863055906 node_paths=PackedStringArray("camera", "soldier_mesh", "collider", "splorch", "dead_cam_target", "respawn_label", "ball_origin", "weapon_node", "pause_panel", "exit_to_lobby", "settings_panel", "scoreboard")]
|
||||||
look_sensitivity = 1.5
|
look_sensitivity = 1.5
|
||||||
camera = NodePath("camera_3d")
|
camera = NodePath("camera_3d")
|
||||||
move_speed = 5.0
|
move_speed = 5.0
|
||||||
soldier_mesh = NodePath("soldier_m")
|
soldier_mesh = NodePath("soldier_m")
|
||||||
collider = NodePath("collision_shape_3d2")
|
collider = NodePath("collision_shape_3d2")
|
||||||
effects = NodePath("effects")
|
splorch = NodePath("splorch")
|
||||||
dead_cam_target = NodePath("dead_camera_target")
|
dead_cam_target = NodePath("dead_camera_target")
|
||||||
respawn_label = NodePath("respawn_label")
|
respawn_label = NodePath("respawn_label")
|
||||||
ball_origin = NodePath("camera_3d")
|
ball_origin = NodePath("camera_3d")
|
||||||
@ -44,7 +44,7 @@ transform = Transform3D(-0.5, 0, -4.371139e-08, 0, 0.5, 0, 4.371139e-08, 0, -0.5
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CapsuleShape3D_oh8vq")
|
shape = SubResource("CapsuleShape3D_oh8vq")
|
||||||
|
|
||||||
[node name="effects" parent="." unique_id=986677517 instance=ExtResource("2_ywmwa")]
|
[node name="splorch" parent="." unique_id=986677517 instance=ExtResource("2_ywmwa")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16157162, 1.4223524, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16157162, 1.4223524, 0)
|
||||||
|
|
||||||
[node name="dead_camera_target" type="Node3D" parent="." unique_id=559969559]
|
[node name="dead_camera_target" type="Node3D" parent="." unique_id=559969559]
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
sound_emitter = NodePath("sound_emitter")
|
sound_emitter = NodePath("sound_emitter")
|
||||||
bullet_prefab = ExtResource("1_m84jv")
|
bullet_prefab = ExtResource("1_m84jv")
|
||||||
bullet_source = NodePath("bullet_source")
|
bullet_source = NodePath("bullet_source")
|
||||||
cooldown = 1.5
|
|
||||||
|
|
||||||
[node name="Raygun" parent="." unique_id=1928455392 instance=ExtResource("1_ckadf")]
|
[node name="Raygun" parent="." unique_id=1928455392 instance=ExtResource("1_ckadf")]
|
||||||
|
|
||||||
|
|||||||
@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1cgct"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1cgct"]
|
||||||
|
|
||||||
[node name="player" type="RemotePlayer" unique_id=845968872 node_paths=PackedStringArray("soldier_mesh", "collider", "effects", "spectator_camera", "ball_origin", "name_label")]
|
[node name="player" type="RemotePlayer" unique_id=845968872 node_paths=PackedStringArray("soldier_mesh", "collider", "splorch", "spectator_camera", "ball_origin", "name_label")]
|
||||||
move_speed = 5.0
|
move_speed = 5.0
|
||||||
soldier_mesh = NodePath("soldier_m")
|
soldier_mesh = NodePath("soldier_m")
|
||||||
collider = NodePath("collision_shape_3d")
|
collider = NodePath("collision_shape_3d")
|
||||||
effects = NodePath("effects")
|
splorch = NodePath("gpu_particles_3d")
|
||||||
health = 100
|
health = 100
|
||||||
spectator_camera = NodePath("spectate_root/spectate_camera")
|
spectator_camera = NodePath("spectate_root/spectate_camera")
|
||||||
ball_origin = NodePath("ball_origin")
|
ball_origin = NodePath("ball_origin")
|
||||||
@ -24,7 +24,7 @@ transform = Transform3D(-0.5, 0, -4.371139e-08, 0, 0.5, 0, 4.371139e-08, 0, -0.5
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CapsuleShape3D_1cgct")
|
shape = SubResource("CapsuleShape3D_1cgct")
|
||||||
|
|
||||||
[node name="effects" parent="." unique_id=986677517 instance=ExtResource("2_orxjf")]
|
[node name="gpu_particles_3d" parent="." unique_id=986677517 instance=ExtResource("2_orxjf")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4540546, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4540546, 0)
|
||||||
|
|
||||||
[node name="spectate_root" type="Node3D" parent="." unique_id=624336254]
|
[node name="spectate_root" type="Node3D" parent="." unique_id=624336254]
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
[gd_scene format=3 uid="uid://cl66unms2gim0"]
|
[gd_scene format=3 uid="uid://cl66unms2gim0"]
|
||||||
|
|
||||||
[ext_resource type="AudioStream" uid="uid://bfg31e3s4jv8c" path="res://assets/Hit.mp3" id="1_2hdmt"]
|
|
||||||
|
|
||||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_1cgct"]
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_1cgct"]
|
||||||
particle_flag_align_y = true
|
particle_flag_align_y = true
|
||||||
direction = Vector3(0, 1, 0)
|
direction = Vector3(0, 1, 0)
|
||||||
@ -25,11 +23,7 @@ section_length = 0.1
|
|||||||
section_rings = 10
|
section_rings = 10
|
||||||
curve = SubResource("Curve_yli5f")
|
curve = SubResource("Curve_yli5f")
|
||||||
|
|
||||||
[node name="player_effects" type="PlayerEffects" unique_id=1493455892 node_paths=PackedStringArray("splorch", "hit_sound")]
|
[node name="gpu_particles_3d" type="GPUParticles3D" unique_id=986677517]
|
||||||
splorch = NodePath("splorch")
|
|
||||||
hit_sound = NodePath("hit_sound")
|
|
||||||
|
|
||||||
[node name="splorch" type="GPUParticles3D" parent="." unique_id=986677517]
|
|
||||||
emitting = false
|
emitting = false
|
||||||
amount = 20
|
amount = 20
|
||||||
one_shot = true
|
one_shot = true
|
||||||
@ -38,6 +32,3 @@ trail_enabled = true
|
|||||||
trail_lifetime = 0.5
|
trail_lifetime = 0.5
|
||||||
process_material = SubResource("ParticleProcessMaterial_1cgct")
|
process_material = SubResource("ParticleProcessMaterial_1cgct")
|
||||||
draw_pass_1 = SubResource("TubeTrailMesh_wwb7k")
|
draw_pass_1 = SubResource("TubeTrailMesh_wwb7k")
|
||||||
|
|
||||||
[node name="hit_sound" type="AudioStreamPlayer3D" parent="." unique_id=345049143]
|
|
||||||
stream = ExtResource("1_2hdmt")
|
|
||||||
|
|||||||
@ -15,8 +15,9 @@ use crate::{
|
|||||||
},
|
},
|
||||||
util::NetVector3,
|
util::NetVector3,
|
||||||
},
|
},
|
||||||
player::{DamageSource, IPlayer, LocalPlayer, NetTransform, RemotePlayer, weapon::WeaponType},
|
player::{DamageSource, IPlayer, LocalPlayer, NetTransform, RemotePlayer},
|
||||||
team_resource::TeamResource,
|
team_resource::TeamResource,
|
||||||
|
weapon::WeaponType,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GAME_MANAGER_GLOBAL: &str = "GameManagerGlobal";
|
pub const GAME_MANAGER_GLOBAL: &str = "GameManagerGlobal";
|
||||||
|
|||||||
@ -10,9 +10,12 @@ pub mod map;
|
|||||||
pub mod map_resource;
|
pub mod map_resource;
|
||||||
pub mod net;
|
pub mod net;
|
||||||
pub mod player;
|
pub mod player;
|
||||||
|
pub mod player_hand_remover;
|
||||||
pub mod popup_queue;
|
pub mod popup_queue;
|
||||||
|
pub mod soldier_mesh;
|
||||||
pub mod team_resource;
|
pub mod team_resource;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
|
pub mod weapon;
|
||||||
|
|
||||||
struct MyExtension;
|
struct MyExtension;
|
||||||
|
|
||||||
|
|||||||
@ -12,9 +12,10 @@ use crate::{
|
|||||||
game_manager::{Game, GameManager, GameOption, GameOptionValue, NetPlayer},
|
game_manager::{Game, GameManager, GameOption, GameOptionValue, NetPlayer},
|
||||||
game_settings::GameSettingsManager,
|
game_settings::GameSettingsManager,
|
||||||
net::{net_stats::Stats, util::NetVector3},
|
net::{net_stats::Stats, util::NetVector3},
|
||||||
player::{DamageSource, NetTransform, weapon::WeaponType},
|
player::{DamageSource, NetTransform},
|
||||||
popup_queue::{Popup, PopupQueue},
|
popup_queue::{Popup, PopupQueue},
|
||||||
ui::cli::{CliColor, CommandLinePanel},
|
ui::cli::{CliColor, CommandLinePanel},
|
||||||
|
weapon::WeaponType,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use godot::obj::Singleton;
|
use godot::{global::godot_print, obj::Singleton};
|
||||||
use teanet::PeerMessage;
|
use teanet::PeerMessage;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|||||||
@ -2,8 +2,9 @@ use std::{f32::consts::PI, ops::Neg};
|
|||||||
|
|
||||||
use godot::{
|
use godot::{
|
||||||
classes::{
|
classes::{
|
||||||
Button, Camera3D, CharacterBody3D, CollisionShape3D, ICharacterBody3D, Input, InputEvent,
|
Button, Camera3D, CharacterBody3D, CollisionShape3D, GpuParticles3D, ICharacterBody3D,
|
||||||
InputEventMouseMotion, Label, Label3D, Panel, PanelContainer, input::MouseMode,
|
Input, InputEvent, InputEventMouseMotion, Label, Label3D, Panel, PanelContainer,
|
||||||
|
input::MouseMode,
|
||||||
},
|
},
|
||||||
obj::WithBaseField,
|
obj::WithBaseField,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
@ -21,19 +22,11 @@ use crate::{
|
|||||||
},
|
},
|
||||||
util::{NetVector3, cast_ray},
|
util::{NetVector3, cast_ray},
|
||||||
},
|
},
|
||||||
player::{
|
soldier_mesh::SoldierMesh,
|
||||||
effects::PlayerEffects,
|
|
||||||
soldier_mesh::SoldierMesh,
|
|
||||||
weapon::{BallWeapon, Raygun, Weapon, WeaponType},
|
|
||||||
},
|
|
||||||
ui::{cli::CommandLinePanel, settings::SettingsPanel},
|
ui::{cli::CommandLinePanel, settings::SettingsPanel},
|
||||||
|
weapon::{BallWeapon, Raygun, Weapon, WeaponType},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod effects;
|
|
||||||
pub mod player_hand_remover;
|
|
||||||
pub mod soldier_mesh;
|
|
||||||
pub mod weapon;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub struct NetTransform {
|
pub struct NetTransform {
|
||||||
pub location: NetVector3,
|
pub location: NetVector3,
|
||||||
@ -190,7 +183,7 @@ pub struct LocalPlayer {
|
|||||||
#[export]
|
#[export]
|
||||||
collider: Option<Gd<CollisionShape3D>>,
|
collider: Option<Gd<CollisionShape3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
effects: Option<Gd<PlayerEffects>>,
|
splorch: Option<Gd<GpuParticles3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
dead_cam_target: Option<Gd<Node3D>>,
|
dead_cam_target: Option<Gd<Node3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
@ -297,11 +290,15 @@ impl IPlayer for LocalPlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rid = self.base().get_rid();
|
if self.shoot_cd <= 0. {
|
||||||
if let Some(mut weapon) = self.get_weapon() {
|
let rid = self.base().get_rid();
|
||||||
weapon
|
if let Some(mut weapon) = self.get_weapon() {
|
||||||
.dyn_bind_mut()
|
weapon
|
||||||
.shoot(rid, self.player_id.unwrap_or(0), to, deal_damage)
|
.dyn_bind_mut()
|
||||||
|
.shoot(rid, self.player_id.unwrap_or(0), to, deal_damage);
|
||||||
|
}
|
||||||
|
self.shoot_cd = 0.2;
|
||||||
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@ -339,8 +336,8 @@ impl IPlayer for LocalPlayer {
|
|||||||
if let Some(mut collider) = self.collider.take() {
|
if let Some(mut collider) = self.collider.take() {
|
||||||
collider.queue_free();
|
collider.queue_free();
|
||||||
}
|
}
|
||||||
if let Some(effects) = &mut self.effects {
|
if let Some(splorch) = &mut self.splorch {
|
||||||
effects.bind_mut().death();
|
splorch.set_emitting(true);
|
||||||
}
|
}
|
||||||
if let Some(mut weapon) = self.weapon.take() {
|
if let Some(mut weapon) = self.weapon.take() {
|
||||||
weapon.queue_free();
|
weapon.queue_free();
|
||||||
@ -656,7 +653,7 @@ pub struct RemotePlayer {
|
|||||||
#[export]
|
#[export]
|
||||||
collider: Option<Gd<CollisionShape3D>>,
|
collider: Option<Gd<CollisionShape3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
effects: Option<Gd<PlayerEffects>>,
|
splorch: Option<Gd<GpuParticles3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
health: i32,
|
health: i32,
|
||||||
#[export]
|
#[export]
|
||||||
@ -745,13 +742,17 @@ impl IPlayer for RemotePlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rid = self.base().get_rid();
|
if self.shoot_cd <= 0. {
|
||||||
if let Some(mesh) = &mut self.soldier_mesh
|
let rid = self.base().get_rid();
|
||||||
&& let Some(mut weapon) = mesh.bind().get_weapon()
|
if let Some(mesh) = &mut self.soldier_mesh
|
||||||
{
|
&& let Some(mut weapon) = mesh.bind().get_weapon()
|
||||||
weapon
|
{
|
||||||
.dyn_bind_mut()
|
weapon
|
||||||
.shoot(rid, self.player_id.unwrap_or(0), to, deal_damage)
|
.dyn_bind_mut()
|
||||||
|
.shoot(rid, self.player_id.unwrap_or(0), to, deal_damage);
|
||||||
|
}
|
||||||
|
self.shoot_cd = 0.2;
|
||||||
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@ -789,8 +790,8 @@ impl IPlayer for RemotePlayer {
|
|||||||
if let Some(mut collider) = self.collider.take() {
|
if let Some(mut collider) = self.collider.take() {
|
||||||
collider.queue_free();
|
collider.queue_free();
|
||||||
}
|
}
|
||||||
if let Some(effects) = &mut self.effects {
|
if let Some(splorch) = &mut self.splorch {
|
||||||
effects.bind_mut().death();
|
splorch.set_emitting(true);
|
||||||
}
|
}
|
||||||
if let Some(mut name) = self.name_label.take() {
|
if let Some(mut name) = self.name_label.take() {
|
||||||
name.queue_free();
|
name.queue_free();
|
||||||
@ -1,26 +0,0 @@
|
|||||||
use godot::{
|
|
||||||
classes::{AudioStreamPlayer3D, GpuParticles3D},
|
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
|
||||||
#[class(base=Node3D, init)]
|
|
||||||
pub struct PlayerEffects {
|
|
||||||
#[export]
|
|
||||||
splorch: Option<Gd<GpuParticles3D>>,
|
|
||||||
#[export]
|
|
||||||
hit_sound: Option<Gd<AudioStreamPlayer3D>>,
|
|
||||||
|
|
||||||
base: Base<Node3D>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PlayerEffects {
|
|
||||||
pub fn death(&mut self) {
|
|
||||||
if let Some(splorch) = &mut self.splorch {
|
|
||||||
splorch.set_emitting(true);
|
|
||||||
}
|
|
||||||
if let Some(sfx) = &mut self.hit_sound {
|
|
||||||
sfx.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@ use godot::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::player::{
|
use crate::{
|
||||||
player_hand_remover::PlayerHandRemover,
|
player_hand_remover::PlayerHandRemover,
|
||||||
weapon::{BallWeapon, Raygun, Weapon},
|
weapon::{BallWeapon, Raygun, Weapon},
|
||||||
};
|
};
|
||||||
@ -1,11 +1,14 @@
|
|||||||
use godot::{
|
use godot::{
|
||||||
classes::{Button, HBoxContainer, IPanel, Label, Panel},
|
classes::{
|
||||||
|
Button, HBoxContainer, IPanel, Label, Panel, VBoxContainer, box_container::AlignmentMode,
|
||||||
|
},
|
||||||
|
global::HorizontalAlignment,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game_manager::{Game, GameManager},
|
game_manager::{Game, GameManager},
|
||||||
ui::player_listings::PlayerListings,
|
ui::{player_listing::PlayerListing, player_listings::PlayerListings},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use godot::prelude::*;
|
use godot::prelude::*;
|
||||||
|
|
||||||
use crate::player::soldier_mesh::SoldierMesh;
|
use crate::soldier_mesh::SoldierMesh;
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
#[class(base=Node3D, init)]
|
#[class(base=Node3D, init)]
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use godot::{
|
use godot::{
|
||||||
classes::{HBoxContainer, IHBoxContainer, Label, Texture2D, TextureRect},
|
classes::{CompressedTexture2D, HBoxContainer, IHBoxContainer, Label, Texture2D, TextureRect},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,10 @@ use godot::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{game_settings::GameSettingsManager, ui::slider::SliderContainer};
|
use crate::{
|
||||||
|
game_settings::{GameSettings, GameSettingsManager},
|
||||||
|
ui::slider::SliderContainer,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Hash)]
|
||||||
pub enum Setting {
|
pub enum Setting {
|
||||||
|
|||||||
@ -4,12 +4,12 @@ use serde::{Deserialize, Serialize};
|
|||||||
use crate::{
|
use crate::{
|
||||||
ball::Ball,
|
ball::Ball,
|
||||||
game_manager::{Game, GameOption},
|
game_manager::{Game, GameOption},
|
||||||
net::util::cast_ray,
|
net::{network_manager::NetworkManager, util::cast_ray},
|
||||||
player::{DamageSource, IPlayer},
|
player::{DamageSource, IPlayer},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Weapon {
|
pub trait Weapon {
|
||||||
fn shoot(&mut self, player_rid: Rid, player_id: u16, to: Vector3, deal_damage: bool) -> bool;
|
fn shoot(&mut self, player_rid: Rid, player_id: u16, to: Vector3, deal_damage: bool);
|
||||||
fn get_type(&self) -> WeaponType;
|
fn get_type(&self) -> WeaponType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,28 +29,12 @@ pub struct Raygun {
|
|||||||
#[export]
|
#[export]
|
||||||
bullet_source: Option<Gd<Node3D>>,
|
bullet_source: Option<Gd<Node3D>>,
|
||||||
|
|
||||||
#[export]
|
|
||||||
cooldown: f64,
|
|
||||||
|
|
||||||
cooldown_remaining: f64,
|
|
||||||
|
|
||||||
base: Base<Node3D>,
|
base: Base<Node3D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[godot_api]
|
|
||||||
impl INode3D for Raygun {
|
|
||||||
fn process(&mut self, delta: f64) {
|
|
||||||
self.cooldown_remaining -= delta;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[godot_dyn]
|
#[godot_dyn]
|
||||||
impl Weapon for Raygun {
|
impl Weapon for Raygun {
|
||||||
fn shoot(&mut self, player: Rid, player_id: u16, to: Vector3, deal_damage: bool) -> bool {
|
fn shoot(&mut self, player: Rid, player_id: u16, to: Vector3, deal_damage: bool) {
|
||||||
if self.cooldown_remaining > 0. {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(emitter) = &mut self.sound_emitter {
|
if let Some(emitter) = &mut self.sound_emitter {
|
||||||
emitter.play();
|
emitter.play();
|
||||||
}
|
}
|
||||||
@ -105,10 +89,6 @@ impl Weapon for Raygun {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cooldown_remaining = self.cooldown;
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_type(&self) -> WeaponType {
|
fn get_type(&self) -> WeaponType {
|
||||||
@ -168,9 +148,7 @@ pub struct BallWeapon {
|
|||||||
|
|
||||||
#[godot_dyn]
|
#[godot_dyn]
|
||||||
impl Weapon for BallWeapon {
|
impl Weapon for BallWeapon {
|
||||||
fn shoot(&mut self, _: Rid, _: u16, _: Vector3, _: bool) -> bool {
|
fn shoot(&mut self, _: Rid, _: u16, _: Vector3, _: bool) {}
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_type(&self) -> WeaponType {
|
fn get_type(&self) -> WeaponType {
|
||||||
WeaponType::Ball
|
WeaponType::Ball
|
||||||
Loading…
Reference in New Issue
Block a user