// Copyright (c) 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
{
///
public override bool CanBeCreated => true;
///
/// Types of the emitter templates that can be created.
///
public enum Templates
{
///
/// An empty emitter.
///
Empty,
///
/// An emitter that emits particles at a constant emission rate.
///
ConstantBurst,
///
/// An emitter that produces simple, periodic bursts of particles.
///
PeriodicBurst,
///
/// An emitter that uses a blended spritesheet to produce a smooth, thick cloud of smoke.
///
Smoke,
///
/// A GPU emitter that produces sparks that can collide, thanks to depth-buffer based collisions.
///
Sparks,
///
/// An emitter that produces a spiral shaped ribbon.
///
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("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());
}
}
}