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