/// <summary> /// Free all particles withing a given pool. /// </summary> /// <param name="poolerChain">Pool of particles to clear.</param> public void FreeAllParticles(IIndexPoolerChain poolerChain) { // Are any particles allocation? if (poolerChain.Allocated == 0) { // Sanity! Assert.Fatal(poolerChain.Head == T2DParticleManager.NodeEndMarker && poolerChain.Tail == T2DParticleManager.NodeEndMarker, "Emitter particle pool has no allocated nodes but chain isn't empty!"); // No, so return! return; } // Pass through to our internal index-pooler. _particlePool.FreeAllNodes(poolerChain); // Sanity! Assert.Fatal(poolerChain.Head == T2DParticleManager.NodeEndMarker && poolerChain.Tail == T2DParticleManager.NodeEndMarker, "Emitter particle pool deallocated but chain isn't empty!"); }
/// <summary> /// Free a single particle, removing from linked list. /// </summary> /// <param name="index">Index of particle to free.</param> /// <param name="poolerChain">Particle pool from which originally allocated.</param> public void FreeParticle(int index, IIndexPoolerChain poolerChain) { // Pass through to our internal index-pooler. _particlePool.FreeNode(index, poolerChain); }
/// <summary> /// Allocate a quantity of particles. No initialization occurs. /// </summary> /// <param name="quantity">Number of particles to allocate.</param> /// <param name="poolerChain">Pooler to allocate from.</param> /// <returns>Index of first allocated particle.</returns> public int AllocateParticles(int quantity, IIndexPoolerChain poolerChain) { // Pass through to our internal index-pooler. int startFreeIndex = _particlePool.AllocateNodes(quantity, poolerChain); // Return start free index. return startFreeIndex; }