A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.7KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Svelto.ECS;
  7. namespace GamecraftModdingAPI.Events
  8. {
  9. /// <summary>
  10. /// Convenient factories for mod event engines
  11. /// </summary>
  12. [Obsolete]
  13. public static class EventEngineFactory
  14. {
  15. /// <summary>
  16. /// Factory method which automatically adds the SimpleEventHandlerEngine to the Manager
  17. /// </summary>
  18. /// <param name="name">The name of the engine</param>
  19. /// <param name="type">The type of event to handle</param>
  20. /// <param name="onActivated">The operation to do when the event is created</param>
  21. /// <param name="onDestroyed">The operation to do when the event is destroyed (if applicable)</param>
  22. /// <returns>The created object</returns>
  23. public static SimpleEventHandlerEngine CreateAddSimpleHandler(string name, int type, Action onActivated, Action onDestroyed)
  24. {
  25. var engine = new SimpleEventHandlerEngine(onActivated, onDestroyed, type, name);
  26. EventManager.AddEventHandler(engine);
  27. return engine;
  28. }
  29. /// <summary>
  30. /// Factory method which automatically adds the SimpleEventHandlerEngine to the Manager
  31. /// </summary>
  32. /// <param name="name">The name of the engine</param>
  33. /// <param name="type">The type of event to handle</param>
  34. /// <param name="onActivated">The operation to do when the event is created</param>
  35. /// <param name="onDestroyed">The operation to do when the event is destroyed (if applicable)</param>
  36. /// <returns>The created object</returns>
  37. public static SimpleEventHandlerEngine CreateAddSimpleHandler(string name, int type, Action<EntitiesDB> onActivated, Action<EntitiesDB> onDestroyed)
  38. {
  39. var engine = new SimpleEventHandlerEngine(onActivated, onDestroyed, type, name);
  40. EventManager.AddEventHandler(engine);
  41. return engine;
  42. }
  43. /// <summary>
  44. /// Factory method which automatically adds the SimpleEventEmitterEngine to the Manager
  45. /// </summary>
  46. /// <param name="name">The name of the engine</param>
  47. /// <param name="type">The type of event to emit</param>
  48. /// <param name="isRemovable">Will removing this engine not break your code?</param>
  49. /// <returns>The created object</returns>
  50. public static SimpleEventEmitterEngine CreateAddSimpleEmitter(string name, int type, bool isRemovable = true)
  51. {
  52. var engine = new SimpleEventEmitterEngine(type, name, isRemovable);
  53. EventManager.AddEventEmitter(engine);
  54. return engine;
  55. }
  56. }
  57. }