Decouple ParticleSimulation into separate class
This commit is contained in:
33
ParticleSimulation/Particle.cs
Normal file
33
ParticleSimulation/Particle.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
|
||||
namespace Particles
|
||||
{
|
||||
public class Particle
|
||||
{
|
||||
|
||||
public Vector2 Position = new Vector2();
|
||||
public Vector2 Velocity = new Vector2();
|
||||
public ParticleType Type { get; }
|
||||
public float AverageSpeed { get; private set; } = 1f;
|
||||
|
||||
public int Id { get; }
|
||||
public float Health
|
||||
{
|
||||
get => _health;
|
||||
set => _health = Mathf.Clamp(value, 0f, 1f);
|
||||
}
|
||||
|
||||
private float _health = 1f;
|
||||
|
||||
public Particle(int id, ParticleType type)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public void AddAverageSpeedValue(float speed)
|
||||
{
|
||||
AverageSpeed = (0.99f * AverageSpeed) + (0.01f * speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user