mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 12:06:37 +00:00
moved the particle system and the entity component system into their own nuget packages
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
|
||||
namespace MonoGame.Extended.Particles.Modifiers
|
||||
{
|
||||
public class VelocityColorModifier : IModifier
|
||||
{
|
||||
public HslColor StationaryColor { get; set; }
|
||||
public HslColor VelocityColor { get; set; }
|
||||
public float VelocityThreshold { get; set; }
|
||||
|
||||
public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
|
||||
{
|
||||
var velocityThreshold2 = VelocityThreshold*VelocityThreshold;
|
||||
|
||||
while (iterator.HasNext)
|
||||
{
|
||||
var particle = iterator.Next();
|
||||
var velocity2 = particle->Velocity.X*particle->Velocity.X +
|
||||
particle->Velocity.Y*particle->Velocity.Y;
|
||||
var deltaColor = VelocityColor - StationaryColor;
|
||||
|
||||
if (velocity2 >= velocityThreshold2)
|
||||
VelocityColor.CopyTo(out particle->Color);
|
||||
else
|
||||
{
|
||||
var t = (float) Math.Sqrt(velocity2)/VelocityThreshold;
|
||||
|
||||
particle->Color = new HslColor(
|
||||
deltaColor.H*t + StationaryColor.H,
|
||||
deltaColor.S*t + StationaryColor.S,
|
||||
deltaColor.L*t + StationaryColor.L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user