-
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
14 changed files
with
1,605 additions
and
42 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "scripts" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["dylib", "rlib"] | ||
|
||
[dependencies] | ||
godot-rust-script = { workspace = true, features = ["scripts"] } | ||
backtrace = "0.3.64" | ||
num_enum = "0.7.1" |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod particles; | ||
mod scene_object_registry; | ||
mod spawner; | ||
|
||
godot_rust_script::setup_library!(); |
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use godot_rust_script::{ | ||
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>, | ||
} | ||
|
||
#[godot_script_impl] | ||
impl DustParticles { | ||
pub fn _ready(&mut self) { | ||
self.set_strength(0.0); | ||
} | ||
|
||
/// get effect strength | ||
pub fn strength(&self) -> f64 { | ||
self.strength | ||
} | ||
|
||
pub fn set_strength(&mut self, value: f64) { | ||
self.strength = value; | ||
|
||
let is_emitting = value > 0.0; | ||
|
||
if self.base.is_emitting() != is_emitting { | ||
self.base.set_emitting(is_emitting); | ||
} | ||
|
||
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 mesh: Gd<PrimitiveMesh> = mesh.cast(); | ||
|
||
let Some(material) = mesh.get_material() else { | ||
godot_error!("mesh has no material!"); | ||
return; | ||
}; | ||
|
||
let mut material: Gd<StandardMaterial3D> = material.cast(); | ||
|
||
let distance = (100.0 * (1.0 - value)).max(2.0); | ||
|
||
material.set_proximity_fade_distance(distance as f32); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
mod dust_particles; |
Oops, something went wrong.