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