Compare commits
2 Commits
6d88ddc6ed
...
050e4b6021
| Author | SHA1 | Date | |
|---|---|---|---|
| 050e4b6021 | |||
| c65c3b0ac4 |
@ -129,3 +129,9 @@ name = "Florian Karsten"
|
|||||||
[[people.credits]]
|
[[people.credits]]
|
||||||
credit = "Space Grotesk"
|
credit = "Space Grotesk"
|
||||||
link = "https://floriankarsten.github.io/space-grotesk/"
|
link = "https://floriankarsten.github.io/space-grotesk/"
|
||||||
|
|
||||||
|
[[people]]
|
||||||
|
name = "musdasch"
|
||||||
|
[[people.credits]]
|
||||||
|
credit = "Bullet Decal"
|
||||||
|
link = "https://opengameart.org/content/bullet-decal"
|
||||||
|
|||||||
BIN
godot/raw_assets/bullet_hole.png
Normal file
BIN
godot/raw_assets/bullet_hole.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 334 KiB |
40
godot/raw_assets/bullet_hole.png.import
Normal file
40
godot/raw_assets/bullet_hole.png.import
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://sxfd2davklia"
|
||||||
|
path="res://.godot/imported/bullet_hole.png-06c7bf2f1e5bc1dff2400b53427c9cfb.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://raw_assets/bullet_hole.png"
|
||||||
|
dest_files=["res://.godot/imported/bullet_hole.png-06c7bf2f1e5bc1dff2400b53427c9cfb.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
@ -1,9 +1,9 @@
|
|||||||
[gd_scene format=3 uid="uid://bod6b3befmyt5"]
|
[gd_scene format=3 uid="uid://bod6b3befmyt5"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cw7duhhjebypt" path="res://scenes/player/raygun.tscn" id="1_a50o4"]
|
[ext_resource type="PackedScene" uid="uid://cw7duhhjebypt" path="res://scenes/weapons/raygun.tscn" id="1_a50o4"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ncxcmgdit2j1" path="res://mesh/soldier_m.tscn" id="1_sxefq"]
|
[ext_resource type="PackedScene" uid="uid://ncxcmgdit2j1" path="res://mesh/soldier_m.tscn" id="1_sxefq"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ci8r4lgijtalh" path="res://scenes/player/ball_weapon.tscn" id="2_jbny0"]
|
[ext_resource type="PackedScene" uid="uid://ci8r4lgijtalh" path="res://scenes/weapons/ball_weapon.tscn" id="2_jbny0"]
|
||||||
[ext_resource type="PackedScene" uid="uid://deyfeiqyi0wmj" path="res://scenes/player/shotgun.tscn" id="2_kknoo"]
|
[ext_resource type="PackedScene" uid="uid://deyfeiqyi0wmj" path="res://scenes/weapons/shotgun.tscn" id="2_kknoo"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cbvxh8xp8ilac" path="res://assets/Soldier.png" id="5_hjbn3"]
|
[ext_resource type="Texture2D" uid="uid://cbvxh8xp8ilac" path="res://assets/Soldier.png" id="5_hjbn3"]
|
||||||
[ext_resource type="Shader" uid="uid://canvckfs02odw" path="res://shaders/bubble_shader.tres" id="6_3lfhi"]
|
[ext_resource type="Shader" uid="uid://canvckfs02odw" path="res://shaders/bubble_shader.tres" id="6_3lfhi"]
|
||||||
|
|
||||||
|
|||||||
9
godot/scenes/weapons/bullet_hole_decal.tscn
Normal file
9
godot/scenes/weapons/bullet_hole_decal.tscn
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene format=3 uid="uid://b32uxedvawp73"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://sxfd2davklia" path="res://raw_assets/bullet_hole.png" id="1_lf0rx"]
|
||||||
|
|
||||||
|
[node name="bullet_hole_decal" type="Node3D" unique_id=18163478]
|
||||||
|
|
||||||
|
[node name="decal" type="Decal" parent="." unique_id=1515351623]
|
||||||
|
size = Vector3(0.5, 0.5, 0.5)
|
||||||
|
texture_albedo = ExtResource("1_lf0rx")
|
||||||
@ -1,13 +1,15 @@
|
|||||||
[gd_scene format=3 uid="uid://cw7duhhjebypt"]
|
[gd_scene format=3 uid="uid://cw7duhhjebypt"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cg81784ct8gf5" path="res://mesh/raygun.tscn" id="1_ckadf"]
|
[ext_resource type="PackedScene" uid="uid://cg81784ct8gf5" path="res://mesh/raygun.tscn" id="1_ckadf"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ctslratcr8h6v" path="res://scenes/player/raygun_beam.tscn" id="1_m84jv"]
|
[ext_resource type="PackedScene" uid="uid://ctslratcr8h6v" path="res://scenes/weapons/raygun_beam.tscn" id="1_m84jv"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b32uxedvawp73" path="res://scenes/weapons/bullet_hole_decal.tscn" id="2_vhn31"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bq553wxrelpdr" path="res://raw_assets/sfx/LaserWithRecoveryEditedCompressed.mp3" id="3_m84jv"]
|
[ext_resource type="AudioStream" uid="uid://bq553wxrelpdr" path="res://raw_assets/sfx/LaserWithRecoveryEditedCompressed.mp3" id="3_m84jv"]
|
||||||
|
|
||||||
[node name="raygun" type="Raygun" unique_id=573018429 node_paths=PackedStringArray("sound_emitter", "bullet_source")]
|
[node name="raygun" type="Raygun" unique_id=573018429 node_paths=PackedStringArray("sound_emitter", "bullet_source")]
|
||||||
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")
|
||||||
|
decal = ExtResource("2_vhn31")
|
||||||
cooldown = 1.5
|
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")]
|
||||||
@ -1,5 +1,6 @@
|
|||||||
[gd_scene format=3 uid="uid://deyfeiqyi0wmj"]
|
[gd_scene format=3 uid="uid://deyfeiqyi0wmj"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b32uxedvawp73" path="res://scenes/weapons/bullet_hole_decal.tscn" id="1_278ir"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bcclq2sv7k0x3" path="res://raw_assets/sfx/gun_sounds/shotgun_compressed.mp3" id="1_pyt38"]
|
[ext_resource type="AudioStream" uid="uid://bcclq2sv7k0x3" path="res://raw_assets/sfx/gun_sounds/shotgun_compressed.mp3" id="1_pyt38"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b8nwd3323kwlc" path="res://mesh/shotgun.tscn" id="3_0xpw2"]
|
[ext_resource type="PackedScene" uid="uid://b8nwd3323kwlc" path="res://mesh/shotgun.tscn" id="3_0xpw2"]
|
||||||
|
|
||||||
@ -53,6 +54,7 @@ curve = SubResource("Curve_yli5f")
|
|||||||
sound_emitter = NodePath("sound_emitter")
|
sound_emitter = NodePath("sound_emitter")
|
||||||
vfx = NodePath("gpu_particles_3d")
|
vfx = NodePath("gpu_particles_3d")
|
||||||
cooldown = 1.0
|
cooldown = 1.0
|
||||||
|
decal = ExtResource("1_278ir")
|
||||||
|
|
||||||
[node name="sound_emitter" type="AudioStreamPlayer3D" parent="." unique_id=1572422640]
|
[node name="sound_emitter" type="AudioStreamPlayer3D" parent="." unique_id=1572422640]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8420726, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8420726, 0)
|
||||||
@ -44,11 +44,13 @@ pub fn cast_ray(
|
|||||||
&& let Some(mut space) = world.get_direct_space_state()
|
&& let Some(mut space) = world.get_direct_space_state()
|
||||||
{
|
{
|
||||||
let results = space.intersect_ray(&ray);
|
let results = space.intersect_ray(&ray);
|
||||||
if let (Some(position), Some(collider)) =
|
if let Some(position) = results.get("position")
|
||||||
(results.get("position"), results.get("collider"))
|
&& let Some(collider) = results.get("collider")
|
||||||
|
&& let Some(normal) = results.get("normal")
|
||||||
{
|
{
|
||||||
Some(RaycastResult {
|
Some(RaycastResult {
|
||||||
position: Vector3::from_variant(&position),
|
position: Vector3::from_variant(&position),
|
||||||
|
normal: Vector3::from_variant(&normal),
|
||||||
collider: Gd::from_variant(&collider),
|
collider: Gd::from_variant(&collider),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -95,7 +97,9 @@ pub fn shotgun_ray(
|
|||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct RaycastResult {
|
pub struct RaycastResult {
|
||||||
pub position: Vector3,
|
pub position: Vector3,
|
||||||
|
pub normal: Vector3,
|
||||||
pub collider: Gd<Object>,
|
pub collider: Gd<Object>,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
use std::{collections::HashSet, f32::consts::PI};
|
use std::{collections::HashSet, f32::consts::PI};
|
||||||
|
|
||||||
use godot::{
|
use godot::{
|
||||||
classes::{AudioStreamPlayer3D, GpuParticles3D},
|
classes::{AudioStreamPlayer3D, GpuParticles3D, RandomNumberGenerator},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game::Game,
|
game::Game,
|
||||||
net::util::{cast_ray, shotgun_ray},
|
net::util::{RaycastResult, cast_ray, shotgun_ray},
|
||||||
player::{DamageSource, shootable::Shootable},
|
player::{DamageSource, shootable::Shootable},
|
||||||
replay::StandaloneReplayManager,
|
replay::StandaloneReplayManager,
|
||||||
};
|
};
|
||||||
@ -45,6 +45,8 @@ pub struct Raygun {
|
|||||||
bullet_prefab: Option<Gd<PackedScene>>,
|
bullet_prefab: Option<Gd<PackedScene>>,
|
||||||
#[export]
|
#[export]
|
||||||
bullet_source: Option<Gd<Node3D>>,
|
bullet_source: Option<Gd<Node3D>>,
|
||||||
|
#[export]
|
||||||
|
decal: Option<Gd<PackedScene>>,
|
||||||
|
|
||||||
#[export]
|
#[export]
|
||||||
cooldown: f64,
|
cooldown: f64,
|
||||||
@ -80,7 +82,7 @@ impl Weapon for Raygun {
|
|||||||
emitter.play();
|
emitter.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(source) = &self.bullet_source {
|
if let Some(source) = self.bullet_source.clone() {
|
||||||
let target = cast_ray(
|
let target = cast_ray(
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
@ -88,6 +90,13 @@ impl Weapon for Raygun {
|
|||||||
&Array::from_iter(vec![player]),
|
&Array::from_iter(vec![player]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let target_clone = target.clone();
|
||||||
|
self.run_deferred(|s| {
|
||||||
|
if let Some(target) = target_clone {
|
||||||
|
add_decal(&target, s.decal.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let dir = (to - source.get_global_position()).normalized();
|
let dir = (to - source.get_global_position()).normalized();
|
||||||
let beam_end = target
|
let beam_end = target
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -160,8 +169,13 @@ pub struct Shotgun {
|
|||||||
#[export]
|
#[export]
|
||||||
cooldown: f64,
|
cooldown: f64,
|
||||||
|
|
||||||
|
#[export]
|
||||||
|
decal: Option<Gd<PackedScene>>,
|
||||||
|
|
||||||
cooldown_remaining: f64,
|
cooldown_remaining: f64,
|
||||||
|
|
||||||
|
rng: Gd<RandomNumberGenerator>,
|
||||||
|
|
||||||
base: Base<Node3D>,
|
base: Base<Node3D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +209,7 @@ impl Weapon for Shotgun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut colliders = HashSet::new();
|
let mut colliders = HashSet::new();
|
||||||
|
let results = shotgun_ray(
|
||||||
for result in shotgun_ray(
|
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
up,
|
up,
|
||||||
@ -205,8 +218,25 @@ impl Weapon for Shotgun {
|
|||||||
10,
|
10,
|
||||||
PI / 2.,
|
PI / 2.,
|
||||||
10.,
|
10.,
|
||||||
) {
|
);
|
||||||
colliders.insert(result.collider);
|
let mut bullet_decal_results = Vec::new();
|
||||||
|
for _ in 0..10 {
|
||||||
|
if let Some(result) = results
|
||||||
|
.get(self.rng.randi_range(0, results.len() as i32 - 1) as usize)
|
||||||
|
.cloned()
|
||||||
|
{
|
||||||
|
bullet_decal_results.push(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for result in bullet_decal_results {
|
||||||
|
self.run_deferred(move |s| {
|
||||||
|
add_decal(&result, s.decal.clone());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for result in &results {
|
||||||
|
colliders.insert(result.collider.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
if deal_damage {
|
if deal_damage {
|
||||||
@ -322,3 +352,16 @@ impl Weapon for BallWeapon {
|
|||||||
|
|
||||||
fn set_remaining_cd(&mut self, _: f64) {}
|
fn set_remaining_cd(&mut self, _: f64) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_decal(result: &RaycastResult, prefab: Option<Gd<PackedScene>>) {
|
||||||
|
if let Some(mut game) = Game::singleton()
|
||||||
|
&& let Some(map) = &mut game.bind_mut().current_map
|
||||||
|
&& let Some(prefab) = prefab
|
||||||
|
{
|
||||||
|
let mut decal = prefab.instantiate_as::<Node3D>();
|
||||||
|
map.add_child(&decal);
|
||||||
|
decal.set_global_position(result.position);
|
||||||
|
let quat = Quaternion::from_rotation_arc(Vector3::UP, result.normal);
|
||||||
|
decal.set_global_rotation(quat.get_euler());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user