// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Content/BinaryAsset.h"
#include "Engine/Core/Math/Color32.h"
#include "Engine/Core/Types/Pair.h"
#include "ParticleEmitter.h"
///
/// Particle system contains a composition of particle emitters and playback information.
///
API_CLASS(NoSpawn) class FLAXENGINE_API ParticleSystem : public BinaryAsset
{
DECLARE_BINARY_ASSET_HEADER(ParticleSystem, 1);
public:
///
/// The particle system timeline track data.
///
struct Track
{
enum class Types
{
Emitter = 0,
Folder = 1,
};
enum class Flags
{
None = 0,
Mute = 1,
};
///
/// The type of the track.
///
Types Type;
///
/// The flags of the track.
///
Flags Flag;
///
/// The parent track index or -1 for root tracks.
///
int32 ParentIndex;
///
/// The amount of child tracks (stored in the sequence after this track).
///
int32 ChildrenCount;
///
/// The name of the track.
///
String Name;
///
/// True if track is disabled, otherwise false (cached on load based on the flags and parent flags).
///
bool Disabled;
///
/// The track color.
///
Color32 Color;
union
{
struct
{
///
/// The index of the emitter (from particle system emitters collection).
///
int32 Index;
///
/// The start frame of the emitter play begin.
///
int32 StartFrame;
///
/// The total duration of the emitter playback in the timeline sequence frames amount.
///
int32 DurationFrames;
} AsEmitter;
struct
{
} AsFolder;
};
Track()
{
}
};
typedef Pair EmitterParameterOverrideKey;
public:
///
/// The asset data version number. Used to sync the data with the instances state. Incremented each time asset gets loaded.
///
uint32 Version = 0;
///
/// The frames amount per second of the timeline animation.
///
API_FIELD(ReadOnly) float FramesPerSecond;
///
/// The animation duration (in frames).
///
API_FIELD(ReadOnly) int32 DurationFrames;
///
/// The animation duration (in seconds).
///
API_PROPERTY() float GetDuration() const
{
return static_cast(DurationFrames) / FramesPerSecond;
}
///
/// The emitters used by this system.
///
Array> Emitters;
///
/// The overriden values for the emitters parameters. Key is pair of emitter index and parameter ID, value is the custom value.
///
Dictionary EmittersParametersOverrides;
///
/// The tracks on the system timeline.
///
Array