2021-12-27 23:29:02 -05:00
|
|
|
|
using Godot;
|
|
|
|
|
|
2021-12-28 14:32:11 -05:00
|
|
|
|
namespace Particles.ParticleSimulation
|
2021-12-27 23:29:02 -05:00
|
|
|
|
{
|
|
|
|
|
public class Particle
|
|
|
|
|
{
|
2021-12-28 14:32:11 -05:00
|
|
|
|
private float _health = 1f;
|
2021-12-27 23:29:02 -05:00
|
|
|
|
|
|
|
|
|
public Vector2 Position = new Vector2();
|
2021-12-29 15:08:26 -05:00
|
|
|
|
public bool WasTeleportedLast = true;
|
2021-12-27 23:29:02 -05:00
|
|
|
|
public Vector2 Velocity = new Vector2();
|
2021-12-28 14:32:11 -05:00
|
|
|
|
|
|
|
|
|
public Particle(int id, ParticleType type)
|
|
|
|
|
{
|
|
|
|
|
Id = id;
|
|
|
|
|
Type = type;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-27 23:29:02 -05:00
|
|
|
|
public ParticleType Type { get; }
|
|
|
|
|
public float AverageSpeed { get; private set; } = 1f;
|
|
|
|
|
|
2021-12-28 14:32:11 -05:00
|
|
|
|
// ReSharper disable once UnusedAutoPropertyAccessor.Global
|
|
|
|
|
// ReSharper disable once MemberCanBePrivate.Global
|
2021-12-27 23:29:02 -05:00
|
|
|
|
public int Id { get; }
|
2021-12-28 14:32:11 -05:00
|
|
|
|
|
2021-12-27 23:29:02 -05:00
|
|
|
|
public float Health
|
|
|
|
|
{
|
|
|
|
|
get => _health;
|
|
|
|
|
set => _health = Mathf.Clamp(value, 0f, 1f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddAverageSpeedValue(float speed)
|
|
|
|
|
{
|
2021-12-28 14:32:11 -05:00
|
|
|
|
AverageSpeed = 0.99f * AverageSpeed + 0.01f * speed;
|
2021-12-27 23:29:02 -05:00
|
|
|
|
}
|
2021-12-29 15:08:26 -05:00
|
|
|
|
|
|
|
|
|
public void ResetAverageSpeed()
|
|
|
|
|
{
|
|
|
|
|
AverageSpeed = 1f;
|
|
|
|
|
}
|
2021-12-27 23:29:02 -05:00
|
|
|
|
}
|
|
|
|
|
}
|