using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Svelto.ECS;
namespace GamecraftModdingAPI.Events
{
///
/// Convenient factories for mod event engines
///
public static class EventEngineFactory
{
///
/// Factory method which automatically adds the SimpleEventHandlerEngine to the Manager
///
/// The name of the engine
/// The type of event to handle
/// The operation to do when the event is created
/// The operation to do when the event is destroyed (if applicable)
/// The created object
public static SimpleEventHandlerEngine CreateAddSimpleHandler(string name, int type, Action onActivated, Action onDestroyed)
{
var engine = new SimpleEventHandlerEngine(onActivated, onDestroyed, type, name);
EventManager.AddEventHandler(engine);
return engine;
}
///
/// Factory method which automatically adds the SimpleEventHandlerEngine to the Manager
///
/// The name of the engine
/// The type of event to handle
/// The operation to do when the event is created
/// The operation to do when the event is destroyed (if applicable)
/// The created object
public static SimpleEventHandlerEngine CreateAddSimpleHandler(string name, int type, Action onActivated, Action onDestroyed)
{
var engine = new SimpleEventHandlerEngine(onActivated, onDestroyed, type, name);
EventManager.AddEventHandler(engine);
return engine;
}
///
/// Factory method which automatically adds the SimpleEventEmitterEngine to the Manager
///
/// The name of the engine
/// The type of event to emit
/// Will removing this engine not break your code?
/// The created object
public static SimpleEventEmitterEngine CreateAddSimpleEmitter(string name, int type, bool isRemovable = true)
{
var engine = new SimpleEventEmitterEngine(type, name, isRemovable);
EventManager.AddEventEmitter(engine);
return engine;
}
}
}