1#ifndef GAME_EDITOR_MAPITEMS_ENVELOPE_H
2#define GAME_EDITOR_MAPITEMS_ENVELOPE_H
3
4#include <game/map/render_map.h>
5#include <game/mapitems.h>
6
7#include <array>
8#include <vector>
9
10class CEnvelope
11{
12public:
13 std::vector<CEnvPoint_runtime> m_vPoints;
14 char m_aName[32] = "";
15 bool m_Synchronized = true;
16
17 enum class EType
18 {
19 POSITION,
20 COLOR,
21 SOUND
22 };
23 explicit CEnvelope(EType Type);
24 explicit CEnvelope(int NumChannels);
25
26 std::pair<float, float> GetValueRange(int ChannelMask);
27 void Eval(float Time, ColorRGBA &Result, size_t Channels);
28 void AddPoint(CFixedTime Time, std::array<int, CEnvPoint::MAX_CHANNELS> aValues);
29 float EndTime() const;
30 int FindPointIndex(CFixedTime Time) const;
31 int GetChannels() const;
32 EType Type() const { return m_Type; }
33
34private:
35 void Resort();
36
37 EType m_Type;
38
39 class CEnvelopePointAccess : public IEnvelopePointAccess
40 {
41 std::vector<CEnvPoint_runtime> *m_pvPoints;
42
43 public:
44 CEnvelopePointAccess(std::vector<CEnvPoint_runtime> *pvPoints);
45
46 int NumPoints() const override;
47 const CEnvPoint *GetPoint(int Index) const override;
48 const CEnvPointBezier *GetBezier(int Index) const override;
49 };
50 CEnvelopePointAccess m_PointsAccess;
51};
52
53#endif
54