public bool Add(ref T particle) { if (CapacityLimit.HasValue && _Count >= CapacityLimit.Value) { _ParticlesRemovedByLimit += 1; if (!RemoveParticlesWhenCapacityReached || !RemoveRandomParticle(null)) { return(false); } } var position = GetPosition(ref particle); var sectorIndex = Particles.GetIndexFromPoint(position); var sector = Particles.GetSectorFromIndex(sectorIndex, true); if (SectorCapacityLimit.HasValue && sector.Count >= SectorCapacityLimit.Value) { _ParticlesRemovedByLimit += 1; if (!RemoveParticlesWhenCapacityReached || !RemoveRandomParticle(sector)) { return(false); } } sector.Add(ref particle); _Count += 1; return(true); }