Add tint to gun color
This commit is contained in:
parent
06cc3006b3
commit
67b512222f
@ -3,5 +3,6 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://c7epv5p0qau02" path="res://assets/Gear.png" id="1_qr2ym"]
|
[ext_resource type="Texture2D" uid="uid://c7epv5p0qau02" path="res://assets/Gear.png" id="1_qr2ym"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
albedo_texture = ExtResource("1_qr2ym")
|
albedo_texture = ExtResource("1_qr2ym")
|
||||||
texture_filter = 0
|
texture_filter = 0
|
||||||
|
|||||||
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
[node name="Raygun" unique_id=1928455392 instance=ExtResource("1_njit6")]
|
[node name="Raygun" unique_id=1928455392 instance=ExtResource("1_njit6")]
|
||||||
|
|
||||||
[node name="Sniper_Rifle" parent="." index="0" unique_id=1650136097]
|
[node name="weapon_mesh" type="WeaponMesh" parent="." index="0" unique_id=612110357 node_paths=PackedStringArray("mesh")]
|
||||||
|
mesh = NodePath("../Sniper_Rifle")
|
||||||
|
|
||||||
|
[node name="Sniper_Rifle" parent="." index="1" unique_id=1650136097]
|
||||||
layers = 2
|
layers = 2
|
||||||
surface_material_override/0 = ExtResource("2_81k8r")
|
surface_material_override/0 = ExtResource("2_81k8r")
|
||||||
|
|||||||
@ -4,11 +4,15 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://bis6yrsc7uo1p" path="res://raw_assets/Soldier/Shotgun.png" id="2_cseg6"]
|
[ext_resource type="Texture2D" uid="uid://bis6yrsc7uo1p" path="res://raw_assets/Soldier/Shotgun.png" id="2_cseg6"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cseg6"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cseg6"]
|
||||||
|
resource_local_to_scene = true
|
||||||
albedo_texture = ExtResource("2_cseg6")
|
albedo_texture = ExtResource("2_cseg6")
|
||||||
texture_filter = 0
|
texture_filter = 0
|
||||||
|
|
||||||
[node name="Shotgun" unique_id=1412770732 instance=ExtResource("1_wwlim")]
|
[node name="Shotgun" unique_id=1412770732 instance=ExtResource("1_wwlim")]
|
||||||
|
|
||||||
[node name="Shotgun" parent="." index="0" unique_id=508004006]
|
[node name="weapon_mesh" type="WeaponMesh" parent="." index="0" unique_id=669806124 node_paths=PackedStringArray("mesh")]
|
||||||
|
mesh = NodePath("../Shotgun")
|
||||||
|
|
||||||
|
[node name="Shotgun" parent="." index="1" unique_id=508004006]
|
||||||
layers = 2
|
layers = 2
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_cseg6")
|
surface_material_override/0 = SubResource("StandardMaterial3D_cseg6")
|
||||||
|
|||||||
@ -4,16 +4,26 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://ctslratcr8h6v" path="res://scenes/weapons/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="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"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c7epv5p0qau02" path="res://assets/Gear.png" id="4_6y348"]
|
||||||
|
|
||||||
[node name="raygun" type="Raygun" unique_id=573018429 node_paths=PackedStringArray("sound_emitter", "bullet_source")]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_j7oj0"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
albedo_texture = ExtResource("4_6y348")
|
||||||
|
texture_filter = 0
|
||||||
|
|
||||||
|
[node name="raygun" type="Raygun" unique_id=573018429 node_paths=PackedStringArray("sound_emitter", "bullet_source", "mesh")]
|
||||||
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")
|
decal = ExtResource("2_vhn31")
|
||||||
|
mesh = NodePath("Raygun/weapon_mesh")
|
||||||
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")]
|
||||||
|
|
||||||
|
[node name="Sniper_Rifle" parent="Raygun" index="1" unique_id=1650136097]
|
||||||
|
surface_material_override/0 = SubResource("StandardMaterial3D_j7oj0")
|
||||||
|
|
||||||
[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)
|
||||||
stream = ExtResource("3_m84jv")
|
stream = ExtResource("3_m84jv")
|
||||||
@ -21,3 +31,5 @@ bus = &"SFX"
|
|||||||
|
|
||||||
[node name="bullet_source" type="Node3D" parent="." unique_id=211401237]
|
[node name="bullet_source" type="Node3D" parent="." unique_id=211401237]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.36108458, -1.490972)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.36108458, -1.490972)
|
||||||
|
|
||||||
|
[editable path="Raygun"]
|
||||||
|
|||||||
@ -3,6 +3,12 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://b32uxedvawp73" path="res://scenes/weapons/bullet_hole_decal.tscn" id="1_278ir"]
|
[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"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bis6yrsc7uo1p" path="res://raw_assets/Soldier/Shotgun.png" id="4_uukpr"]
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qn8fy"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
albedo_texture = ExtResource("4_uukpr")
|
||||||
|
texture_filter = 0
|
||||||
|
|
||||||
[sub_resource type="Gradient" id="Gradient_0xpw2"]
|
[sub_resource type="Gradient" id="Gradient_0xpw2"]
|
||||||
|
|
||||||
@ -50,11 +56,12 @@ material = SubResource("StandardMaterial3D_ybahf")
|
|||||||
radius = 0.1
|
radius = 0.1
|
||||||
curve = SubResource("Curve_yli5f")
|
curve = SubResource("Curve_yli5f")
|
||||||
|
|
||||||
[node name="shotgun" type="Shotgun" unique_id=786130999 node_paths=PackedStringArray("sound_emitter", "vfx")]
|
[node name="shotgun" type="Shotgun" unique_id=786130999 node_paths=PackedStringArray("sound_emitter", "vfx", "mesh")]
|
||||||
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")
|
decal = ExtResource("1_278ir")
|
||||||
|
mesh = NodePath("Shotgun/weapon_mesh")
|
||||||
|
|
||||||
[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)
|
||||||
@ -66,6 +73,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.36108458, -1.2375934)
|
|||||||
|
|
||||||
[node name="Shotgun" parent="." unique_id=1412770732 instance=ExtResource("3_0xpw2")]
|
[node name="Shotgun" parent="." unique_id=1412770732 instance=ExtResource("3_0xpw2")]
|
||||||
|
|
||||||
|
[node name="Shotgun" parent="Shotgun" index="1" unique_id=508004006]
|
||||||
|
surface_material_override/0 = SubResource("StandardMaterial3D_qn8fy")
|
||||||
|
|
||||||
[node name="gpu_particles_3d" type="GPUParticles3D" parent="." unique_id=898123062]
|
[node name="gpu_particles_3d" type="GPUParticles3D" parent="." unique_id=898123062]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.2958451, -1.2305822)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.2958451, -1.2305822)
|
||||||
emitting = false
|
emitting = false
|
||||||
@ -78,3 +88,5 @@ trail_enabled = true
|
|||||||
trail_lifetime = 0.1
|
trail_lifetime = 0.1
|
||||||
process_material = SubResource("ParticleProcessMaterial_1cgct")
|
process_material = SubResource("ParticleProcessMaterial_1cgct")
|
||||||
draw_pass_1 = SubResource("TubeTrailMesh_wwb7k")
|
draw_pass_1 = SubResource("TubeTrailMesh_wwb7k")
|
||||||
|
|
||||||
|
[editable path="Shotgun"]
|
||||||
|
|||||||
@ -333,6 +333,16 @@ impl IPlayer for LocalPlayer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
self.run_deferred(|s| {
|
||||||
|
if let Some(game) = Game::singleton()
|
||||||
|
&& let Some(player) = game.bind().find_player(s.player_id.unwrap_or(0))
|
||||||
|
&& let Some(team) = game.bind().get_team(player.data.team)
|
||||||
|
{
|
||||||
|
if let Some(weapon) = &mut s.weapon {
|
||||||
|
weapon.dyn_bind_mut().set_color(team.bind().color());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_weapon(&self) -> Option<DynGd<Node3D, dyn Weapon>> {
|
fn get_weapon(&self) -> Option<DynGd<Node3D, dyn Weapon>> {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use std::{collections::HashMap, f32::consts::PI};
|
use std::{collections::HashMap, f32::consts::PI};
|
||||||
|
|
||||||
use godot::{
|
use godot::{
|
||||||
classes::{AudioStreamPlayer3D, GpuParticles3D, RandomNumberGenerator},
|
classes::{AudioStreamPlayer3D, GpuParticles3D, MeshInstance3D, RandomNumberGenerator},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -13,6 +13,25 @@ use crate::{
|
|||||||
util::{RaycastResult, cast_ray, shotgun_ray},
|
util::{RaycastResult, cast_ray, shotgun_ray},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(GodotClass)]
|
||||||
|
#[class(base=Node3D, init)]
|
||||||
|
pub struct WeaponMesh {
|
||||||
|
#[export]
|
||||||
|
mesh: Option<Gd<MeshInstance3D>>,
|
||||||
|
|
||||||
|
base: Base<Node3D>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WeaponMesh {
|
||||||
|
fn set_color(&mut self, color: Color) {
|
||||||
|
if let Some(mesh) = &mut self.mesh
|
||||||
|
&& let Some(mut mat) = mesh.get_active_material(0)
|
||||||
|
{
|
||||||
|
mat.set("albedo_color", &color.to_variant());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait Weapon {
|
pub trait Weapon {
|
||||||
fn shoot(
|
fn shoot(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -28,6 +47,7 @@ pub trait Weapon {
|
|||||||
fn get_max_cd(&self) -> f64;
|
fn get_max_cd(&self) -> f64;
|
||||||
fn get_remaining_cd(&self) -> f64;
|
fn get_remaining_cd(&self) -> f64;
|
||||||
fn set_remaining_cd(&mut self, cd: f64);
|
fn set_remaining_cd(&mut self, cd: f64);
|
||||||
|
fn set_color(&mut self, color: Color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, PartialOrd)]
|
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, PartialOrd)]
|
||||||
@ -48,6 +68,8 @@ pub struct Raygun {
|
|||||||
bullet_source: Option<Gd<Node3D>>,
|
bullet_source: Option<Gd<Node3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
decal: Option<Gd<PackedScene>>,
|
decal: Option<Gd<PackedScene>>,
|
||||||
|
#[export]
|
||||||
|
mesh: Option<Gd<WeaponMesh>>,
|
||||||
|
|
||||||
#[export]
|
#[export]
|
||||||
cooldown: f64,
|
cooldown: f64,
|
||||||
@ -167,6 +189,12 @@ impl Weapon for Raygun {
|
|||||||
fn set_remaining_cd(&mut self, cd: f64) {
|
fn set_remaining_cd(&mut self, cd: f64) {
|
||||||
self.cooldown_remaining = cd;
|
self.cooldown_remaining = cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_color(&mut self, color: Color) {
|
||||||
|
if let Some(mesh) = &mut self.mesh {
|
||||||
|
mesh.bind_mut().set_color(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
@ -182,6 +210,8 @@ pub struct Shotgun {
|
|||||||
|
|
||||||
#[export]
|
#[export]
|
||||||
decal: Option<Gd<PackedScene>>,
|
decal: Option<Gd<PackedScene>>,
|
||||||
|
#[export]
|
||||||
|
mesh: Option<Gd<WeaponMesh>>,
|
||||||
|
|
||||||
cooldown_remaining: f64,
|
cooldown_remaining: f64,
|
||||||
|
|
||||||
@ -299,6 +329,12 @@ impl Weapon for Shotgun {
|
|||||||
fn set_remaining_cd(&mut self, cd: f64) {
|
fn set_remaining_cd(&mut self, cd: f64) {
|
||||||
self.cooldown_remaining = cd;
|
self.cooldown_remaining = cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_color(&mut self, color: Color) {
|
||||||
|
if let Some(mesh) = &mut self.mesh {
|
||||||
|
mesh.bind_mut().set_color(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
@ -379,6 +415,8 @@ impl Weapon for BallWeapon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_remaining_cd(&mut self, _: f64) {}
|
fn set_remaining_cd(&mut self, _: f64) {}
|
||||||
|
|
||||||
|
fn set_color(&mut self, _: Color) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_decal(result: &RaycastResult, prefab: Option<Gd<PackedScene>>) {
|
fn add_decal(result: &RaycastResult, prefab: Option<Gd<PackedScene>>) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user