// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
using System.IO;
using FlaxEngine;
namespace FlaxEditor.Content.Create
{
///
/// Particle emitter asset creating handler. Allows to specify asset template.
///
///
public class ParticleEmitterCreateEntry : CreateFileEntry
{
///
/// Types of the emitter templates that can be created.
///
public enum Templates
{
///
/// The empty asset.
///
Empty,
///
/// The simple particle system that uses constant emission rate.
///
ConstantBurst,
///
/// The simple periodic burst particle system.
///
PeriodicBurst,
///
/// The layers and tags settings.
///
Smoke,
///
/// The GPU sparks with depth-buffer collisions.
///
Sparks,
///
/// The ribbon spiral particles.
///
RibbonSpiral,
}
///
/// The create options.
///
public class Options
{
///
/// The template.
///
[Tooltip("Particle emitter template.")]
public Templates Template = Templates.ConstantBurst;
}
private readonly Options _options = new Options();
///
public override object Settings => _options;
///
/// Initializes a new instance of the class.
///
/// The result file url.
public ParticleEmitterCreateEntry(string resultUrl)
: base("Settings", resultUrl)
{
}
///
public override bool Create()
{
string templateName;
switch (_options.Template)
{
case Templates.Empty:
return Editor.CreateAsset(Editor.NewAssetType.ParticleEmitter, ResultUrl);
case Templates.ConstantBurst:
templateName = "Constant Burst";
break;
case Templates.PeriodicBurst:
templateName = "Periodic Burst";
break;
case Templates.Smoke:
templateName = "Smoke";
break;
case Templates.Sparks:
templateName = "Sparks";
break;
case Templates.RibbonSpiral:
templateName = "Ribbon Spiral";
break;
default: throw new ArgumentOutOfRangeException();
}
var templatePath = Path.Combine(Globals.EngineContentFolder, "Editor/Particles", templateName + ".flax");
return Editor.Instance.ContentEditing.CloneAssetFile(templatePath, ResultUrl, Guid.NewGuid());
}
}
}