// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Compiler.h"
struct RenderContext;
struct RenderView;
class ParticleEmitter;
class ParticleSystemInstance;
class ParticleEffect;
class ParticleSystem;
class ParticleBuffer;
class SceneRenderTask;
class Actor;
///
/// The particles service used for simulation and emitters data pooling.
///
class FLAXENGINE_API ParticleManager
{
public:
///
/// Updates the effect during next particles simulation tick.
///
/// The effect.
static void UpdateEffect(ParticleEffect* effect);
///
/// Called when effect gets removed from gameplay. All references to it should be cleared.
///
/// The effect.
static void OnEffectDestroy(ParticleEffect* effect);
public:
///
/// Draws the particles.
///
/// The rendering context.
/// The owning actor.
static void DrawParticles(RenderContext& renderContext, ParticleEffect* effect);
public:
///
/// Enables or disables particle buffer pooling.
///
static bool EnableParticleBufferPooling;
///
/// The particle buffer recycle timeout (in seconds).
///
static float ParticleBufferRecycleTimeout;
///
/// Acquires the free particle buffer for the emitter instance data.
///
/// The emitter.
/// The particle buffer.
static ParticleBuffer* AcquireParticleBuffer(ParticleEmitter* emitter);
///
/// Recycles the used particle buffer.
///
/// The particle buffer.
static void RecycleParticleBuffer(ParticleBuffer* buffer);
///
/// Called when emitter gets unloaded. Particle buffers using this emitter has to be cleared.
///
/// The emitter.
static void OnEmitterUnload(ParticleEmitter* emitter);
};