Decouple ParticleSimulation into separate class

This commit is contained in:
2021-12-27 23:29:02 -05:00
parent 8406578b80
commit 6e5d40614c
8 changed files with 327 additions and 252 deletions

View File

@@ -0,0 +1,48 @@
using System.Collections.Generic;
using Godot;
public struct ParticleRelationshipProps
{
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 class ParticleType
{
private readonly Dictionary<ParticleType, ParticleRelationshipProps> _particleRelationships =
new Dictionary<ParticleType, ParticleRelationshipProps>();
private float _hue;
public float Hue
{
get => _hue;
set => _hue = Mathf.Clamp(value, 0, 1);
}
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];
}
}