Files
sbox-public/engine/Sandbox.Engine/Scene/Components/Particles/Emitter/ParticleSphereEmitter.cs
Carson Kompon a0cdba7ca6 Re-organize existing Components (#4595)
* Re-categorize SoundscapeTrigger, IndirectLightVolume, and AmbientLight components.

* Rename "Clutter Component" -> "Clutter Renderer" and add to "Rendering" category

* Move CameraComponent into "Rendering" category

* Move particle components into the "Effects" category
2026-04-25 07:26:05 -04:00

54 lines
1.0 KiB
C#

namespace Sandbox;
/// <summary>
/// Emits particles within a sphere shape.
/// </summary>
[Title( "Sphere Emitter" )]
[Category( "Effects" )]
[Icon( "radio_button_unchecked" )]
public sealed class ParticleSphereEmitter : ParticleEmitter
{
[Property, Range( 0, 100 )] public float Radius { get; set; } = 20.0f;
[Property, Range( -1000, 1000 )] public float Velocity { get; set; } = 100.0f;
[Property] public bool OnEdge { get; set; } = false;
protected override void DrawGizmos()
{
if ( !Gizmo.IsSelected )
return;
Gizmo.Draw.Color = Color.White.WithAlpha( 0.1f );
Gizmo.Draw.LineSphere( 0, Radius );
// TODO - Sphere Gizmo
}
public override bool Emit( ParticleEffect target )
{
var random = Vector3.Random;
var offset = random;
var radius = Radius * WorldScale;
var pos = WorldPosition;
if ( OnEdge )
{
pos += random.Normal * radius;
}
else
{
pos += random * radius;
}
var p = target.Emit( pos, Delta );
if ( Velocity != 0.0f )
{
p.Velocity += offset * Velocity;
}
return true;
}
}