Add lifetime for decals
This commit is contained in:
parent
5083e8a738
commit
2dba0d5d60
@ -2,7 +2,8 @@
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cnahou6bg32pu" path="res://raw_assets/blood_splat.png" id="1_1rw23"]
|
||||
|
||||
[node name="bullet_hole_decal" type="Node3D" unique_id=18163478]
|
||||
[node name="blood_decal" type="MapDecal" unique_id=810489252]
|
||||
lifetime = 90.0
|
||||
|
||||
[node name="decal" type="Decal" parent="." unique_id=1515351623]
|
||||
size = Vector3(1, 1, 1)
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
|
||||
[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="bullet_hole_decal" type="MapDecal" unique_id=371158487]
|
||||
lifetime = 90.0
|
||||
|
||||
[node name="decal" type="Decal" parent="." unique_id=1515351623]
|
||||
size = Vector3(0.5, 0.5, 0.5)
|
||||
|
||||
22
rust/src/map/decal.rs
Normal file
22
rust/src/map/decal.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use godot::prelude::*;
|
||||
|
||||
#[derive(GodotClass)]
|
||||
#[class(base=Node3D, init)]
|
||||
pub struct MapDecal {
|
||||
#[export]
|
||||
lifetime: f64,
|
||||
|
||||
alive_for: f64,
|
||||
|
||||
base: Base<Node3D>,
|
||||
}
|
||||
|
||||
#[godot_api]
|
||||
impl INode3D for MapDecal {
|
||||
fn process(&mut self, delta: f64) {
|
||||
self.alive_for += delta;
|
||||
if self.alive_for >= self.lifetime {
|
||||
self.base_mut().queue_free();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,7 @@ use crate::{
|
||||
replay::{ReplayPlayer, ReplayPlayerState, StandaloneReplayManager},
|
||||
};
|
||||
|
||||
pub mod decal;
|
||||
pub mod footstep_box;
|
||||
pub mod goal;
|
||||
pub mod killbox;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user