WIP on (no branch): a99e3f3 WIP on master: 6e5d406 Decouple ParticleSimulation into separate class

This commit is contained in:
2021-12-28 14:32:11 -05:00
7 changed files with 177 additions and 137 deletions

View File

@@ -1,48 +1,51 @@
using System.Collections.Generic;
using Godot;
public struct ParticleRelationshipProps
namespace Particles.ParticleSimulation
{
public ParticleRelationshipProps(float minRadius, float maxRadius, float force)
public struct ParticleRelationshipProps
{
MinRadius = minRadius;
MaxRadius = maxRadius;
Force = force;
public ParticleRelationshipProps(float minRadius, float maxRadius, float force)
{
MinRadius = minRadius;
MaxRadius = maxRadius;
Force = force;
}
public float MinRadius { get; }
public float MaxRadius { get; }
public float Force { get; }
}
public float MinRadius { get; }
public float MaxRadius { get; }
public float Force { get; }
}
public class ParticleType
{
private readonly Dictionary<ParticleType, ParticleRelationshipProps> _particleRelationships =
new Dictionary<ParticleType, ParticleRelationshipProps>();
private float _hue;
public float Hue
public class ParticleType
{
get => _hue;
set => _hue = Mathf.Clamp(value, 0, 1);
}
private readonly Dictionary<ParticleType, ParticleRelationshipProps> _particleRelationships =
new Dictionary<ParticleType, ParticleRelationshipProps>();
public void AddRelationship(ParticleType type, ParticleRelationshipProps props)
{
if (_particleRelationships.ContainsKey(type))
return;
_particleRelationships[type] = props;
}
private float _hue;
public void RemoveRelationship(ParticleType type)
{
if (_particleRelationships.ContainsKey(type))
_particleRelationships.Remove(type);
}
public float Hue
{
get => _hue;
set => _hue = Mathf.Clamp(value, 0, 1);
}
public ParticleRelationshipProps GetRelationship(ParticleType type)
{
return _particleRelationships[type];
public void AddRelationship(ParticleType type, ParticleRelationshipProps props)
{
if (_particleRelationships.ContainsKey(type))
return;
_particleRelationships[type] = props;
}
public void RemoveRelationship(ParticleType type)
{
if (_particleRelationships.ContainsKey(type))
_particleRelationships.Remove(type);
}
public ParticleRelationshipProps GetRelationship(ParticleType type)
{
return _particleRelationships[type];
}
}
}