-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
168 additions
and
157 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
use godot_rust_script::{ | ||
godot::{ | ||
engine::{GpuParticles3D, PrimitiveMesh, StandardMaterial3D}, | ||
prelude::{godot_error, Gd}, | ||
}, | ||
godot_script_impl, GodotScript, | ||
godot::{ | ||
engine::{GpuParticles3D, PrimitiveMesh, StandardMaterial3D}, | ||
prelude::{godot_error, Gd}, | ||
}, | ||
godot_script_impl, GodotScript, | ||
}; | ||
|
||
/// Dust Particle behavior for a particle system. | ||
/// This is used for the rotor effects | ||
#[derive(GodotScript, Debug)] | ||
#[script(base = GpuParticles3D)] | ||
struct DustParticles { | ||
/// The strength of the emitted dust. | ||
/// This is used for the rotor effects | ||
/** | ||
* This is more documentation | ||
* please read it carefully | ||
*/ | ||
#[prop(get = Self::strength, set = Self::set_strength)] | ||
#[export(range(min = 0.1, max = 1.5, step = 0.05))] | ||
strength: f64, | ||
base: Gd<GpuParticles3D>, | ||
/// The strength of the emitted dust. | ||
/// This is used for the rotor effects | ||
/** | ||
* This is more documentation | ||
* please read it carefully | ||
*/ | ||
#[prop(get = Self::strength, set = Self::set_strength)] | ||
#[export(range(min = 0.1, max = 1.5, step = 0.05))] | ||
strength: f64, | ||
base: Gd<GpuParticles3D>, | ||
} | ||
|
||
#[godot_script_impl] | ||
impl DustParticles { | ||
pub fn _ready(&mut self) { | ||
self.set_strength(0.0); | ||
} | ||
pub fn _ready(&mut self) { | ||
self.set_strength(0.0); | ||
} | ||
|
||
/// get effect strength | ||
fn strength(&self) -> f64 { | ||
self.strength | ||
} | ||
/// get effect strength | ||
fn strength(&self) -> f64 { | ||
self.strength | ||
} | ||
|
||
pub fn set_strength(&mut self, value: f64) { | ||
self.strength = value; | ||
pub fn set_strength(&mut self, value: f64) { | ||
self.strength = value; | ||
|
||
let is_emitting = value > 0.0; | ||
let is_emitting = value > 0.0; | ||
|
||
if self.base.is_emitting() != is_emitting { | ||
self.base.set_emitting(is_emitting); | ||
} | ||
if self.base.is_emitting() != is_emitting { | ||
self.base.set_emitting(is_emitting); | ||
} | ||
|
||
if !self.base.is_emitting() { | ||
return; | ||
} | ||
if !self.base.is_emitting() { | ||
return; | ||
} | ||
|
||
let Some(mesh) = self.base.get_draw_pass_mesh(1) else { | ||
godot_error!("Draw pass 1 does not exist!"); | ||
return; | ||
}; | ||
let Some(mesh) = self.base.get_draw_pass_mesh(0) else { | ||
godot_error!("Draw pass 1 does not exist!"); | ||
return; | ||
}; | ||
|
||
let mesh: Gd<PrimitiveMesh> = mesh.cast(); | ||
let mesh: Gd<PrimitiveMesh> = mesh.cast(); | ||
|
||
let Some(material) = mesh.get_material() else { | ||
godot_error!("mesh has no material!"); | ||
return; | ||
}; | ||
let Some(material) = mesh.get_material() else { | ||
godot_error!("mesh has no material!"); | ||
return; | ||
}; | ||
|
||
let mut material: Gd<StandardMaterial3D> = material.cast(); | ||
let mut material: Gd<StandardMaterial3D> = material.cast(); | ||
|
||
let distance = (100.0 * (1.0 - value)).max(2.0); | ||
let distance = (100.0 * (1.0 - value)).max(2.0); | ||
|
||
material.set_proximity_fade_distance(distance as f32); | ||
} | ||
material.set_proximity_fade_distance(distance as f32); | ||
} | ||
} |
Oops, something went wrong.