Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
ParticleFunctionController.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Graphics module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP
8 #define NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Graphics/ParticleController.hpp>
12 #include <functional>
13 
14 namespace Nz
15 {
16  class ParticleFunctionController;
17 
18  using ParticleFunctionControllerConstRef = ObjectRef<const ParticleFunctionController>;
19  using ParticleFunctionControllerRef = ObjectRef<ParticleFunctionController>;
20 
21  class NAZARA_GRAPHICS_API ParticleFunctionController : public ParticleController
22  {
23  public:
24  using Controller = std::function<void(ParticleGroup& /*group*/, ParticleMapper& /*mapper*/, unsigned int /*startId*/, unsigned int /*endId*/, float /*elapsedTime*/)>;
25 
26  inline ParticleFunctionController(Controller controller);
28  ~ParticleFunctionController() = default;
29 
30  void Apply(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override final;
31 
32  inline const Controller& GetController() const;
33 
34  inline void SetController(Controller controller);
35 
36  template<typename... Args> static ParticleFunctionControllerRef New(Args&&... args);
37 
38  private:
39  Controller m_controller;
40  };
41 }
42 
43 #include <Nazara/Graphics/ParticleFunctionController.inl>
44 
45 #endif // NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP
Graphics class which controls a flow of particles.
Definition: ParticleController.hpp:27
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Graphics class that represents the mapping between the internal buffer and the particle declaration...
Definition: ParticleMapper.hpp:17
decltype(auto) Apply(F &&fn, Tuple &&t)
Applies the tuple to the function (e.g. calls the function using the tuple content as arguments) ...
Definition: Algorithm.inl:48
Core class that represents a reference to an object.
Definition: ObjectRef.hpp:18
Helper class used to provide a function as a particle controller without going in the process of maki...
Definition: ParticleFunctionController.hpp:21