mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-15 23:19:29 +00:00
2ea7e85398
* Add enabled state for modifiers * Add enabled state for interpolators * Move AutoTrigger to effect not emitters * Remove LineUniformProfile * Set Enabled field true by default * Don't render invisible emitters * Remove unused member * Document update method * Add documentation * Remove test now that LineUniformProfile was removed * Fix unit tests
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
// Copyright (c) Craftwork Games. All rights reserved.
|
|
// Licensed under the MIT license.
|
|
// See LICENSE file in the project root for full license information.
|
|
|
|
using MonoGame.Extended.Particles.Data;
|
|
|
|
namespace MonoGame.Extended.Particles.Modifiers;
|
|
|
|
/// <summary>
|
|
/// A modifier that rapidly decreases particle opacity based on their age.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The <see cref="OpacityFastFadeModifier"/> creates a linear fade-out effect where particles
|
|
/// become more transparent as they age.
|
|
///
|
|
/// Important notes:
|
|
/// <list type="bullet">
|
|
/// <item>
|
|
/// This modifier assumes particles have a standard lifespan of 1.0 second. For particles
|
|
/// with different lifespans, the fade effect may not complete before the particle is removed,
|
|
/// or may become fully transparent before the particle's actual end of life.
|
|
/// </item>
|
|
/// <item>
|
|
/// Unlike other modifiers that accumulate changes over time, this modifier directly sets
|
|
/// the opacity value each frame based solely on the particle's age.
|
|
/// </item>
|
|
/// </list>
|
|
/// </remarks>
|
|
public sealed class OpacityFastFadeModifier : Modifier
|
|
{
|
|
/// <summary>
|
|
/// Updates all particles by setting their opacity based on their age.
|
|
/// </summary>
|
|
/// <inheritdoc/>
|
|
public override unsafe void Update(float elapsedSeconds, ParticleIterator iterator)
|
|
{
|
|
if (!Enabled) { return; }
|
|
|
|
while (iterator.HasNext)
|
|
{
|
|
Particle* particle = iterator.Next();
|
|
|
|
particle->Opacity = 1.0f - particle->Age;
|
|
}
|
|
}
|
|
}
|